N
Nexus API Referencev2.4.1

The Tool Surface

The tool registry is where the model's "what can I do?" surface is defined. Claw Code registers 50 tools through a four-field struct, dispatches them through a single match statement, and lazily materializes the schemas of all but the six most common.

The ToolSpec struct

crates/tools/src/lib.rs:102:

@dataclass(frozen=True)
class ToolSpec:
    name: str
    description: str
    input_schema: dict      # JSONSchema
    required_permission: PermissionMode

That's it. Four fields: name and description (interned at compile time in the Rust impl), schema as a JSON object, permission as an enum. The list is built by mvp_tool_specs() at line 393, which returns a Vec<ToolSpec> of all 50 tools.

The dispatcher is execute_tool_with_enforcer(name, input, enforcer) at line 1201, a giant match on name. Each arm calls into the appropriate function in the runtime crate, threading the optional &PermissionEnforcer through.

The 50 tools, by category

File & shell (the eager six + extras)

ToolPermissionEager?Schema highlights
bashDangerFullAccessyescommand, timeout, description, run_in_background, dangerouslyDisableSandbox, filesystemMode
read_fileReadOnlyyespath (required), offset, limit
write_fileWorkspaceWriteyespath, content
edit_fileWorkspaceWriteyespath, old_string, new_string, replace_all
glob_searchReadOnlyyespattern, path
grep_searchReadOnlyyespattern, path, glob, output_mode, -B/-A/-C, context, -n, -i, type, head_limit, offset, multiline
NotebookEditWorkspaceWritedeferrednotebook_path, cell_id, new_source, cell_type, edit_mode
REPLDangerFullAccessdeferredcode, language, timeout_ms
PowerShellDangerFullAccessdeferredcommand, timeout, description, run_in_background

Web

ToolPermissionEager?Notes
WebFetchReadOnlydeferredurl, prompt — fetches and processes content with a small model
WebSearchReadOnlydeferredquery (min length 2), allowed_domains, blocked_domains

Conversation control

ToolPermissionEager?Notes
SkillReadOnlydeferredskill, args — invoke a registered skill
AgentDangerFullAccessdeferreddescription, prompt, subagent_type, name, model — spawn sub-agent
ToolSearchReadOnlydeferredquery, max_results — fetch deferred tool schemas on demand
SleepReadOnlydeferredduration_ms
SendUserMessageReadOnlydeferredmessage, attachments, status (normal/proactive). Also exposed as Brief.
ConfigWorkspaceWritedeferredsetting, value (string/bool/number)
EnterPlanModeWorkspaceWritedeferred(no params)
ExitPlanModeWorkspaceWritedeferred(no params)
StructuredOutputReadOnlydeferredflexible schema (additionalProperties: true)
AskUserQuestionReadOnlydeferredquestion, options
TodoWriteWorkspaceWritedeferredtodos array of {content, activeForm, status}

Tasks, workers, teams, crons (the multi-agent surface)

ToolPermissionNotes
TaskCreateDangerFullAccessprompt, description
RunTaskPacketDangerFullAccessfull structured packet: objective, scope, repo, branch_policy, acceptance_tests, commit_policy, reporting_contract, escalation_policy
TaskGet, TaskList, TaskOutputReadOnlytask introspection
TaskStop, TaskUpdateDangerFullAccesstask_id + state-change ops
WorkerCreateDangerFullAccesscwd, trusted_roots, auto_recover_prompt_misdelivery
WorkerGet, WorkerObserve, WorkerAwaitReadyReadOnlyworker introspection / ready-handshake
WorkerResolveTrust, WorkerSendPrompt, WorkerRestart, WorkerTerminate, WorkerObserveCompletionDangerFullAccessworker control
TeamCreate, TeamDeleteDangerFullAccessparallel-task team management
CronCreate, CronDelete, CronListDangerFullAccess / ReadOnlyscheduled triggers (5-field cron expressions stored as strings)

MCP / remote / LSP

ToolPermissionNotes
LSPReadOnlyaction ∈ {symbols, references, diagnostics, definition, hover}, path, line, character, query
ListMcpResources, ReadMcpResourceReadOnlyMCP server resource listing/reading
McpAuthDangerFullAccessserver — kicks OAuth flow
RemoteTriggerDangerFullAccessurl, method (GET/POST/PUT/DELETE), headers, body — generic webhook
MCPDangerFullAccessserver, tool, arguments — execute server tool by name
TestingPermissionDangerFullAccesstest-only, validates the enforcer itself

The deferred mechanism (why this matters)

crates/tools/src/lib.rs:4944–4954 defines deferred_tool_specs(), which filters mvp_tool_specs() and excludes the eager six (bash/read/write/edit/glob/grep). searchable_tool_specs() is the deferred set; total_deferred_tools (line 337) tracks the count.

The mechanism: at session start, the model only sees full schemas for the eager six tools plus a ToolSearch tool. Every other tool is referenced by name in the system prompt or in tool-use guidance, but its parameter schema is not loaded. When the model wants to call (e.g.) WorkerCreate, it first calls ToolSearch({"query": "select:WorkerCreate"}). The harness returns the JSONSchema for WorkerCreate, which is then valid for the next turn's tool call.

This pattern is directly visible in any live Claude Code session's system prompt: "Some tools are deferred and not listed above. When a deferred tool is surfaced later in the conversation, its full schema appears as a <function>{...}</function> definition inside a <functions> block (the same encoding as the tool list above), and it is immediately callable exactly like any tool defined here."

The win: 50 tool schemas, especially for tools with rich schemas like RunTaskPacket or all the MCP tools (which can total hundreds of tokens each), would balloon the system prompt. With deferred loading, the typical session only ever materializes ~5–10 tool schemas. The cost is one extra round-trip per first-use.

Permission category as a coarse filter

Five PermissionMode levels (crates/runtime/src/permissions.rs:9–15):

ReadOnly  →  WorkspaceWrite  →  DangerFullAccess  →  Prompt  →  Allow

Two of these (Prompt, Allow) are session modes, not tool requirements. The other three are the tiers tools declare:

  • ReadOnly: can never write, run shells, or escape the session
  • WorkspaceWrite: can write files, but only inside the workspace root
  • DangerFullAccess: arbitrary shell, network, file writes anywhere

Note: 21 of 50 tools require DangerFullAccess, which is a high count. In practice most of those are worker/team/cron-management tools whose risk model is "they enable spawning more agents, which may then do dangerous things," not "they are dangerous themselves." This is over-classified. Real Claude Code likely splits this into a finer enum (e.g. "spawn-agent" as a distinct category from "filesystem-write").

The full permission decision flow is covered in Permissions & Sandboxing.


Continue: Sub-agents & Context Cleanliness

Last updated: May 14, 2026