← all repositories
Windy3f3f3f3f/claude-code-from-scratch

Claude Code's 500k lines, distilled to 4k for mortals

A tutorial that reverse-engineers Claude Code's core architecture in ~4,300 lines so you don't have to read half a million.

2.4k stars Python Coding AssistantsLearning
claude-code-from-scratch
Velocity · 7d
+23
★ / day
Trend
accelerating
star history

What it does This is a from-scratch rebuild of Anthropic’s Claude Code in roughly 4,300 lines of TypeScript or ~3,800 lines of Python. A 13-chapter tutorial walks through the agent loop, tool system, 4-layer context compression, semantic memory, skills, multi-agent coordination, and MCP integration—each chapter mapping the simplified code directly to the original 500,000-line source. The result is a working terminal coding agent with REPL commands, session persistence, and budget controls.

The interesting bit The project treats Claude Code’s massive codebase as a textbook rather than a dependency. Every chapter shows “how they did it → how we simplified it,” turning an overwhelming reverse-engineering task into a guided architecture tour. It is essentially a compressed, annotated rewrite for developers who want to understand why coding agents work, not merely that they work.

Key highlights

  • Dual TypeScript and Python implementations with the same architecture
  • 13 tools including parallel read-only execution, streaming early-start, and mtime-protected file edits
  • 4-layer context compression (budget truncation → stale snip → microcompact → auto-compact) plus offloading large results to disk
  • Semantic memory with async prefetch, sub-agent fork-return patterns, and MCP integration via JSON-RPC over stdio
  • A detailed comparison table showing exactly what was simplified, from 5 permission modes versus the original’s 7-layer AST analysis to a 2D budget limit instead of the original’s three-dimensional control

Caveats

  • Explicitly a teaching tool, not a production replacement: 13 tools versus Claude Code’s 66+, simpler permission rules, and budget control limited to cost and turn count rather than the original’s three-dimensional limits
  • The Python and TypeScript versions are separate parallel implementations with their own entry points, not a shared core with language bindings
  • Edit validation is simplified to quote tolerance, uniqueness checks, and diff output instead of Claude Code’s 14-step pipeline

Verdict Grab this if you are an engineer who wants to understand coding agent internals without drowning in a half-million-line codebase. Skip it if you are looking for a drop-in, battle-tested alternative to the real Claude Code.

Frequently asked

What is Windy3f3f3f3f/claude-code-from-scratch?
A tutorial that reverse-engineers Claude Code's core architecture in ~4,300 lines so you don't have to read half a million.
Is claude-code-from-scratch open source?
Yes — Windy3f3f3f3f/claude-code-from-scratch is open source, released under the MIT license.
What language is claude-code-from-scratch written in?
Windy3f3f3f3f/claude-code-from-scratch is primarily written in Python.
How popular is claude-code-from-scratch?
Windy3f3f3f3f/claude-code-from-scratch has 2.4k stars on GitHub and is currently accelerating.
Where can I find claude-code-from-scratch?
Windy3f3f3f3f/claude-code-from-scratch is on GitHub at https://github.com/Windy3f3f3f3f/claude-code-from-scratch.

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