Back to directory

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.

Visit website (opens in a new tab)windy3f3f3f3f.github.io
Claude Code From Scratch

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.

More in Coding agents

See all 793
  • The City

    github.com

    A native macOS app that shows Claude Code runs as a city, with each project as a building, each team as a floor of robots, and every animation driven by a real event from the claude CLI's stream.

  • rig

    tryrig.ai

    A small, single-binary agent runtime that points at any OpenAI-compatible model, local or hosted, reads and edits a repository's code, runs its tests and remembers what it learned, with a loop implemented in a few hundred lines.

  • Jauvex

    jauvex.reindent.com

    An Electron desktop app that puts Claude Code, Codex and Grok coding-agent sessions side by side and lets you steer them by voice, with a small model handling fast routing decisions.