
Agent Tool Design
- 1 installs
- 36 repo stars
- Updated July 14, 2026
- oimiragieo/agent-studio
Presents 5 principles for designing tools agents call reliably: predictable named signatures, rich errors, token-efficient structured output, idempotency, and graceful degradation.
About
This skill defines the Agent Tool Contract with five principles and an anti-pattern table for building tools that agents invoke reliably. A developer uses it when designing agent-facing tools or MCP tool signatures.
- 5 principles plus 8 common anti-patterns
- Named params, machine-readable errors, idempotent retries
Agent Tool Design by the numbers
- 1 all-time installs (skills.sh)
- Ranked #14,098 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
- Data as of Jul 31, 2026 (Skillselion catalog sync)
npx skills add https://github.com/oimiragieo/agent-studio --skill agent-tool-designAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 1 |
|---|---|
| repo stars | ★ 36 |
| Last updated | July 14, 2026 |
| Repository | oimiragieo/agent-studio ↗ |
What it does
Presents 5 principles for designing tools agents call reliably: predictable named signatures, rich errors, token-efficient structured output, idempotency, and graceful degradation.
Files
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 onPrinciple 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 errorPrinciple 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-Pattern | Problem | Fix |
|---|---|---|
| Verbose status wrapping | Wastes tokens; agent re-parses to extract data | Return data directly |
| Positional args | Ambiguous; breaks on refactor | Named params with types |
| Swallowed exceptions | Agent thinks success; work is lost | Always surface errors explicitly |
| Non-idempotent mutations | Retry causes duplicate data or errors | Upsert semantics; check-then-set |
| Hard failures on partial input | One bad item breaks entire batch | Return partial results |
| Side-effect-heavy reads | Read tools that trigger writes confuse agents | Separate reads from writes |
| String error messages only | Agent can't programmatically handle errors | Include machine-readable error codes |
| Untyped return shape | Agent can't reliably destructure output | Document 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-creatorskill when designing new tools - Reviewed by:
code-revieweragent during tool PRs - Pairs with:
dynamic-api-integrationskill (consuming external tools) - Complements:
agent-evaluationskill (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.
Invoke the agent-tool-design skill and follow it exactly as presented to you
'use strict';
/**
* Post-execute hook for agent-tool-design
* Auto-generated by enterprise-bundle-scaffolder
*
* Records metrics after skill execution.
*/
function postExecute(_context) {
// Record execution metrics
return { ok: true, skill: 'agent-tool-design' };
}
module.exports = { postExecute };
'use strict';
/**
* Pre-execute hook for agent-tool-design
* Auto-generated by enterprise-bundle-scaffolder
*
* Validates inputs before skill execution.
*/
function preExecute(context) {
// Validate skill invocation context
if (!context || typeof context !== 'object') {
return { allow: true, message: 'agent-tool-design: no context to validate' };
}
return { allow: true };
}
module.exports = { preExecute };
agent-tool-design Research Requirements
Generated: 2026-02-28
Skill Description
'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.'
Research Areas
- Current best practices for agent-tool-design
- Industry standards and tooling
- Integration patterns
Source References
- To be populated by skill-updater research phase
agent-tool-design Rules
Purpose
'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.'
Best Practices
- Parameters are named not positional
- Errors include machine-readable code plus human message plus context
- Output is structured data only — no prose
- Tools are idempotent (safe to retry)
- Partial failure returns partial results rather than throws
Integration Points
See SKILL.md for complete documentation.
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "agent-tool-designInput",
"description": "Input schema for '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.'",
"type": "object",
"additionalProperties": true,
"properties": {
"target": {
"type": "string",
"description": "Target file or path for the skill to operate on"
},
"options": {
"type": "object",
"description": "Additional options for skill execution",
"additionalProperties": true
}
}
}
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "agent-tool-designOutput",
"type": "object",
"additionalProperties": true,
"properties": {
"ok": {
"type": "boolean"
},
"summary": {
"type": "string"
}
}
}
#!/usr/bin/env node
/**
* Agent Tool Design - Main Script
* The Agent Tool Contract — 5 principles for designing tools agents call reliably with anti-pattern table
*/
const options = Object.fromEntries(
process.argv
.slice(2)
.filter(arg => arg.startsWith('--'))
.map(flag => [flag.replace(/^--/, ''), true])
);
if (options.help) {
console.log('Agent Tool Design - Main Script');
process.exit(0);
}
console.warn('WARNING: This skill is currently a scaffold and has no implementation.');
process.exit(1);
agent-tool-design Implementation Template
Goal
- Define target outcome and acceptance criteria.
TDD
1. Red 2. Green 3. Refactor
Verification
- lint
- format
- targeted tests