src/tools.ts. Claude decides which tool to call, the permission layer checks whether to allow it, and the result is fed back into the next API turn.
How the tool loop works
Tool anatomy
Every tool is a TypeScript module that exports an object conforming to theTool interface defined in src/Tool.ts. The three required parts are:
1. Input schema (Zod)
Tools declare their inputs using Zod v4 schemas. The schema is compiled to JSON Schema and sent to the Anthropic API so Claude knows what arguments are valid.2. Permission declaration
Each tool declares whether it is read-only, mutating, or dangerous. This declaration is used by the permission layer to decide the default behavior before prompting the user.3. Execute function
The execute function receives validated input and aToolUseContext (working directory, abort signal, permission mode, etc.) and returns a result that Claude can read.
Tool registration
All tools are registered insrc/tools.ts. Some tools are always included; others are conditionally loaded based on feature flags or environment variables:
Built-in tools
File tools
File tools
Tools for reading, writing, and editing files on disk.
File read and write operations are subject to the permission model. Write and edit tools require explicit user approval in default mode.See File tools reference for full input schemas.
| Tool | Description |
|---|---|
FileReadTool | Read file contents; supports text, images, PDFs, and Jupyter notebooks |
FileWriteTool | Create or overwrite a file |
FileEditTool | Partial file modification via exact string replacement |
NotebookEditTool | Edit individual cells in a Jupyter notebook |
Search tools
Search tools
Tools for finding files and content across the codebase.
| Tool | Description |
|---|---|
GlobTool | Find files by glob pattern (e.g., **/*.ts) |
GrepTool | Content search powered by ripgrep |
ToolSearchTool | Deferred tool discovery — finds the right tool for a task |
GrepTool shells out to rg for performance. It supports full regex syntax and file-type filters.See Search tools reference for full input schemas.Shell tools
Shell tools
Tools for executing shell commands and running processes.
| Tool | Description |
|---|---|
BashTool | Execute a shell command in the current working directory |
LSPTool | Query a Language Server Protocol server (hover, diagnostics, go-to-definition) |
BashTool is the most permissive built-in tool. It runs arbitrary shell commands and is classified as dangerous — it will always prompt for approval in default mode unless you have added an allow rule.Agent tools
Agent tools
Tools for spawning sub-agents and coordinating multi-agent work.
See Agent tools reference for full input schemas and the Agent swarms guide.
| Tool | Description |
|---|---|
AgentTool | Spawn a sub-agent with its own context window and tool set |
SkillTool | Execute a saved skill (reusable workflow) |
TeamCreateTool | Create a team of parallel agents |
TeamDeleteTool | Tear down a team |
SendMessageTool | Send a message between agents in a swarm |
TaskCreateTool | Create a tracked task |
TaskUpdateTool | Update task status or output |
TaskGetTool | Read a task |
TaskListTool | List all tasks |
EnterPlanModeTool | Switch to plan mode (propose without executing) |
ExitPlanModeTool | Exit plan mode and resume execution |
EnterWorktreeTool | Isolate work to a git worktree |
ExitWorktreeTool | Return from a git worktree |
SleepTool | Pause execution (proactive mode) |
Web tools
Web tools
Tools for fetching content from the web.
See Web tools reference.
| Tool | Description |
|---|---|
WebFetchTool | Fetch a URL and return its content as text or markdown |
WebSearchTool | Run a web search and return results |
MCP tools
MCP tools
Tools exposed by connected Model Context Protocol servers.
MCP tools are registered dynamically when servers connect and are namespaced by server name to avoid collisions. See MCP servers.
| Tool | Description |
|---|---|
MCPTool | Invoke a tool provided by an MCP server |
ListMcpResourcesTool | List resources available on an MCP server |
ReadMcpResourceTool | Read an MCP server resource |
Tool permission levels
Tools declare one of three permission levels that determine the default approval behavior:| Level | Examples | Default behavior |
|---|---|---|
| Read-only | FileReadTool, GlobTool, GrepTool | Auto-approved in most modes |
| Mutating | FileWriteTool, FileEditTool | Prompts user for approval |
| Dangerous | BashTool | Always prompts; classifier may pre-approve safe patterns |
Related pages
Permission model
How every tool call is checked before execution.
File tools
Full reference for file read, write, and edit tools.
Search tools
Full reference for glob and grep tools.
MCP servers
Connect external tools via the Model Context Protocol.