What: How It Shows Up in Your World
This codebase exposes three external product forms, all sharing the same core engine:
Claude Code
├── CLI Tool → Run `claude` in terminal, conversational coding
├── Agent SDK → API for developers to embed Claude in their own products
└── MCP Server Mode → Standard protocol exposing Claude's tools to external systems
There is also a key infrastructure concept:
└── MCP Client → Claude Code connects outward to external MCP servers (databases, Slack, etc.)
CLI Tool (src/entrypoints/cli.tsx)
The primary form. Users open a terminal in their project directory, type claude, and enter an interactive session. Supported modes include:
- Interactive mode: Conversational; Claude asks the user before requesting permissions
- Non-interactive mode (
--print): Single-shot execution, exits after output, suitable for scripting - Remote mode (
CLAUDE_CODE_REMOTE=true): Runs inside a cloud container (CCR environment) with an 8 GB memory ceiling
Agent SDK (src/entrypoints/sdk/)
A programmatic interface for developers who want to embed Claude Code's capabilities into their own products. Key differences from the CLI:
- The CLI is for humans — it has an interactive permission dialog
- The SDK is for programs — permissions are configured via code parameters, no dialog appears
- The SDK does not enable REPL mode (a batch tool-call mode exclusive to internal Anthropic employees)
All type definitions live in src/entrypoints/agentSdkTypes.ts, including 25 Hook events (PreToolUse, PostToolUse, SessionStart, etc.) that let integrators inject custom logic at any key point in the pipeline.
What is a Hook? Think of Claude Code's execution as an assembly line: user input → Claude thinking → tool execution → result returned. A Hook is a pre-drilled socket at a specific point on that line — you plug your own logic in, and it fires automatically at that moment. For example, the PreToolUse Hook lets you attach a script that logs every Bash command Claude is about to run, or routes it through a security-audit system. The assembly line itself needs no modification; you simply "hang a hook" at the right spot.
MCP Server Mode (src/entrypoints/mcp.ts)
Claude Code can itself become an MCP server (claude/tengu), exposing its full tool suite (Bash, file read/write, search…) via the MCP standard protocol. This lets any other MCP-compatible AI client (Cursor, another Claude instance) call Claude Code's tool capabilities directly.
MCP Client (the reverse direction)
Beyond acting as a server, Claude Code is simultaneously an MCP client — it can connect to external MCP servers, giving Claude access to externally provided tools (database queries, Slack messages, GitHub APIs, etc.). This is the tool system's extension mechanism, covered in detail in C. Tool System.