Module Map
8 modules · ~301K lines totalClaude Code is organized into 8 logical modules. This hub shows their dependencies, explains reading order, and links to each module's deep-dive page.
Architecture Dependency Graph
Visual layout of module dependencies. Click any box to jump to that module's page.
All 8 Modules
The orchestrator — every user message passes through here, running the 7-phase agent loop.
43 tools implementing a unified interface — from BashTool to AgentTool, each with its own schema and permissions.
Background infrastructure: API client, MCP runtime (470KB!), context compaction, LSP, memory extraction.
5 security layers between you and disaster, including a classifier literally named yoloClassifier.
React for the terminal — Ink + Yoga flexbox engine powering the entire REPL visual experience.
101 slash commands — from /compact and /model to /stickers and /color. Each owns its own directory.
The SDK bridge — exposes Claude Code as a headless programmatic API for subagents and remote execution.
The foundation layer — Bash AST parser, message manipulation, session storage. No inbound dependencies.
Recommended Reading Order
Start from the foundation and work upward. Each module builds on the ones below it.
Start here — foundation with no dependencies. Understand the building blocks.
Why: 5 files are larger than most npm packages. messages.ts (5512 lines) is a complete message library.
Second — security layer used by everything. Understand what checkPermissions() does.
Why: 5 security layers, 4 rule matching types, real HackerOne CVEs patched — small but dense
Third — the infrastructure. API client, MCP, compaction. Powers the loop.
Why: 470KB MCP client alone. 8 subsystems. The API client streams tokens from 3 providers.
Fourth — where Claude's capabilities live. 43 tools, all using services + permissions.
Why: 43 independent tool implementations, each with schema, permissions, and result rendering
Fifth — the orchestrator. Now you know what it's orchestrating.
Why: 15 files each averaging 1000+ lines — orchestrates the entire agent loop in minimal code
Sixth — the terminal UI that wraps everything above.
Why: 346 files but avg ~115 lines — many small focused components. REPL.tsx alone is 5005 lines.
Seventh — slash commands, the user-facing control layer.
Why: 110 files but only 8K total — avg ~73 lines per file. Each command is simple and self-contained.
Finally — how the whole stack runs headless as an SDK.
Why: Only 12 files but avg ~1083 lines each — dense WebSocket adapters and multi-worker coordination