6-Chapter Guide
Inside Claude Code
A chapter-by-chapter guide to how Claude Code actually works, reverse-engineered from the v2.1.88 source code (512,000+ lines of TypeScript, 1,902 files). Not speculation — real code, real prompts, real architecture decisions.
Source exposed via npm source maps on March 31, 2026 · ~1 hour total reading
512K+
Lines of TS
1,902
Source Files
40+
Built-in Tools
v2.1.88
Analyzed
The Agentic Loop
12 minHow a message goes from your keyboard to a response. The while(true) loop, streaming, tool execution, and concurrency.
The 5 Hidden Background Systems
15 minForked agents, memory extraction, session memory, auto-dream consolidation, and speculative execution. The invisible layer that makes Claude Code feel intelligent.
System Prompt Anatomy
10 minThe 15KB prompt dissected layer by layer. The cache boundary trick, CLAUDE.md injection, conditional rules, and how the prompt is assembled on every API call.
Voice Mode Deep Dive
8 minNot Whisper. Not Google. Deepgram STT behind an Anthropic WebSocket proxy. Pre-connection audio buffering, hold-to-talk detection, and the silent-drop recovery hack.
Cost Optimization Secrets
7 minExact pricing from modelCost.ts. The prompt cache architecture, forked agent economics, microcompaction, and why background agents cost $0.001 per run.
Unreleased Features & What's Coming
5 minKAIROS always-on mode, Buddy companion, Ultraplan, Proactive daemon, Torch, and 5 more features found via compile-time feature flags.
About this guide
This guide is based on analysis of the Claude Code source code that became publicly accessible through source maps in the npm distribution on March 31, 2026. All code excerpts and architecture details are from that snapshot (version 2.1.88). The original code is the property of Anthropic. This guide is educational — it explains how the system works so developers can learn from the architecture decisions.