A comprehensive synthesis of the claude-code-from-source project (and companion site claude-code-from-source.com ) β distilled into core principles, techniques, and actionable guidelines for builders who want to ship a coding agent of comparable quality.
The source repo is a 18-chapter educational reverse-engineering of Claude Code derived from npm source maps. No proprietary code is reproduced β only architectural pseudocode and design rationale. This guide does the same.
Table of Contents
π‘ TL;DR β the whole agent in one mental picture
π― What you are actually building
π§± The six core abstractions
π¦ State: two tiers, one source of truth
βοΈ The agent loop: AsyncGenerator as control plane
π§ Tools: self-describing, fail-closed, parameterized
β‘ Concurrency and speculative execution
π Permissions: modes, rules, and bubbling
ποΈ Context engineering: the 4-layer compression pipeline
π The API layer: prompt caching as architecture
π€ Sub-agents and fork agents
πΈοΈ Multi-agent coordinationβ¦