src/tools.ts and lives under src/tools/<ToolName>/.
Each tool defines five things:
- Input schema — Zod-validated parameters
- Permission model — What requires user approval
- Execution logic — The tool’s implementation
- UI components — Terminal rendering for invocation and results
- Concurrency safety — Whether it can run in parallel
Tool definition pattern
Tools are constructed withbuildTool(). The following example shows every hook a tool can implement:
Directory structure
Each tool follows a consistent four-file layout:Permission model
Every tool invocation passes through the permission system atsrc/hooks/toolPermission/. The active mode determines how approval is handled:
| Mode | Behavior |
|---|---|
default | Prompt the user for each potentially destructive operation |
plan | Show the full plan, ask once |
bypassPermissions | Auto-approve everything (dangerous) |
auto | ML-based classifier decides |
checkPermissions(), which returns { granted: boolean, reason?, prompt? }.
Tool presets
Tools are grouped into presets insrc/tools.ts for different contexts:
- Read-only preset — Safe for code review, analysis, and exploration. Includes
FileReadTool,GlobTool,GrepTool,WebFetchTool, and similar read-only tools. - Full toolset — The complete set for active development, including shell execution, file writes, and agent orchestration.
Tool categories
File System Tools
Read, write, edit, and search files and code. Includes
FileReadTool, FileEditTool, GlobTool, GrepTool, and more.Shell & Execution Tools
Run shell commands and code in REPL sessions. Includes
BashTool, PowerShellTool, and REPLTool.Agent & Task Tools
Spawn sub-agents, manage teams, and run background tasks. Includes
AgentTool, TaskCreateTool, and more.Web, MCP & Integrations
Web access, MCP server interaction, LSP, scheduling, and utility tools.