Search: Dozens of Tools, Pulled In on Demand

Claude Code has 40 built-in tools (each corresponding to a subdirectory under src/tools/), grouped by function:

GroupToolsDescription
File operationsFileReadTool, FileWriteTool, FileEditToolRead, write, edit files
Code searchGlobTool, GrepToolFile name matching, content search
Command executionBashTool, PowerShellToolExecute shell commands (cross-platform)
Agent collaborationAgentTool, SendMessageTool, TeamCreateTool, TeamDeleteToolSpawn sub-agents, team collaboration
Task managementTaskCreateTool, TaskGetTool, TaskListTool, TaskOutputTool, TaskStopTool, TaskUpdateToolFull lifecycle management of background tasks
Plan modeEnterPlanModeTool, ExitPlanModeToolPlan only, don't execute
Sandbox isolationEnterWorktreeTool, ExitWorktreeToolEnter/exit git worktree isolated environment
MCP protocolMCPTool, McpAuthTool, ListMcpResourcesTool, ReadMcpResourceToolConnect to external MCP servers and their resources
NetworkWebFetchTool, WebSearchToolFetch web pages, search engine queries
NotebookNotebookEditToolEdit Jupyter Notebooks
Dev toolingREPLTool, LSPTool, ToolSearchTool, SkillToolBatch tool calls, language service, tool search, skill loading
Interaction & configAskUserQuestionTool, ConfigTool, TodoWriteToolAsk user questions, read/write config, task lists
SchedulingScheduleCronTool, RemoteTriggerTool, SleepToolScheduled tasks, remote triggers, waits
Internal toolsBriefTool, SyntheticOutputToolInternal summary generation, synthetic output (not exposed externally)

Loading all of them into Claude's context on the first turn would waste tokens. shouldDefer and alwaysLoad solve this:

// src/Tool.ts
readonly shouldDefer?: boolean
// When true: only the tool's name is sent — no full parameter schema
// Claude must call ToolSearch first to get the full definition before calling the tool

readonly alwaysLoad?: boolean
// When true: even if lazy-loading is enabled globally, this tool always includes its full schema
// Suitable for tools Claude needs in the first turn (like ToolSearch itself)

This mechanism implements "on-demand loading": common tools (Bash, FileEdit) always load; rarely used tools (e.g. CronCreate) are hidden first — Claude uses ToolSearch with keywords to retrieve the full definition.