Claude Code Deep Dive
Understanding Claude Code's architecture from source. Not a usage guide — an engineering dissection of how each module is designed and why.
The Big Picture — More Than a CLI Tool
4756 TypeScript files, multiple entry points, one agent runtime. What Claude Code actually is under the hood.
02The Engine — Main Loop and Prompt Assembly
How cli.tsx hands off to query.ts, why it's an async generator instead of recursion, and the 10 steps that run on every turn.
03Tool System — 42 Tools and a Governance Pipeline
The Tool interface, fail-closed defaults, all 42 tools categorized, and the 14-step execution pipeline that runs before any tool touches your filesystem.
04Multi-Agent Architecture
Six built-in agent roles, how AgentTool.tsx dispatches sub-agents, fork path cache optimization, and the full agent lifecycle in runAgent.ts.
05Security — Permissions, Hooks, and Three Defense Layers
27 permission files, the hook system's five capabilities, and why hook allow doesn't override settings deny.
06Ecosystem — Skills, Plugins, MCP
17 bundled skills, 42 plugin files, MCP instruction injection, and why model awareness of its own capabilities is the key design insight.
07Context Economics — Tokens as Budget
Four compression mechanisms, reactive compact as API 413 fallback, the token budget system, and lazy injection for skills and memory.
08Design Principles and Productionization
What it takes to ship an agent as a production tool: lifecycle management, Bridge, state, TUI, telemetry, and seven principles extracted from the codebase.