Dissecting Anthropic's AI Engineering Decisions from 510,000 Lines of Leaked Code
Orange Book Series | April 2026 | By Huashu
On March 31, 2026, Anthropic accidentally shipped the complete Claude Code source code inside an npm package. 1,902 TypeScript files, 510,000 lines of code, every design decision laid bare.
This book is not a source code reading journal. It dissects the design decisions behind Claude Code -- one of the world's most sophisticated AI coding tools. Why does search use grep instead of a vector database? Why does the memory system only store preferences, not code? Why does Auto mode run a second AI for safety reviews? Why Bun over Node.js?
Every choice has a reason. Those reasons are more valuable than the code itself, because they are transferable.
| Version | File | Pages |
|---|---|---|
| English | Claude-Code-Source-Code-Analysis-v260411.pdf | ~80 |
| Chinese | Claude-Code-Source-Analysis-zh-v260411.pdf | ~80 |
💡 Download the PDF for the best reading experience. GitHub's online preview may not render properly.
- Ch 01 A Billion-Dollar Blueprint
- Ch 02 Architecture Overview: The Skeleton of the Harness
- Ch 03 System Prompt Engineering
- Ch 04 The Tool System: 4 Primitives, 59 Tools
- Ch 05 The Permission System: Trust by Design
- Ch 06 The Memory System: Remember Preferences, Forget Code
- Ch 07 Context Management: Surviving Long Conversations
- Ch 08 Search: Why grep Beats RAG
- Ch 09 Multi-Agent Architecture: Run Like a Company
- Ch 10 The Future in Feature Flags
- Ch 11 Two Claude Codes: Internal vs External
- Ch 12 The Harness Engineering Playbook
- 60/40 Rule: Claude Code is 60% model capability, 40% harness engineering
- grep > RAG: 510,000 lines of code, zero vector databases -- because the LLM is smart enough
- Remember preferences, forget code: Memory stores what changes slowly; search retrieves what changes fast
- Four-layer permission pipeline: Rule matching -> low-risk skip -> allowlist -> ML classifier
- Nine-section structured compression: Not "summarize this" but a strict template for what must be preserved
- Simple components + smart brain: File-based communication, plain-text memory, grep search -- each component is simple, but together they outperform complex alternatives
Huashu -- AI Native Coder, indie developer, AI content creator with 300K+ followers.
Notable works: Kitten Ring Light (App Store Paid #1), Master DeepSeek in One Book (bestseller)
- X/Twitter: @AlchainHust
- YouTube: @Alchain
- Bilibili: Huashu
- WeChat Official Account: Huashu
- Website: huasheng.ai
This book is part of the AI Programming Orange Book Series:
- Claude Code: From Beginner to Pro -- How to use the tool
- Claude Code: Source Code Analysis -- How it's built (this book)
- Harness Engineering -- The methodology
- Agent Skills -- Extending AI capabilities
- OpenClaw -- Building your own AI
- Polymarket Guide -- Prediction markets with AI
This work is provided for educational and research purposes. The source code analysis is based on publicly available leaked code. All trademarks belong to their respective owners.
This book is based on analysis of TypeScript source code publicly exposed during the Claude Code v2.1.88 leak in March 2026. The analysis covers client-side tool code only and does not involve model weights, training data, or user information.
