← all repositories
alejandrobalderas/claude-code-from-source

Reverse-engineering Claude Code from its own source maps

An educational book that distills how Anthropic's AI coding agent actually works — without containing a single line of its proprietary code.

2.2k stars TypeScript LearningCoding AssistantsAgents
claude-code-from-source
Velocity · 7d
+33
★ / day
Trend
steady
star history

What it does This repository is a ~400-page technical book, organized into 18 chapters across 7 parts, that explains the architecture of Anthropic’s Claude Code. The author extracted the original TypeScript from npm source maps (sourcesContent), then had 36 AI agents analyze nearly 2,000 files and rewrite the findings as original pseudocode and narrative. The result is a layered read: skimmable for technical leaders, deep-divable for implementers, with an “Apply This” section at the end of each chapter for stealing patterns.

The interesting bit The book was produced in about 6 hours by a swarm of specialized agents — explorers, analysts, writers, reviewers, and revisers — which feels like a dog-food demo of the very orchestration patterns it describes. The “NO’REILLY” crab cover is a parody; the disclaimer that “the crab is just a crab” is not.

Key highlights

  • 10 concrete patterns extracted, from “AsyncGenerator as agent loop” to “slot reservation” output caps that escalate from 8K to 64K tokens on demand
  • Fork-agent cache sharing — parallel sub-agents reuse byte-identical prompt prefixes to save ~95% of input tokens
  • 4-layer context compression (snip → microcompact → collapse → autocompact) for managing long conversations
  • Two-tier state architecture with bootstrap singletons, sticky latches, and cost tracking
  • Mermaid diagrams throughout, rendering natively on GitHub
  • No proprietary code included — all examples are original pseudocode with renamed variables

Caveats

  • The source material came from source maps accidentally shipped in npm packages; the legality of this extraction is not discussed in the README
  • All code is pseudocode, so you cannot run or directly copy anything — it is architectural description, not implementation
  • The 6-hour production time refers to the AI-assisted writing pipeline, not reading time

Verdict Read this if you are building agentic systems and want to crib from a production-grade reference architecture. Skip it if you need copy-pasteable code or are looking for an official Anthropic document — this is independent analysis, not endorsed by them.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.