Skip to content

jung-wan-kim/claude-code-reverse-engineering

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Status Docs Lines Verification

Claude Code CLI β€” Reverse Engineering Design Documents

Implementation-ready reverse engineering specifications for Anthropic's Claude Code CLI tool. Extracted via source map analysis of the npm package (March 2026).


At a Glance

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                      Claude Code CLI                                β”‚
β”‚                                                                     β”‚
β”‚   ~1,900 files  Β·  512,000+ LOC  Β·  TypeScript Strict  Β·  Bun     β”‚
β”‚                                                                     β”‚
β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”          β”‚
β”‚   β”‚  React   β”‚  β”‚   Ink    β”‚  β”‚  Yoga    β”‚  β”‚Commander β”‚          β”‚
β”‚   β”‚   19     β”‚  β”‚ (custom  β”‚  β”‚ (WASM    β”‚  β”‚   .js    β”‚          β”‚
β”‚   β”‚          β”‚  β”‚   fork)  β”‚  β”‚  layout) β”‚  β”‚          β”‚          β”‚
β”‚   β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜          β”‚
β”‚        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜               β”‚
β”‚                         Terminal UI                                  β”‚
β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚   β”‚                     Core Engine                              β”‚   β”‚
β”‚   β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚   β”‚
β”‚   β”‚  β”‚  45+    β”‚ β”‚  Query   β”‚ β”‚ Streaming β”‚ β”‚    Cost      β”‚   β”‚   β”‚
β”‚   β”‚  β”‚  Tools  β”‚ β”‚  Engine  β”‚ β”‚ Executor  β”‚ β”‚   Tracker    β”‚   β”‚   β”‚
β”‚   β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚   β”‚
β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚   β”‚                    Extension Layer                           β”‚   β”‚
β”‚   β”‚  β”Œβ”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”  β”‚   β”‚
β”‚   β”‚  β”‚ MCP β”‚ β”‚Plugins β”‚ β”‚ Skills β”‚ β”‚Hooks β”‚ β”‚ LSP β”‚ β”‚Bridgeβ”‚  β”‚   β”‚
β”‚   β”‚  β””β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”˜  β”‚   β”‚
β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚   β”‚                     Services                                 β”‚   β”‚
β”‚   β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚   β”‚
β”‚   β”‚  β”‚  API   β”‚ β”‚ Auth β”‚ β”‚ Analytics β”‚ β”‚Settingsβ”‚ β”‚Migrationβ”‚  β”‚   β”‚
β”‚   β”‚  β”‚(4 back)β”‚ β”‚OAuth β”‚ β”‚ DD+OTel  β”‚ β”‚5-layer β”‚ β”‚  chain  β”‚  β”‚   β”‚
β”‚   β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚   β”‚
β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚   β”‚                 Security & Permissions                       β”‚   β”‚
β”‚   β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚   β”‚
β”‚   β”‚  β”‚  7 Perm  β”‚ β”‚ 23 Bash  β”‚ β”‚   Path   β”‚ β”‚  Auto-Mode  β”‚  β”‚   β”‚
β”‚   β”‚  β”‚  Modes   β”‚ β”‚ Checks   β”‚ β”‚Validator β”‚ β”‚ Classifier  β”‚  β”‚   β”‚
β”‚   β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚   β”‚
β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Design Documents

Part 1 β€” Architecture Overview

docs/01-architecture-overview.md Β· 1,101 lines

Startup Sequence (5 phases)
═══════════════════════════════════════════
Phase 0 ─► Module-level side effects (MDM, Keychain prefetch)
Phase 1 ─► main() entry, basic initialization
Phase 2 ─► Commander preAction β†’ init() β†’ migrations
Phase 3 ─► action() β†’ setup() β†’ auth/permissions
Phase 4 ─► REPL render + deferred prefetches
Topic Key Details
Module System ESM-only, .js extensions required, lazy require() for cycles
Build Bun bundler, feature() flags for dead code elimination
Config 7 layers: Global β†’ Project β†’ Settings(5 sources) β†’ CLI β†’ MDM
Feature Flags 89 flags via GrowthBook, bun:bundle compile-time DCE
State 110 global fields in bootstrap/state.ts, DO NOT ADD MORE policy

Part 2 β€” Core Engine

docs/02-core-engine.md Β· 1,352 lines

Tool Execution Pipeline
═══════════════════════════════════════════
User Input ──► QueryEngine ──► LLM API (streaming)
                                    β”‚
                              tool_use block
                                    β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β–Ό               β–Ό               β–Ό
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚ Bash     β”‚  β”‚ FileEdit β”‚  β”‚ Agent    β”‚
              β”‚ Tool     β”‚  β”‚ Tool     β”‚  β”‚ Tool     β”‚
              β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜
                   β”‚             β”‚              β”‚
                   β–Ό             β–Ό              β–Ό
              ToolResult    ToolResult    ToolResult
              { data, newMessages?, contextModifier?, mcpMeta? }
                                    β”‚
                              β—„β”€β”€β”€β”€β”€β”˜
                    Next LLM turn with results
Topic Key Details
Tool Interface 60+ fields, buildTool() factory, 7 defaultable keys
Concurrency isConcurrencySafe flag β€” safe tools run parallel, unsafe exclusive
Recovery 8-stage chain: streaming fallback β†’ model fallback β†’ collapse drain β†’ reactive compact
Cost Tracking Per-session USD accumulator, multi-provider normalization

Part 3 β€” Permission & Security

docs/03-permission-security.md Β· 1,178 lines

Permission Decision Pipeline (4 steps + auto-mode)
═══════════════════════════════════════════════════
Step 0  Config deny rules ──► deny (immediate)
Step 1  Tool.checkPermissions() ──► allow/deny/ask/passthrough
Step 2  Permanent allow rules ──► allow (skip prompt)
Step 3  passthrough β†’ ask conversion
Step 4  Post-processing:
        β”œβ”€β”€ dontAsk mode ──► auto deny
        β”œβ”€β”€ auto mode ──► classifier pipeline:
        β”‚   β”œβ”€β”€ acceptEdits fast-path
        β”‚   β”œβ”€β”€ safe-tool allowlist
        β”‚   └── YOLO classifier (2-stage)
        β”‚       β”œβ”€β”€ allowed ──► allow
        β”‚       β”œβ”€β”€ blocked ──► deny + denial tracking
        β”‚       └── unavailable ──► iron_gate fail-closed
        └── headless ──► hook or deny
Topic Key Details
7 Modes default, plan, acceptEdits, bypassPermissions, dontAsk, auto, bubble
Bash Security 23 check IDs, 19 cross-platform + 7 Unix + 11 ANT-only patterns
Path Validation 6-step: normalize β†’ symlink resolve β†’ traversal β†’ Windows patterns β†’ scope
TOCTOU Warning Path validation and file access are not atomic β€” race condition window

Part 4 β€” Multi-Agent & Memory

docs/04-multi-agent-memory.md Β· 1,416 lines

Agent Hierarchy
═══════════════════════════════════════════
                β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                β”‚  Coordinator  β”‚  (orchestrator β€” no direct tool use)
                β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
           β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
           β–Ό            β–Ό            β–Ό
     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
     β”‚  Worker  β”‚ β”‚  Worker  β”‚ β”‚  Worker  β”‚
     β”‚ (fork)   β”‚ β”‚ (spawn)  β”‚ β”‚(in-proc) β”‚
     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Memory Hierarchy (5 layers)
═══════════════════════════════════════════
[1] Session Memory ── in-context summaries
[2] Project Memory ── .claude/memory/ files
[3] User Memory    ── ~/.claude/memory/
[4] Team Memory    ── server-synced shared memory
[5] External       ── MCP servers, LSP, git
Topic Key Details
3 Swarm Backends fork (shared context), spawn (independent), in-process teammate
Task Types 7 types with ID prefixes: bash, workflow, agent, teammate, remote, monitor, dream
Mailbox File-based: .claude/teams/{team}/inboxes/{agent}.json
Team Sync ETag-based conflict detection (412), no local file locking

Part 5 β€” Extension Systems

docs/05-extension-systems.md Β· 1,709 lines

6 Extension Points
═══════════════════════════════════════════
β”Œβ”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”
β”‚ MCP β”‚ β”‚Plugins β”‚ β”‚ Skills β”‚ β”‚Hooks β”‚ β”‚ LSP β”‚ β”‚Bridgeβ”‚
β”‚     β”‚ β”‚        β”‚ β”‚        β”‚ β”‚      β”‚ β”‚     β”‚ β”‚      β”‚
β”‚8 cfgβ”‚ β”‚market- β”‚ β”‚17 bun- β”‚ β”‚27    β”‚ β”‚code β”‚ β”‚IDE   β”‚
β”‚typesβ”‚ β”‚place + β”‚ β”‚dled +  β”‚ β”‚eventsβ”‚ β”‚intelβ”‚ β”‚comms β”‚
β”‚     β”‚ β”‚builtin β”‚ β”‚custom  β”‚ β”‚      β”‚ β”‚     β”‚ β”‚      β”‚
β””β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”˜
Topic Key Details
MCP Transports TransportSchema: 6 types; McpServerConfig: 8 (+ ws-ide, claudeai-proxy)
Hook Priority deny > ask > allow β€” any hook's deny overrides all allows
Plugin Loading Parallel (marketplace + session) β†’ builtins β†’ merge β†’ dependency verify
Reconnection MAX_ERRORS_BEFORE_RECONNECT=3, SSE maxRetries=2, 15min poll timeout

Part 6 β€” UI Layer

docs/06-ui-layer.md Β· 1,784 lines

Render Pipeline
═══════════════════════════════════════════
React Component Tree
        β”‚
        β–Ό
Custom Reconciler (React 19 HostConfig)
        β”‚
        β–Ό
Yoga Layout Engine (WASM)
        β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”œβ”€β”€β”‚ Box  (flexbox node)  β”‚
        β”œβ”€β”€β”‚ Text (measure func)  β”‚
        └──│ Button (interactive) β”‚
           β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚
        β–Ό
Output Renderer (ANSI diff)
        β”‚
        β–Ό
Terminal stdout (throttled at FRAME_INTERVAL_MS)
Topic Key Details
Ink Fork 96 files in src/ink/, custom reconciler, Yoga WASM integration
Components 346 .tsx files in src/components/
Hooks 85+ custom hooks (useTextInput, useTerminalSize, useStdin, etc.)
Concurrency maySuspendCommit() always returns false β€” Suspense disabled

Part 7 β€” Services & Infrastructure

docs/07-services-infrastructure.md Β· 1,845 lines

API Client Factory (4 backends)
═══════════════════════════════════════════
                β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                β”‚  buildFetch()    β”‚
                β”‚  + withRetry()   β”‚
                β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β–Ό                β–Ό                β–Ό              β–Ό
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚ Anthropicβ”‚    β”‚ Bedrock  β”‚    β”‚ Foundry  β”‚   β”‚ Vertex   β”‚
  β”‚ (Direct) β”‚    β”‚ (AWS)    β”‚    β”‚ (Azure)  β”‚   β”‚ (GCP)    β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Retry Strategy:  429 β†’ Retry-After (≀20s: sleep, >20s: 30min cooldown)
                 529 β†’ MAX_529_RETRIES=3 (non-subscriber only)
                 401 β†’ token refresh β†’ retry (no max refresh limit!)
Topic Key Details
Analytics Datadog (44 allowed events, 16 tag fields) + OpenTelemetry + 1P logger
OAuth PKCE flow, macOS Keychain with plaintext fallback (30s TTL cache)
Settings Merge 5 sources: user β†’ project β†’ local β†’ flag β†’ policy (arrays concat, not override!)
Migrations 11 sync + 1 async, includes migrateLegacyOpusToCurrent (ant-only DCE)

Part 8 β€” Types, Schemas & API

docs/08-types-schemas-api.md Β· 2,194 lines

Type System Layers
═══════════════════════════════════════════
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Branded IDs                              β”‚
β”‚ SessionId, AgentId, TaskId, ToolUseId   β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Core Types                               β”‚
β”‚ Tool<I,O,P>, ToolResult<T>,             β”‚
β”‚ ValidationResult, ToolUseContext (30+)   β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Zod Schemas                              β”‚
β”‚ HookCommand (discriminated union),       β”‚
β”‚ SettingsSchema (~100 fields),            β”‚
β”‚ TransportSchema (6 literals)             β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ AppState                                 β”‚
β”‚ DeepImmutable<> wrapper,                 β”‚
β”‚ ~85 fields + Store<T> pattern            β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Environment Variables (60+)              β”‚
β”‚ Feature Flags (89)                       β”‚
β”‚ Analytics Events (44 Datadog)            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
Topic Key Details
SettingsJson ~100 fields across 15 categories (auth, permissions, MCP, hooks, model, UI...)
Settings Merge policySettings internal priority: remote > HKLM/plist > file > HKCU
Env Vars 60+ variables across 7 groups (API, model, auth, debug, feature, proxy, internal)
Feature Flags 89 bun:bundle feature() calls, compile-time dead code elimination

Infrastructure & Deployment

infrastructure/ β€” Complete deployment blueprints with Terraform IaC

Deployment Options
═══════════════════════════════════════════
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Local Dev  β”‚  β”‚     AWS      β”‚  β”‚    Azure     β”‚  β”‚  Supabase    β”‚
β”‚              β”‚  β”‚              β”‚  β”‚              β”‚  β”‚              β”‚
β”‚ Ollama/vLLM  β”‚  β”‚ ECS Fargate  β”‚  β”‚ Container   β”‚  β”‚ Edge Funcs   β”‚
β”‚ Docker Stack β”‚  β”‚ Bedrock      β”‚  β”‚ Apps         β”‚  β”‚ Realtime     β”‚
β”‚ RTX 4090     β”‚  β”‚ Lambda       β”‚  β”‚ Azure OpenAI β”‚  β”‚ PostgreSQL   β”‚
β”‚              β”‚  β”‚ Cognito      β”‚  β”‚ AD B2C       β”‚  β”‚ Auth         β”‚
β”‚ $0-50/mo     β”‚  β”‚ $45-180/mo   β”‚  β”‚ $50-190/mo   β”‚  β”‚ $0-25/mo     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
Document Description
01-local-development.md Ollama, vLLM, LM Studio, Docker Compose full stack
02-aws-architecture.md VPC, ECS, Bedrock, Lambda sandbox, CloudWatch
03-azure-architecture.md Container Apps, Azure OpenAI, Functions, Monitor
04-supabase-backend.md 10-table schema, RLS policies, Edge Functions
05-cost-analysis.md Real pricing: $9/mo solo β†’ $25/dev enterprise
06-architecture-diagram.md 7 ASCII diagrams: system, data flow, auth, agents
terraform/ 10 .tf files β€” production-ready AWS IaC

Cost Quick Reference

Scale Supabase + API AWS Full Hybrid (Local GPU)
Solo (1 dev) $9–103/mo $240–280/mo $50/mo
Team (10 devs) $46–116/dev $65–110/dev $35–60/dev
Enterprise (100 devs) N/A $45–111/dev $25/dev

LLM token costs represent 60–95% of total spend at every scale.


Verification Status

These documents went through 8 rigorous verification passes against the actual source code:

Pass 1 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ 16 corrections  (type/value accuracy)
Pass 2 β–ˆβ–ˆβ–ˆβ–ˆ             4 fixes         (blocking implementation gaps)
Pass 3 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ          7 corrections   (line-by-line precision)
Pass 4 β–ˆβ–ˆβ–ˆ              3 fixes         (missing schemas/flows)
Pass 5 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ          7 additions     (Bridge, MDM, Keychain, Plugin)
Pass 6 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ   42 caveats      (structural problem warnings)
Pass 7 β–ˆβ–ˆ               2 micro-fixes   (convergence check)
Pass 8 ─────────────── CONVERGED        (24/24 spot-checks verified)
       ═══════════════
Total: 39 corrections + 42 implementation caveats

Quick Start

# Clone the repo
git clone https://github.com/jung-wan-kim/claude-code-reverse-engineering.git
cd claude-code-reverse-engineering

# Read the design docs (start here)
open docs/01-architecture-overview.md

# Deploy infrastructure (AWS)
cd infrastructure/terraform
cp terraform.tfvars.example terraform.tfvars
# Edit terraform.tfvars with your settings
terraform init && terraform plan

Repository Structure

claude-code-reverse-engineering/
β”œβ”€β”€ README.md                          ← You are here
β”œβ”€β”€ docs/
β”‚   β”œβ”€β”€ 01-architecture-overview.md    (1,101 lines)
β”‚   β”œβ”€β”€ 02-core-engine.md             (1,352 lines)
β”‚   β”œβ”€β”€ 03-permission-security.md     (1,178 lines)
β”‚   β”œβ”€β”€ 04-multi-agent-memory.md      (1,416 lines)
β”‚   β”œβ”€β”€ 05-extension-systems.md       (1,709 lines)
β”‚   β”œβ”€β”€ 06-ui-layer.md               (1,784 lines)
β”‚   β”œβ”€β”€ 07-services-infrastructure.md (1,845 lines)
β”‚   └── 08-types-schemas-api.md       (2,194 lines)
└── infrastructure/
    β”œβ”€β”€ 01-local-development.md
    β”œβ”€β”€ 02-aws-architecture.md
    β”œβ”€β”€ 03-azure-architecture.md
    β”œβ”€β”€ 04-supabase-backend.md
    β”œβ”€β”€ 05-cost-analysis.md
    β”œβ”€β”€ 06-architecture-diagram.md
    └── terraform/
        β”œβ”€β”€ main.tf
        β”œβ”€β”€ variables.tf
        β”œβ”€β”€ vpc.tf
        β”œβ”€β”€ compute.tf
        β”œβ”€β”€ database.tf
        β”œβ”€β”€ storage.tf
        β”œβ”€β”€ auth.tf
        β”œβ”€β”€ monitoring.tf
        β”œβ”€β”€ outputs.tf
        └── terraform.tfvars.example

Disclaimer

This is a reverse-engineering effort for educational and security research purposes only. All rights to the original Claude Code software belong to Anthropic.

License

MIT (documentation only β€” does not cover the original Claude Code software)

About

Reverse-engineered design documents for Anthropic Claude Code CLI - implementation-ready specifications

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors