Design tools agents use well
How to write tool names, descriptions and inputs that Claude uses correctly, return useful errors, and keep each tool small and focused. 8 min
Read
The description does most of the work
Claude chooses and calls tools from their names, descriptions and input schemas. Anthropic calls detailed descriptions by far the most important factor in tool performance and suggests at least three or four sentences: what the tool does, when to use it and when not to, what each input means, and what it does not return.
Write for a capable new starter who knows nothing about your systems. Spell out formats ("dates as YYYY-MM-DD"), limits ("returns at most 10 orders") and links between tools ("customer_id comes from crm_find_customer").
On the Claude API, tool names must match ^[a-zA-Z0-9_-]{1,128}$. When you have many tools, prefix them by service, such as crm_find_customer and crm_list_orders, so Claude does not mix up similar ones.
Lesson notes: Design tools agents use well
Everything in this lesson as text, for revision or to read without the interactive steps. By the end you will be able to: You can define a tool that Claude picks at the right time, calls correctly and recovers from when it fails.
Step 1 of 6 · Read
The description does most of the work
Claude chooses and calls tools from their names, descriptions and input schemas. Anthropic calls detailed descriptions by far the most important factor in tool performance and suggests at least three or four sentences: what the tool does, when to use it and when not to, what each input means, and what it does not return.
Write for a capable new starter who knows nothing about your systems. Spell out formats ("dates as YYYY-MM-DD"), limits ("returns at most 10 orders") and links between tools ("customer_id comes from crm_find_customer").
On the Claude API, tool names must match
^[a-zA-Z0-9_-]{1,128}$. When you have many tools, prefix them by service, such ascrm_find_customerandcrm_list_orders, so Claude does not mix up similar ones.Step 2 of 6 · Improve a prompt
Rewrite a weak tool description
Rewrite the description of a tool that looks up orders in a small online shop's database.
Starting prompt:
Gets orders.
Hint: Say when to use it, what the input means with an example, what it returns and in what shape, a limit, and what it must not be used for.
Show a strong version
Find recent orders for one customer of our online shop. Use this when the user asks about a customer's order status, delivery or return. The input customer_email is the exact email on the account, for example "sam.jones@example.co.uk". Returns at most 10 orders as a list, newest first, with order number, date, status and total. It does not return card details and must not be used to change an order.
Step 3 of 6 · Read
Inputs Claude cannot get wrong
Use names that cannot be misread:
customer_email, notuser. Useenumwhere only some values are valid, mark which inputs are required, and give every property its own description.Set
strict: trueon a tool definition and Claude's inputs are guaranteed to match your schema, which rules out missing or wrongly typed parameters. For awkward nested inputs, addinput_examples; each one costs roughly 100 to 200 input tokens.A tool definition for the Claude API { "name": "crm_list_orders", "description": "Lists recent orders for one customer. Use after crm_find_customer has returned a customer_id. Returns at most 10 orders, newest first, with order number, date, status and total. Does not return payment details.", "strict": true, "input_schema": { "type": "object", "properties": { "customer_id": { "type": "string", "description": "The customer_id returned by crm_find_customer, for example cus_4471" }, "status": { "type": "string", "enum": ["open", "dispatched", "returned"], "description": "Only return orders with this status. Leave out for all statuses." } }, "required": ["customer_id"] } }Step 4 of 6 · Read
Return less, and fail helpfully
Return only what Claude needs for its next step. Prefer readable names and stable identifiers over internal codes, and filter or page large results instead of dumping everything. Anthropic's engineering team gives the example of a
search_contactstool beating alist_contactstool that pours every contact into the conversation.When something fails, say what went wrong and what to try next. On the API, send a
tool_resultwithis_error: true. In an MCP server, raiseToolErrorin Python or returnisError: truein TypeScript. "Rate limit exceeded. Retry after 60 seconds." gets a recovery; "failed" gets a guess. Claude may retry, so cap retries in your own loop.A useful error result { "type": "tool_result", "tool_use_id": "toolu_01A09q90qw90lq917835lq9", "content": "No customer found for sam@exampel.co.uk. Check the spelling, or call crm_find_customer with the customer's name instead.", "is_error": true }Step 5 of 6 · Sort
Good tool design or not?
Sort each design choice.
- One crm_find_customer tool that searches by name or email
- A list_all_contacts tool that returns 40,000 rows
- An error that says the email was not found and suggests searching by name
- A parameter called data that accepts anything
- Returning the customer's name alongside their ID
- Twelve near-identical tools, one per API endpoint
Show the answers
- One crm_find_customer tool that searches by name or email: Good design. Focused on the job Claude actually has to do.
- A list_all_contacts tool that returns 40,000 rows: Needs work. It floods the context. Offer search and filters instead.
- An error that says the email was not found and suggests searching by name: Good design. It tells Claude what went wrong and what to try next.
- A parameter called data that accepts anything: Needs work. Claude has to guess what to send. Name and type each input.
- Returning the customer's name alongside their ID: Good design. Readable names help Claude reason and reduce mix-ups.
- Twelve near-identical tools, one per API endpoint: Needs work. Anthropic advises grouping related operations into fewer, clearer tools.
Step 6 of 6 · Quiz
Check your understanding
Claude keeps calling your get_invoice tool without the invoice number. What is the best first fix?
- Mark invoice_number as required, describe its format with an example, and consider strict: true
- Add a line to the system prompt asking Claude to remember the number
- Retry the call automatically until it works
Show the answer
Mark invoice_number as required, describe its format with an example, and consider strict: true Missing inputs usually mean the definition did not tell Claude enough. Strict mode then guarantees the schema is followed.