This skill should be used when the user asks to "design agent tools", "create tool descriptions", "reduce tool complexity", "implement MCP tools", or mentions tool consolidation, architectural reduction, tool naming conventions, or agent-tool interfaces.
Add this skill
npx mdskills install muratcankoylan/tool-designComprehensive, actionable instructions for designing agent-friendly tools with strong architectural insights
1---2name: tool-design3description: This skill should be used when the user asks to "design agent tools", "create tool descriptions", "reduce tool complexity", "implement MCP tools", or mentions tool consolidation, architectural reduction, tool naming conventions, or agent-tool interfaces.4---56# Tool Design for Agents78Tools are the primary mechanism through which agents interact with the world. They define the contract between deterministic systems and non-deterministic agents. Unlike traditional software APIs designed for developers, tool APIs must be designed for language models that reason about intent, infer parameter values, and generate calls from natural language requests. Poor tool design creates failure modes that no amount of prompt engineering can fix. Effective tool design follows specific principles that account for how agents perceive and use tools.910## When to Activate1112Activate this skill when:13- Creating new tools for agent systems14- Debugging tool-related failures or misuse15- Optimizing existing tool sets for better agent performance16- Designing tool APIs from scratch17- Evaluating third-party tools for agent integration18- Standardizing tool conventions across a codebase1920## Core Concepts2122Tools are contracts between deterministic systems and non-deterministic agents. The consolidation principle states that if a human engineer cannot definitively say which tool should be used in a given situation, an agent cannot be expected to do better. Effective tool descriptions are prompt engineering that shapes agent behavior.2324Key principles include: clear descriptions that answer what, when, and what returns; response formats that balance completeness and token efficiency; error messages that enable recovery; and consistent conventions that reduce cognitive load.2526## Detailed Topics2728### The Tool-Agent Interface2930**Tools as Contracts**31Tools are contracts between deterministic systems and non-deterministic agents. When humans call APIs, they understand the contract and make appropriate requests. Agents must infer the contract from descriptions and generate calls that match expected formats.3233This fundamental difference requires rethinking API design. The contract must be unambiguous, examples must illustrate expected patterns, and error messages must guide correction. Every ambiguity in tool definitions becomes a potential failure mode.3435**Tool Description as Prompt**36Tool descriptions are loaded into agent context and collectively steer behavior. The descriptions are not just documentation—they are prompt engineering that shapes how agents reason about tool use.3738Poor descriptions like "Search the database" with cryptic parameter names force agents to guess. Optimized descriptions include usage context, examples, and defaults. The description answers: what the tool does, when to use it, and what it produces.3940**Namespacing and Organization**41As tool collections grow, organization becomes critical. Namespacing groups related tools under common prefixes, helping agents select appropriate tools at the right time.4243Namespacing creates clear boundaries between functionality. When an agent needs database information, it routes to the database namespace. When it needs web search, it routes to web namespace.4445### The Consolidation Principle4647**Single Comprehensive Tools**48The consolidation principle states that if a human engineer cannot definitively say which tool should be used in a given situation, an agent cannot be expected to do better. This leads to a preference for single comprehensive tools over multiple narrow tools.4950Instead of implementing list_users, list_events, and create_event, implement schedule_event that finds availability and schedules. The comprehensive tool handles the full workflow internally rather than requiring agents to chain multiple calls.5152**Why Consolidation Works**53Agents have limited context and attention. Each tool in the collection competes for attention in the tool selection phase. Each tool adds description tokens that consume context budget. Overlapping functionality creates ambiguity about which tool to use.5455Consolidation reduces token consumption by eliminating redundant descriptions. It eliminates ambiguity by having one tool cover each workflow. It reduces tool selection complexity by shrinking the effective tool set.5657**When Not to Consolidate**58Consolidation is not universally correct. Tools with fundamentally different behaviors should remain separate. Tools used in different contexts benefit from separation. Tools that might be called independently should not be artificially bundled.5960### Architectural Reduction6162The consolidation principle, taken to its logical extreme, leads to architectural reduction: removing most specialized tools in favor of primitive, general-purpose capabilities. Production evidence shows this approach can outperform sophisticated multi-tool architectures.6364**The File System Agent Pattern**65Instead of building custom tools for data exploration, schema lookup, and query validation, provide direct file system access through a single command execution tool. The agent uses standard Unix utilities (grep, cat, find, ls) to explore, understand, and operate on your system.6667This works because:681. File systems are a proven abstraction that models understand deeply692. Standard tools have predictable, well-documented behavior703. The agent can chain primitives flexibly rather than being constrained to predefined workflows714. Good documentation in files replaces the need for summarization tools7273**When Reduction Outperforms Complexity**74Reduction works when:75- Your data layer is well-documented and consistently structured76- The model has sufficient reasoning capability to navigate complexity77- Your specialized tools were constraining rather than enabling the model78- You're spending more time maintaining scaffolding than improving outcomes7980Reduction fails when:81- Your underlying data is messy, inconsistent, or poorly documented82- The domain requires specialized knowledge the model lacks83- Safety constraints require limiting what the agent can do84- Operations are truly complex and benefit from structured workflows8586**Stop Constraining Reasoning**87A common anti-pattern is building tools to "protect" the model from complexity. Pre-filtering context, constraining options, wrapping interactions in validation logic. These guardrails often become liabilities as models improve.8889The question to ask: are your tools enabling new capabilities, or are they constraining reasoning the model could handle on its own?9091**Build for Future Models**92Models improve faster than tooling can keep up. An architecture optimized for today's model may be over-constrained for tomorrow's. Build minimal architectures that can benefit from model improvements rather than sophisticated architectures that lock in current limitations.9394See [Architectural Reduction Case Study](./references/architectural_reduction.md) for production evidence.9596### Tool Description Engineering9798**Description Structure**99Effective tool descriptions answer four questions:100101What does the tool do? Clear, specific description of functionality. Avoid vague language like "helps with" or "can be used for." State exactly what the tool accomplishes.102103When should it be used? Specific triggers and contexts. Include both direct triggers ("User asks about pricing") and indirect signals ("Need current market rates").104105What inputs does it accept? Parameter descriptions with types, constraints, and defaults. Explain what each parameter controls.106107What does it return? Output format and structure. Include examples of successful responses and error conditions.108109**Default Parameter Selection**110Defaults should reflect common use cases. They reduce agent burden by eliminating unnecessary parameter specification. They prevent errors from omitted parameters.111112### Response Format Optimization113114Tool response size significantly impacts context usage. Implementing response format options gives agents control over verbosity.115116Concise format returns essential fields only, appropriate for confirmation or basic information. Detailed format returns complete objects with all fields, appropriate when full context is needed for decisions.117118Include guidance in tool descriptions about when to use each format. Agents learn to select appropriate formats based on task requirements.119120### Error Message Design121122Error messages serve two audiences: developers debugging issues and agents recovering from failures. For agents, error messages must be actionable. They must tell the agent what went wrong and how to correct it.123124Design error messages that enable recovery. For retryable errors, include retry guidance. For input errors, include corrected format. For missing data, include what's needed.125126### Tool Definition Schema127128Use a consistent schema across all tools. Establish naming conventions: verb-noun pattern for tool names, consistent parameter names across tools, consistent return field names.129130### Tool Collection Design131132Research shows tool description overlap causes model confusion. More tools do not always lead to better outcomes. A reasonable guideline is 10-20 tools for most applications. If more are needed, use namespacing to create logical groupings.133134Implement mechanisms to help agents select the right tool: tool grouping, example-based selection, and hierarchy with umbrella tools that route to specialized sub-tools.135136### MCP Tool Naming Requirements137138When using MCP (Model Context Protocol) tools, always use fully qualified tool names to avoid "tool not found" errors.139140Format: `ServerName:tool_name`141142```python143# Correct: Fully qualified names144"Use the BigQuery:bigquery_schema tool to retrieve table schemas."145"Use the GitHub:create_issue tool to create issues."146147# Incorrect: Unqualified names148"Use the bigquery_schema tool..." # May fail with multiple servers149```150151Without the server prefix, agents may fail to locate tools, especially when multiple MCP servers are available. Establish naming conventions that include server context in all tool references.152153### Using Agents to Optimize Tools154155Claude can optimize its own tools. When given a tool and observed failure modes, it diagnoses issues and suggests improvements. Production testing shows this approach achieves 40% reduction in task completion time by helping future agents avoid mistakes.156157**The Tool-Testing Agent Pattern**:158159```python160def optimize_tool_description(tool_spec, failure_examples):161 """162 Use an agent to analyze tool failures and improve descriptions.163164 Process:165 1. Agent attempts to use tool across diverse tasks166 2. Collect failure modes and friction points167 3. Agent analyzes failures and proposes improvements168 4. Test improved descriptions against same tasks169 """170 prompt = f"""171 Analyze this tool specification and the observed failures.172173 Tool: {tool_spec}174175 Failures observed:176 {failure_examples}177178 Identify:179 1. Why agents are failing with this tool180 2. What information is missing from the description181 3. What ambiguities cause incorrect usage182183 Propose an improved tool description that addresses these issues.184 """185186 return get_agent_response(prompt)187```188189This creates a feedback loop: agents using tools generate failure data, which agents then use to improve tool descriptions, which reduces future failures.190191### Testing Tool Design192193Evaluate tool designs against criteria: unambiguity, completeness, recoverability, efficiency, and consistency. Test tools by presenting representative agent requests and evaluating the resulting tool calls.194195## Practical Guidance196197### Anti-Patterns to Avoid198199Vague descriptions: "Search the database for customer information" leaves too many questions unanswered.200201Cryptic parameter names: Parameters named x, val, or param1 force agents to guess meaning.202203Missing error handling: Tools that fail with generic errors provide no recovery guidance.204205Inconsistent naming: Using id in some tools, identifier in others, and customer_id in some creates confusion.206207### Tool Selection Framework208209When designing tool collections:2101. Identify distinct workflows agents must accomplish2112. Group related actions into comprehensive tools2123. Ensure each tool has a clear, unambiguous purpose2134. Document error cases and recovery paths2145. Test with actual agent interactions215216## Examples217218**Example 1: Well-Designed Tool**219```python220def get_customer(customer_id: str, format: str = "concise"):221 """222 Retrieve customer information by ID.223224 Use when:225 - User asks about specific customer details226 - Need customer context for decision-making227 - Verifying customer identity228229 Args:230 customer_id: Format "CUST-######" (e.g., "CUST-000001")231 format: "concise" for key fields, "detailed" for complete record232233 Returns:234 Customer object with requested fields235236 Errors:237 NOT_FOUND: Customer ID not found238 INVALID_FORMAT: ID must match CUST-###### pattern239 """240```241242**Example 2: Poor Tool Design**243244This example demonstrates several tool design anti-patterns:245246```python247def search(query):248 """Search the database."""249 pass250```251252**Problems with this design:**2532541. **Vague name**: "search" is ambiguous - search what, for what purpose?2552. **Missing parameters**: What database? What format should query take?2563. **No return description**: What does this function return? A list? A string? Error handling?2574. **No usage context**: When should an agent use this versus other tools?2585. **No error handling**: What happens if the database is unavailable?259260**Failure modes:**261- Agents may call this tool when they should use a more specific tool262- Agents cannot determine correct query format263- Agents cannot interpret results264- Agents cannot recover from failures265266## Guidelines2672681. Write descriptions that answer what, when, and what returns2692. Use consolidation to reduce ambiguity2703. Implement response format options for token efficiency2714. Design error messages for agent recovery2725. Establish and follow consistent naming conventions2736. Limit tool count and use namespacing for organization2747. Test tool designs with actual agent interactions2758. Iterate based on observed failure modes2769. Question whether each tool enables or constrains the model27710. Prefer primitive, general-purpose tools over specialized wrappers27811. Invest in documentation quality over tooling sophistication27912. Build minimal architectures that benefit from model improvements280281## Integration282283This skill connects to:284- context-fundamentals - How tools interact with context285- multi-agent-patterns - Specialized tools per agent286- evaluation - Evaluating tool effectiveness287288## References289290Internal references:291- [Best Practices Reference](./references/best_practices.md) - Detailed tool design guidelines292- [Architectural Reduction Case Study](./references/architectural_reduction.md) - Production evidence for tool minimalism293294Related skills in this collection:295- context-fundamentals - Tool context interactions296- evaluation - Tool testing patterns297298External resources:299- MCP (Model Context Protocol) documentation300- Framework tool conventions301- API design best practices for agents302- Vercel d0 agent architecture case study303304---305306## Skill Metadata307308**Created**: 2025-12-20309**Last Updated**: 2025-12-23310**Author**: Agent Skills for Context Engineering Contributors311**Version**: 1.1.0312
Full transparency — inspect the skill content before installing.