Skip to main content
Every capability Claude Code can exercise — reading a file, running a shell command, fetching a URL, spawning a sub-agent — is a tool. Tools are the atomic unit of action in the agent loop. When the Claude API returns a tool_use block, the loop looks up the matching tool by name, validates the input, checks permissions, and calls it.

The Tool interface

Every tool is a TypeScript object that satisfies the Tool<Input, Output, Progress> type defined in src/Tool.ts. The interface is divided into four groups of methods.

Lifecycle methods

These methods run in sequence for every tool invocation.

Capability flags

These methods let the executor and permission system know how to handle a tool safely.

Rendering methods

Tools render their own UI in the terminal (React/Ink). The loop never dictates how a tool looks.

AI-facing methods

These methods shape how the model sees the tool.

buildTool() factory

All tools are created through the buildTool() factory function in src/Tool.ts. It merges safe defaults for the commonly-stubbed methods so that callers never need ?.() ?? default.
The defaults applied by buildTool() are all fail-closed where it matters:
Every tool in the codebase goes through buildTool(). The factory also ensures that userFacingName always returns the tool’s name even when the tool definition omits it.

Complete tool inventory

File operations

Tools that read, write, and edit files on the local filesystem.

Search & discovery

Tools for finding files and content across the codebase.

Execution

Tools that run code or system commands.

Web & network

Tools that access the internet.

Agent & task management

Tools for spawning and coordinating agents and tasks.

Planning & workflow

Tools for structured planning and worktree management.

MCP protocol

Tools for interacting with Model Context Protocol servers.

System & interaction

Tools for user interaction, configuration, and system management.

Tool result size limits

Every tool sets a maxResultSizeChars property. When a result exceeds this limit, the output is saved to a temporary file and Claude receives a preview with the file path instead of the full content. This prevents single large tool results from consuming the entire context window. FileReadTool sets maxResultSizeChars to Infinity — it self-bounds through its own read limits and persisting would create a circular Read → file → Read loop.

Deferred tools

When the shouldDefer flag is true on a tool, it is sent to the model with defer_loading: true and its full schema is omitted from the initial system prompt. The model must call ToolSearchTool first to locate and load the tool’s schema. This reduces prompt size when many tools are registered. Set alwaysLoad: true on a tool to force its schema into the initial prompt regardless of deferral settings. For MCP tools, this is controlled via _meta['anthropic/alwaysLoad'].