CC
Claude Code
v2.1.88
Claude CodeModule Map

Module Map

8 modules · ~301K lines total

Claude 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.

Bridge — SDK Entry
Top — Orchestrator
Mid — Capabilities
Lower — Infrastructure
Foundation — Utils
A → B = A depends on B
Top tier
Capabilities
Foundation

Recommended Reading Order

Start from the foundation and work upward. Each module builds on the ones below it.

1
Utils220 files · 60K lines

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.

2
Permissions30 files · 20K lines

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

3
Services110 files · 80K lines

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.

4
Tools140 files · 65K lines

Fourth — where Claude's capabilities live. 43 tools, all using services + permissions.

Why: 43 independent tool implementations, each with schema, permissions, and result rendering

5
Query/Engine15 files · 15K lines

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

6
Components346 files · 40K lines

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.

7
Commands110 files · 8K 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.

8
Bridge12 files · 13K lines

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

Codebase at a Glance

Largest module
Components
346 files
Smallest module
Bridge
12 files
Thickest file
messages.ts
5512 lines
Total tools
43+
built-in