Reverse-engineered source of @anthropic-ai/claude-code v2.1.88, restored from the published source map for educational study.
sources/ # Original npm package files
cli.js # Bundled entry point (13MB)
cli.js.map # Source map (60MB)
sdk-tools.d.ts # SDK type definitions
package.json # Package metadata
restored/ # Source restored from source map
src/ # Application source (1,884 TypeScript/TSX files)
vendor/ # Native addon source
node_modules/ # Bundled dependencies
docs/ # Architecture & mechanism analysis (33 documents)
00-11 # Architecture overview series (12 docs)
deep-dive/ # Deep-dive mechanism analysis (21 docs)
33 documents covering the complete internals of Claude Code, organized in two series:
| # | Document | Topic |
|---|---|---|
| 00 | Architecture Overview | Bird's-eye view, module map, data flow |
| 01 | Bootstrap & Lifecycle | Startup sequence, 10 phases, CLI options |
| 02 | Conversation Loop | query() async generator, message flow |
| 03 | Tool System | Tool interface, registry, permissions, hooks |
| 04 | Agent & Task System | 7 task types, AgentTool, Teams/Swarms |
| 05 | Command System | 80+ commands, registry, filtering |
| 06 | Terminal UI | Custom Ink framework, rendering pipeline, Vim |
| 07 | Context Engine | CLAUDE.md, context collection, compaction |
| 08 | Plugin & Skill System | Plugin lifecycle, SKILL.md, hooks |
| 09 | MCP Integration | MCP client, tool mapping, resources |
| 10 | Services & Infrastructure | API, auth, analytics, settings, LSP |
| 11 | Permission & Security | Permission modes, classifier, sandbox |
| # | Document | Topic |
|---|---|---|
| dd-01 | Hooks | 26 events, 4 hook types, execution engine |
| dd-02 | Plugins | Manifest, marketplace, lifecycle |
| dd-03 | Subagent Orchestration | Fork cache sharing, isolation modes |
| dd-04 | Agent Teams / Swarms | Mailbox, permission sync, tmux/in-process |
| dd-05 | Memory System | 5-layer architecture, auto dream |
| dd-06 | Remote Control | CCR, Bridge, Teleport, WebSocket |
| dd-07 | Context Compaction | 4-layer token management |
| dd-08 | Permission Classifier | Auto mode, YOLO classifier, bash security |
| dd-09 | GrowthBook Features | Compile-time + runtime feature gates |
| dd-10 | Settings System | 7-layer merge, MDM, hot-reload |
| dd-11 | Query Engine | Streaming, error recovery, token budget |
| dd-12 | OAuth / Auth | PKCE, keychain, multi-backend |
| dd-13 | Sandbox / Bash Security | 23 security checks, AST analysis |
| dd-14 | LSP Integration | Server management, diagnostics, 8 operations |
| dd-15 | Cost & Rate Limits | Model pricing, quota, early warnings |
| dd-16 | Vim State Machine | 11 substates, motions, operators, text objects |
| dd-17 | Worktree Isolation | Session/agent worktrees, hooks |
| dd-18 | Background Sessions | Daemon mode, bg/ps/logs/attach/kill |
| dd-19 | Voice Mode | Audio capture, STT, hold-to-talk |
| dd-20 | Prompt Suggestions | Suggestion generation, speculation, tips |
| dd-21 | Output Styles | Style system, plugin integration |
- Language: TypeScript (TSX/TS), ESM modules
- Build: Bun bundler (single-file cli.js)
- UI: React + custom Ink terminal framework + Yoga layout
- CLI: Commander.js
- Runtime: Node.js 18+
This repository is for educational and research purposes only. All rights to Claude Code belong to Anthropic. The restored source is derived from publicly available npm package artifacts. Do not use this code for commercial purposes or to create competing products.