Claude Code Orange Book
Summary
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.
Key Takeaways
- Agent loop, compaction, hooks, and sub-agents each get chapter-level treatment
- Frames every mechanism as an engineering decision with trade-offs
- Best source for architecture diagrams' underlying concepts
Reliability Note
Independent reverse-engineering effort - unofficial, verify against official Anthropic docs and behavior. Original text in Chinese; concepts summarized here in English.
Flows informed by this source
5Design 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.
+2 more steps to Done
Best forproduction-grade builds with strict verification
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.
+1 more steps to Done
Best forproduction-grade builds with strict verification
Implement Context Compaction
Keep long agent sessions alive by compacting old conversation into structured summaries before the context window fills.
+1 more steps to Done
Best forproduction-grade builds with strict verification
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.
+1 more steps to Done
Best forbuilders who have shipped a basic app before
Deferred Tool Loading
Stop paying context for tools the task never needs: load a core set eagerly and expand the toolset on demand.
+1 more steps to Done
Best forproduction-grade builds with strict verification