Claude Code From Scratch
A step-by-step tutorial that rebuilds Claude Code's core architecture in about five thousand lines of TypeScript or Python, comparing each piece to the real implementation.
Claude Code From Scratch is a thirteen-chapter, hands-on tutorial that rewrites the core of a coding agent like Claude Code from zero, in roughly five thousand lines of code, in parallel TypeScript and Python versions. It follows Claude Code's publicly observable behavior and common agent-building patterns rather than its real closed-source internals, and is explicitly a learning project with no affiliation to Anthropic.
Chapters build up the agent loop, a set of thirteen tools with parallel and streaming execution, system-prompt engineering, the CLI and session handling, streaming output, permissions and safety checks, four layers of context compression, a four-type memory system with semantic recall, a skill system, plan mode, multi-agent sub-agent delegation, and MCP integration, each mapped explicitly against the corresponding piece of Claude Code's real architecture. Every code chapter runs standalone with one command against a local mock model, needing no API key, so a reader can see the exact output described.
It is released under the MIT license.