{"slug": "claude-code-from-source", "title": "Claude Code from Source", "summary": "A new 18-chapter book, \"Claude Code from Source,\" reverse-engineers Anthropic's Claude Code AI coding agent from the TypeScript source maps that shipped with the tool on npm, which included a sourcesContent field containing nearly two thousand original files. The book's authors say 36 AI agents analyzed and wrote the entire book in four phases in approximately 6 hours, covering the agent loop, a 14-step tool execution pipeline, multi-agent orchestration that shares prompt cache prefixes to cut costs by 95%, file-based memory, and 240ms startup via parallel I/O. The book is presented as purely educational, with all code blocks rewritten as pseudocode and a final audit pass to remove verbatim source code.", "body_md": "# \nHow Anthropic built the most widely used\n\n AI coding agent\n\n When Claude Code shipped on npm, the source maps came with it. We read every file. This book distills the architecture, design decisions, and transferable patterns into 18 chapters you can learn from and apply to your own systems.\n\n[Start reading](https://claude-code-from-source.com/ch01-architecture/)\n\n## What you'll learn\n\n### The agent loop\n\nHow an async generator drives the entire system — streaming model output, executing tools, recovering from errors, and compressing context across 4 layers.\n\n### Tool execution at scale\n\nA 14-step pipeline from model request to tool result. Permission resolution, speculative execution, concurrent batching by safety classification.\n\n### Multi-agent orchestration\n\nHow sub-agents share prompt cache prefixes to cut costs by 95%. Fork agents, coordinator mode, swarm teams with mailbox messaging.\n\n### Memory without a database\n\nFile-based memory with an LLM-powered recall system. Four memory types, staleness warnings, and a Sonnet side-query that beats embedding search.\n\n### Performance engineering\n\nStartup in 240ms via parallel I/O. Slot reservation saving context in 99% of requests. Bitmap pre-filters for fuzzy search. Every millisecond accounted for.\n\n### Extensibility and security\n\nTwo-phase skill loading (metadata at startup, content on demand). 27 lifecycle hooks with config snapshots frozen at startup to prevent injection.\n\n## Explore the architecture\n\nSix core abstractions power Claude Code. Drag nodes to rearrange, hover for details, click to read the chapter.\n\n## Who this is for\n\n**Engineers building agentic systems.** Every chapter ends with \"Apply This\" — 5 transferable patterns with concrete adaptation advice. Steal the architecture, skip the mistakes.\n\n**Technical leaders evaluating architectures.** Follow the narrative without reading every code block. Understand why decisions were made, not just what was built.\n\n**Anyone curious about how production AI tools work.** Claude Code is used by hundreds of thousands of developers. This is how it works under the hood.\n\n## Table of contents\n\n### Foundations\n\nBefore the agent can think, the process must exist.\n\n[1  The Architecture of an AI Agent](https://claude-code-from-source.com/ch01-architecture/)   \n\nThe 6 key abstractions, data flow, permission system, build system\n\n[2  Starting Fast — The Bootstrap Pipeline](https://claude-code-from-source.com/ch02-bootstrap/)   \n\n5-phase init, module-level I/O parallelism, trust boundary\n\n[3  State — The Two-Tier Architecture](https://claude-code-from-source.com/ch03-state/)   \n\nBootstrap singleton, AppState store, sticky latches, cost tracking\n\n[4  Talking to Claude — The API Layer](https://claude-code-from-source.com/ch04-api-layer/)   \n\nMulti-provider client, prompt cache, streaming, error recovery\n\n### The Core Loop\n\nThe heartbeat of the agent: stream, act, observe, repeat.\n\n### Multi-Agent Orchestration\n\nOne agent is powerful. Many agents working together are transformative.\n\n### Persistence and Intelligence\n\nAn agent without memory makes the same mistakes forever.\n\n### The Interface\n\nEverything the user sees passes through this layer.\n\n### Connectivity\n\nThe agent reaches beyond localhost.\n\n### Performance Engineering\n\nMaking it all fast enough that humans don't notice the machinery.\n\n## How this book was made\n\nThe source was extracted from npm source maps — the `.js.map` files that shipped with Claude Code contained a `sourcesContent` field with the full original TypeScript. Nearly two thousand files comprising the complete architecture.\n\n **36 AI agents** analyzed and wrote the entire book in four phases:\n\nThe entire process — from source extraction to final revised book — took approximately **6 hours**. A final audit pass ensured no verbatim source code remained — every code block was rewritten as pseudocode with different variable names.\n\n## The 10 patterns that make it work\n\nIf you read nothing else, these are the architectural bets that define Claude Code.\n\n **Purely educational.** This book contains no source code from Claude Code — every code block is original pseudocode written to illustrate architectural patterns. The goal is to help engineers understand how production AI agents are built, not to reproduce proprietary software. The \"NO'REILLY\" cover is a parody/meme for illustrative purposes only — no affiliation with O'Reilly Media.", "url": "https://wpnews.pro/news/claude-code-from-source", "canonical_source": "https://claude-code-from-source.com/", "published_at": "2026-09-18 01:14:04+00:00", "updated_at": "2026-09-18 01:25:13.855509+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "developer-tools", "ai-products"], "entities": ["Anthropic", "Claude Code", "npm", "TypeScript", "Sonnet"], "alternates": {"html": "https://wpnews.pro/news/claude-code-from-source", "markdown": "https://wpnews.pro/news/claude-code-from-source.md", "text": "https://wpnews.pro/news/claude-code-from-source.txt", "jsonld": "https://wpnews.pro/news/claude-code-from-source.jsonld"}}