🔧 Core Architecture

Tool.ts

The Tool Interface System - How Claude Interacts with the World

792 Lines
29.5KB Size
45+ Tools Defined
TS Language
01

Core Tool Type

Tool.ts - Tool Definition
export type Tool = {
  name: string                    // Unique tool identifier
  description: string             // What the tool does
  inputSchema: ToolInputJSONSchema // JSON Schema for input
  definition?: {                     // API-facing definition
    name: string
    description: string
    input_schema: ToolInputJSONSchema
  }
  execute(                           // Tool execution function
    input: Record<string, unknown>,
    context: ToolUseContext
  ): Promise<ToolResult>
  isAutomated?: boolean            // Auto-approve in auto mode
}
📌
Key Insight

Every tool in Claude Code - from FileReadTool to BashTool to AgentTool - implements this same interface. The execute() function receives typed input and returns a structured ToolResult.

02

Permission Modes

🔒

Default Mode

Safest

User is prompted for each tool execution. Every action requires explicit approval. Recommended for beginners and sensitive environments.

FileRead: Prompt BashTool: Prompt FileEdit: Prompt

Auto Mode

Balanced

AI automatically approves safe operations via a classifier. Dangerous operations still require user approval. Best for experienced developers.

FileRead: Auto rm -rf: Prompt GrepTool: Auto

Bypass Mode

Dangerous

No prompting - all tools are auto-approved. Requires explicit setup. Use with extreme caution in trusted environments only.

FileRead: Auto rm -rf: Auto BashTool: Auto
03

Tool Categories

💡 Try This Experiment

Go to the Playground Permission Simulator. Compare what happens when you use Default vs Auto mode for BashTool:rm.

Open Permission Simulator