agentleFS
saizulsaizul/ai-agent-builder-skills/skills/tool-schema-design/SKILL.md

tool-schema-design

Skill0 starsChanged 8 days agoMITView on GitHub

Design and review tool (function-calling) definitions that LLM agents call reliably - verb-object names, descriptions that say what, when and what it returns, typed parameters with descriptions, enums instead of prose lists, correct required fields, closed objects, small focused tools, clear error results - with a linter for JSON Schema tool definitions that flags missing descriptions, ambiguous parameter names, enum candidates, unknown required fields, missing types, array items, overlapping tools and duplicates. Use when writing or reviewing tools/functions for an agent, when the model calls the wrong tool or invents arguments, or when wrapping an internal API as agent tools.

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Write tools: idempotency key or natural key, dry-run/preview option when actions are costly.

    line 43
  2. Very specific:

    Test tool selection: Write 3-5 eval cases per tool (should call / should not call / needs clarification) with tool_called / tool_not_called …

    line 57

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Tool schema design

The model only sees the tool name, description and parameter schema. Treat them as the user interface for the model: precise, unambiguous, and tested.

Paths below are relative to this skill's folder.

When to use

  • Writing new tools/functions for an agent, or exposing an internal API as tools
  • "The model picks the wrong tool", "it makes up arguments", "it never calls X"
  • Reviewing a pull request that changes tool definitions
  • Consolidating dozens of endpoint-shaped tools into fewer task-shaped ones

When not to use

  • Designing the public HTTP API itself (that is API design, not tool design)
  • Prompt wording outside the tool definitions: use system-prompt-review
  • Deciding which tools the agent should have at all: start with agent-scoping

Workflow

  1. List the tasks, not the endpoints. From the agent spec, write the user-level actions (e.g. "find an order for this customer"). One tool per action; merge endpoints that are always called together; split tools whose behaviour depends on a mode flag.
  2. Write each definition following references/design-rules.md:
    • Name: verb_object (lookup_order, create_return), unique, no generic do_action.
    • Description: what it does, when to use it (and when not to), what it returns, side effects and whether the user must confirm first. 1-4 sentences.
    • Parameters: type and description on every property, formats and examples in the description, enum for fixed sets, minimum/maximum for ranges, required listing the mandatory ones, "additionalProperties": false.
    • Write tools: idempotency key or natural key, dry-run/preview option when actions are costly.
  3. Lint the definitions.
    python3 scripts/tool_schema_lint.py tools.json
    python3 scripts/tool_schema_lint.py tools/*.json --json
    python3 scripts/tool_schema_lint.py tools.json --fail-on high --min-severity low
    Input can be one tool, a list, or {"tools": [...]}; flat (name, description, parameters/input_schema/inputSchema) or wrapped ({"type": "function", "function": {...}}). Exit 1 when findings at or above --fail-on (default medium) exist. Add it to CI.
  4. Design the results too. Return compact JSON with only the fields the model needs, stable keys, and actionable errors ({"error": "order_not_found", "hint": "ask for the order number from the confirmation email"}), never stack traces. See the results section in references/design-rules.md.
  5. Test tool selection. Write 3-5 eval cases per tool (should call / should not call / needs clarification) with tool_called / tool_not_called checks in eval-harness. Overlapping tools flagged by the linter are the first suspects when selection fails.
  6. Show the diff of the improved definitions and explain each change in one line.

Decision points

  • More than ~15-20 tools: group by task, load tool subsets per conversation stage, or add a routing step; long tool lists reduce selection accuracy.
  • Free-text parameter that is really a choice: make it an enum; if the set is large or changes often, add a search/lookup tool instead.
  • The model must not see raw IDs: accept natural keys (order number + email) and resolve them server-side.
  • Dangerous actions: split into prepare_x (returns a summary) and confirm_x (requires the token from prepare) so confirmation is enforced in code, not only in the prompt.

Output

tools.json: 6 tools, 9 findings (2 high, 4 medium, 3 low)
[HIGH]   create_refund: 'required' lists 'order_id' which is not a property
[HIGH]   helper: tool has no description
[MEDIUM] search_orders .status: description lists allowed values; use 'enum'
[MEDIUM] lookup_order, get_order: descriptions are 71% similar; say how they differ
Proposed: merge get_order into lookup_order, rename helper -> check_return_eligibility,
add enum ["open","shipped","delivered","returned"], fix required -> ["order_number"].

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.