References: Tool use, the foundation
Source material
Section titled “Source material”Source curriculum (structural mirror, cited as further study):• Anthropic Academy (https://anthropic.skilljar.com/): "Building with the Claude API" course (tools sections) License: Anthropic Academy course content is account-gated; Clawdemy structurally mirrors the Academy's lesson progression as inspiration and cites it as further study. Every substantive claim in this lesson is verifiable against the public Anthropic documentation.
Primary public-doc anchors (every substantive claim verified against):• Anthropic, "Tool use with Claude" (overview, token-cost table, client-vs-server distinction) https://platform.claude.com/docs/en/agents-and-tools/tool-use/overview• Anthropic, "Handle tool calls" (tool_use / tool_result shapes, two ordering rules, is_error semantics, parallel patterns) https://platform.claude.com/docs/en/agents-and-tools/tool-use/handle-tool-calls• Anthropic, "Define tools" https://platform.claude.com/docs/en/agents-and-tools/tool-use/define-tools• Anthropic, "Strict tool use" (schema-conformance guarantee) https://platform.claude.com/docs/en/agents-and-tools/tool-use/strict-tool-use• Anthropic, "Structured outputs" (the separate feature) https://platform.claude.com/docs/en/build-with-claude/structured-outputs
Verbatim claims sourced from the public docs:• "Tool result blocks must immediately follow their corresponding tool use blocks in the message history" (Handle tool calls, Rule 1)• "In the user message containing tool results, the tool_result blocks must come FIRST in the content array. Any text must come AFTER all tool results." (Handle tool calls, Rule 2)• "If you receive an error like 'tool_use ids were found without tool_result blocks immediately after', check that your tool results are formatted correctly." (Handle tool calls)• "Write instructive error messages. Instead of generic errors like 'failed', include what went wrong and what Claude should try next, e.g., 'Rate limit exceeded. Retry after 60 seconds.'" (Handle tool calls, error guidance)• Per-model tool-use system-prompt token counts from the Tool use overview pricing section. Example values at this lesson's drafting: Opus 4.8 (290 / 410), Opus 4.7 (675 / 804), Opus 4.6 / Sonnet 4.6 (497 / 589), Opus 4.5 / Sonnet 4.5 / Haiku 4.5 (496 / 588), Opus 4.1 (313 / 315); auto/none vs any/tool. The any and specific-tool modes are slightly higher than auto and none.
Required attribution: "Based on the structure of the Anthropic Academy 'Building with the Claude API' course (https://anthropic.skilljar.com/). This lesson is an independent structural mirror in original prose; every substantive claim is verified against the public Anthropic Claude documentation at https://platform.claude.com/docs/. Anthropic does not endorse it."
This is lesson 4 of 12 in Track 22 (Building with Claude). The previouslesson is lesson 3 (Choosing your model and the effort dial), whichclosed Phase 1. This lesson OPENS Phase 2 (augmentation patterns);the next is lesson 5 (Server-side tools and built-ins).Read this next
Section titled “Read this next”- Anthropic, “Tool use with Claude”. The canonical entry point; covers the client-vs-server distinction at depth and links the full sub-documentation tree (define, handle, strict, parallel, runner, tool reference).
- Anthropic, “Handle tool calls”. The definitive reference for the two ordering rules and the is_error semantics; covers all the tool_result content shapes (string, list of content blocks including image and document).
- Anthropic, “Define tools”. Deeper on tool definitions: when to add examples to the description, schema patterns that work well, naming conventions.
- Anthropic, “Strict tool use”. The strict: true feature that guarantees tool inputs match your schema exactly; eliminates invalid tool-call retries entirely.
- Anthropic, “Tool Runner”. The SDK abstraction that automates the four-step loop; worth reading after you have done a manual loop once.
Going deeper
Section titled “Going deeper”A short, durable list. Each link is a specific next step inside Track 22.
- Lesson 5 of this track, “Server-side tools and built-ins.” The Anthropic-provided side of the tool layer: server tools where Anthropic executes (web search, web fetch, code execution, tool search) AND Anthropic-schema client tools where your code executes against a canonical Anthropic schema (bash, computer use, memory, text_editor). The other side of the client-vs-server split this lesson named, plus the schema-canonical client variant.
- Lesson 6 of this track, “Model Context Protocol.” How one tool definition can speak across many model providers, and when the MCP connector beats inline tool definitions.
- Lesson 7 of this track, “Prompt caching and context management.” The cost lever for the tool-definition overhead this lesson named: when tool definitions are stable across calls, prompt caching cuts the repeated cost.
- Lesson 8 of this track, “From single call to agent loop.” Where the four-step loop becomes a multi-turn agent loop; the model and your tools talk back and forth across many turns until a task is done.
- Lesson 11 of this track, “Subagents and Claude Managed Agents.” Where the subagent pattern (one orchestrator + many specialist subagents, each with its own tool set) lands. (For the tool_search server tool that handles large tool catalogs, see lesson 5.)
Adjacent tracks (the natural next destinations)
Section titled “Adjacent tracks (the natural next destinations)”- Track 21 (LLM Ops and Production): pick this if you want the provider-agnostic view of tool use (its lesson 4, “Augmented LLMs,” covers the same concept at the principle level). T22 L8 cross-references T21 L10 “Agents” for the loop-pattern source; tool use is what makes that loop possible.
- Track 20 (AI Agents and Tool Use): pick this if you want the full track-level treatment of tool use and agents (ten lessons end to end on agent design and tool patterns, not pegged to one provider). T22 lesson 4 here is the Anthropic-specific instance of the principles T20 develops at depth.
Where this connects inside the track
Section titled “Where this connects inside the track”The primitive every Phase 2 and Phase 3 lesson extends:
- Lesson 1 (first call): the content array (introduced as “iterate, not index”) is now load-bearing. tool_use blocks live alongside text blocks in the same array; the iterate-not-index pattern is what made this lesson workable.
- Lesson 2 (production patterns): the stop_reason check (lesson 2 covered end_turn / max_tokens / stop_sequence) now adds the tool_use case as a fourth value to dispatch on.
- Lesson 3 (model selection): the effort parameter affects ALL tokens including tool calls. Lower effort means fewer tool calls and terser preambles; higher effort means more tool calls and detailed plans.
- Lesson 5 (server-side tools): the same tools declaration, but no tool_use / tool_result round-trip in your code.
- Lesson 6 (MCP): the same loop, but the tool definitions come from a separate MCP server (or directly from the MCP connector inline).
- Lesson 7 (prompt caching): the tools overhead (a few hundred system-prompt tokens per model plus tool definitions) is exactly the kind of stable repeated content prompt caching addresses.
- Lesson 8 onward (agent loop): one tool round-trip is the unit; the agent loop is N round-trips where the model decides when to stop. Every round-trip is the four-step pattern this lesson establishes.
- Lesson 11 (subagents): each subagent has its own tools and runs its own four-step loop; the orchestrator coordinates.