HeadlinesBriefing favicon HeadlinesBriefing.com

Claude Code Architecture: Patterns & Internals

Hacker News •
×

When Claude Code shipped on npm, the source maps came with it. This book distills the architecture, design decisions, and transferable patterns into 18 chapters for engineers building agentic systems.

The agent loop uses an async generator driving the entire system — streaming model output, executing tools, recovering from errors, and compressing context across 4 layers. Tool execution follows a 14-step pipeline from model request to tool result, with permission resolution, speculative execution, and concurrent batching by safety classification.

Multi-agent orchestration enables sub-agents to share prompt cache prefixes, cutting costs by 95%. Memory operates without a database using file-based memory with an LLM-powered recall system. Startup completes in 240ms via parallel I/O, with slot reservation saving context in 99% of requests.

The source was extracted from npm source maps containing full original TypeScript — nearly two thousand files. 36 AI agents analyzed and wrote the entire book in four phases, completing the process from source extraction to final revised book in approximately 6 hours. A final audit ensured no verbatim source code remained — every code block was rewritten as pseudocode.