← Blog

Claude API Tool Use Schema Design Tips

2026-11-18 · 5 min read · SubToAPI Team

Tool use in the Claude API lives or dies on schema quality. A badly described tool gets ignored, called with wrong arguments, or triggers hallucinated parameters. The fix isn't a bigger model — it's a tighter schema. Below are concrete, battle-tested tips for writing input_schema definitions that Claude reliably understands and calls correctly.

If you're new to tool use, the short version: you define tools as JSON Schema objects with a name, description, and input_schema, Claude decides when to call them, and you execute the function yourself and return the result. The quality of your schema directly determines the quality of the calls. Treat it as an API contract you're writing for a very literal junior developer, not as documentation for humans.

Name tools and parameters like a public API

Claude reads tool and parameter names as semantic hints, not just identifiers.

Write descriptions that answer "when" and "what", not just "what"

The biggest lever for correct tool selection is the description field, both on the tool itself and on each parameter.

{
  "name": "get_weather",
  "description": "Get the current weather conditions for a specific city. Use this only when the user asks about current or real-time weather, not historical weather or forecasts.",
  "input_schema": {
    "type": "object",
    "properties": {
      "city": {
        "type": "string",
        "description": "The city name, e.g. 'Berlin' or 'San Francisco'. Do not include country unless the city name is ambiguous."
      },
      "units": {
        "type": "string",
        "enum": ["celsius", "fahrenheit"],
        "description": "Temperature unit. Default to celsius if the user doesn't specify."
      }
    },
    "required": ["city"]
  }
}

Notice the description tells Claude the boundary condition ("not historical weather or forecasts"). This is often more important than describing what the tool does — it prevents false positives where Claude calls a tool that technically could apply but shouldn't.

Constrain types aggressively

JSON Schema gives you more than string and number. Use it.

"priority": {
  "type": "string",
  "enum": ["low", "medium", "high"],
  "description": "Ticket priority. Default to 'medium' if not specified by the user."
}

Keep required fields minimal and realistic

Mark a field required only if the tool genuinely cannot run without it. Every additional required field is another place Claude can either stall (asking the user a clarifying question when it shouldn't) or invent a plausible-sounding value to satisfy the schema. If a field has a sensible default, say so in the description and leave it optional — don't force Claude to guess at values it should be allowed to omit.

Avoid deeply nested or sprawling objects

Flat schemas are easier for Claude to fill in correctly than deeply nested ones. If you have a tool with five levels of nested objects, split it into multiple tools or flatten the structure where possible. When nesting is unavoidable (e.g., an address object), keep each nested object small and give it its own description so it reads as a coherent unit rather than a maze of properties.

Design for one job per tool

Resist the urge to build a single mega-tool with a type parameter that switches behavior ("action": "create" | "update" | "delete"). This pattern looks efficient but increases the chance Claude picks the wrong action or mixes parameters meant for different actions. Split into create_ticket, update_ticket, and delete_ticket instead — each with a tight, specific schema. Smaller, single-purpose tools are easier for Claude to select correctly and easier for you to validate and test independently.

Handle tool errors explicitly in the conversation

Tool use isn't just the schema — it's also how you report back. If a tool call fails (invalid ID, downstream API timeout, permission denied), return a clear tool_result with is_error: true and a human-readable message. Claude uses that message to decide whether to retry with different arguments, ask the user for clarification, or give up gracefully. A silent or vague error ("failed") gives Claude nothing to work with and often leads to repeated bad calls.

{
  "type": "tool_result",
  "tool_use_id": "toolu_01A...",
  "content": "No order found with id 'ORD-9999'. Order IDs follow the format ORD-XXXX.",
  "is_error": true
}

Test with adversarial prompts

Once your schema is written, don't just test the happy path. Try ambiguous requests, requests that could match two tools, and requests with missing information. If Claude calls the wrong tool or invents a parameter value, that's a schema problem to fix — usually a description that's too vague or two tools whose boundaries overlap.

If you're building against the Claude API through SubToAPI, tool definitions and tool_result handling work exactly as described in the tool use docs — SubToAPI passes through the same request and response shape, so schemas you design this way work unchanged. Check the quickstart for setup and the messages reference for the full request format.

Questions

Does a longer description always improve tool calling? No. Past a point, extra detail dilutes the signal. Aim for 1–3 sentences that state purpose, scope, and boundary conditions — longer than that and key constraints get buried.

Should I use anyOf or oneOf for flexible parameters? Avoid them where possible. Claude handles flat, single-type properties much more reliably than polymorphic schemas. If you need flexibility, prefer separate optional fields or separate tools.

How many tools can I give Claude in one request? There's no hard cap, but accuracy drops as tool count grows and descriptions overlap. Keep the active tool set focused on what's relevant to the current task rather than exposing your entire API surface at once.

Turn your Claude access into an HTTPS API

SubToAPI gives you application API keys, streaming, tool use and usage insights on top of your existing Claude access — set up in minutes.

Start free  Read the quickstart →