본문으로 건너뛰기
cccskills
무료GitHub에 공개

agent-tool-design

The Agent Tool Contract — 5 principles for designing tools agents call reliably: predictable signature, rich errors, token-efficient output, idempotency, graceful degradation. Includes anti-pattern table with 8 common mistakes.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(10)

  • SKILL.md6.1 KB
  • commands/agent-tool-design.md117 B
  • hooks/post-execute.cjs312 B
  • hooks/pre-execute.cjs429 B
  • references/research-requirements.md516 B
  • rules/agent-tool-design.md611 B
  • schemas/input.schema.json703 B
  • schemas/output.schema.json261 B
  • scripts/main.cjs531 B
  • templates/implementation-template.md191 B

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Agent Tool Design

The Agent Tool Contract — 5 principles for designing tools that agents call reliably.

The 5 Principles

Principle 1: Predictable Signature

Tools must have typed, named parameters with clear required/optional distinction. No positional ambiguity.

Good:

// Clear, named, typed
function searchCode({ query, limit = 20, type = 'semantic' }) { ... }

Bad:

// Positional, ambiguous
function searchCode(q, n, t) { ... }

Principle 2: Rich Errors

Errors must include: error code (machine-readable), message (human-readable), context (debugging data).

Good:

throw {
  code: 'FILE_NOT_FOUND',
  message: `File not found: ${path}`,
  context: { path, cwd: process.cwd() },
};

Bad:

throw new Error('not found'); // No context for agent to act on

Principle 3: Token-Efficient Output

Tools return structured minimal data. No prose explanations, no redundant wrapping, no verbose status messages. Agents format output themselves.

Good:

return { files: ['a.js', 'b.js'], total: 2 };

Bad:

return { status: 'success', message: 'Found 2 files successfully', data: { files: [...], metadata: {...} } };

Rule of thumb: If the output contains prose an agent would re-read to extract facts, it's too verbose.

Principle 4: Idempotency

Tools must be safe to retry. Running a tool twice should produce the same result as running it once.

Good:

// Upsert instead of insert
db.upsert({ id, ...data });
// mkdir -p instead of mkdir
fs.mkdirSync(path, { recursive: true });

Bad:

// Fails on retry
db.insert({ id, ...data }); // duplicate key error
fs.mkdirSync(path); // EEXIST error

Principle 5: Graceful Degradation

Partial success > hard failure. Return what succeeded with a clear indication of what didn't.

Good:

return {
  succeeded: ['file1.js', 'file2.js'],
  failed: [{ file: 'file3.js', reason: 'PERMISSION_DENIED' }],
  partial: true,
};

Bad:

// One file fails -> entire batch throws
throw new Error('Failed to process file3.js');

Anti-Pattern Table

Anti-PatternProblemFix
Verbose status wrappingWastes tokens; agent re-parses to extract dataReturn data directly
Positional argsAmbiguous; breaks on refactorNamed params with types
Swallowed exceptionsAgent thinks success; work is lostAlways surface errors explicitly
Non-idempotent mutationsRetry causes duplicate data or errorsUpsert semantics; check-then-set
Hard failures on partial inputOne bad item breaks entire batchReturn partial results
Side-effect-heavy readsRead tools that trigger writes confuse agentsSeparate reads from writes
String error messages onlyAgent can't programmatically handle errorsInclude machine-readable error codes
Untyped return shapeAgent can't reliably destructure outputDocument and enforce return schema

Review Checklist

Before shipping any tool:

[ ] Parameters are named (not positional)
[ ] Required vs optional params are explicit
[ ] All error paths return { code, message, context }
[ ] Output contains no prose — only structured data
[ ] Tool is idempotent (safe to retry)
[ ] Partial failure returns partial results, not throws
[ ] Return shape is documented in JSDoc or TypeScript types
[ ] Token budget for output estimated (< 500 tokens for standard tools)

Iron Laws

  1. ALWAYS use named parameters — never positional arguments in tool signatures; positional args break on refactor and create ambiguity for agents.
  2. ALWAYS include machine-readable error codes — never surface plain string errors only; agents need { code, message, context } to handle errors programmatically.
  3. NEVER mix reads and writes in the same tool — read tools that trigger side effects confuse agents and prevent safe retries.
  4. ALWAYS design for idempotency — retry must produce the same result as the first call; use upsert semantics and mkdir -p patterns.
  5. ALWAYS return partial results on partial failure — never let one failing item abort the entire batch; return { succeeded, failed, partial: true }.

Integration

  • Used by: tool-creator skill when designing new tools
  • Reviewed by: code-reviewer agent during tool PRs
  • Pairs with: dynamic-api-integration skill (consuming external tools)
  • Complements: agent-evaluation skill (evaluating tool output quality)

Memory Protocol (MANDATORY)

Before starting: Read .claude/context/memory/learnings.md

After completing:

  • New pattern -> .claude/context/memory/learnings.md
  • Issue found -> .claude/context/memory/issues.md
  • Decision made -> .claude/context/memory/decisions.md

ASSUME INTERRUPTION: If it's not in memory, it didn't happen.

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Ensure accessibility in UI components including semantic HTML, ARIA attributes, keyboard navigation, and WCAG 2.2 AA compliance.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

oimiragieo/agent-studio422026년 7월 14일 업데이트

Use when you want to improve response quality through meta-cognitive reasoning. Applies 15+ reasoning methods to reconsider and refine initial outputs.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

oimiragieo/agent-studio422026년 7월 14일 업데이트

N-round opposing-stance debates for trade-off analysis. Assigns pro/con roles to agents, runs structured debate rounds with quality scoring, and produces a moderator synthesis with confidence-rated recommendation. Generalizable to architecture, technology, security, and design decisions.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

oimiragieo/agent-studio422026년 7월 14일 업데이트

Force adversarial code review stance that eliminates confirmation bias — reviewer must find issues or re-analyze

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

oimiragieo/agent-studio422026년 7월 14일 업데이트

Creates specialized AI agents on-demand when no existing agent matches a request. Use when the Router cannot find a suitable agent for a task. Enables self-evolution by generating persistent agents.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

oimiragieo/agent-studio422026년 7월 14일 업데이트

LLM-as-judge evaluation framework with 5-dimension rubric (accuracy, groundedness, coherence, completeness, helpfulness) for scoring AI-generated content quality with weighted composite scores and evidence citations

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

oimiragieo/agent-studio422026년 7월 14일 업데이트

oimiragieo의 스킬 모두 보기

이 스킬의 문제 신고