Claude Code Orange Book
A book-length analysis ('Orange Book') dissecting Anthropic's AI engineering decisions from the 510,000 lines / 1,902 TypeScript files that shipped inside an npm package. Chapters cover the agent loop, context compaction, the hook system, and sub-agents - the concepts, not just the code.
View source on GitHubKey takeaways
- 01
Agent loop, compaction, hooks, and sub-agents each get chapter-level treatment
- 02
Frames every mechanism as an engineering decision with trade-offs
- 03
Best source for architecture diagrams' underlying concepts
Flows built on this research
Agent Architecture
Design a Single-Loop Agent
Build the core agent loop the leading coding agents use: one model, one loop, tools in, results folded back into context.
5 steps · 90-150 minutes
Agent Architecture
Sub-Agent Delegation with Context Isolation
Delegate bounded work to sub-agents that run in fresh context and return only distilled results - the pattern behind scalable long tasks.
4 steps · 90-150 minutes
Memory & Context
Implement Context Compaction
Keep long agent sessions alive by compacting old conversation into structured summaries before the context window fills.
4 steps · 90-120 minutes
Agent Architecture
Assemble a System Prompt Like the Pros
Structure your agent's system prompt the way leading harnesses do: layered sections, dynamic context, and enforceable rules.
4 steps · 60-90 minutes
MCP & Tooling
Deferred Tool Loading
Stop paying context for tools the task never needs: load a core set eagerly and expand the toolset on demand.
4 steps · 90-120 minutes