Claude Code From Scratch

Reimplement Claude Code's core in ~5,000 lines of code with a 13-chapter step-by-step tutorial to understand Coding Agents.

Stars
★ 2.9k
Last updated
3d ago v1.0.0
FARS reviewed
Nov 08, 2026
License
MIT
Primary language
HTML

At a glance

How it runs
CLI
Works with
Universal · cross-platformOpenAI API · Claude API
Cost
Free software; you pay for model usage
Setup effort
Low · running in minutes
You'll need
Node.jsPython 3.11+Shell / CLINetwork accessLocal filesystemMCP Server
Typical use
Developers who want to deeply understand Claude Code's inner workings but find the 500k-line codebase overwhelming, using a step-by-step tutorial to reimplement the core.
Not a fit if
  • Teams needing production-grade robustness; this is a teaching minimal implementation
Website
windy3f3f3f3f.github.io ↗ set on GitHub
Maintenance
Commits in the last 30 dayslast commit 2026-11-29latest release v1.0.0 (2026-03-31)+0.7 ★/day over 7 days
Source review
62/100 · Some gaps

What does this agent do, and when should you use it?

This is an educational project that reimplements the core architecture of Claude Code from scratch in about 5,000 lines of TypeScript or Python, rather than a full replacement. It includes a 13-chapter tutorial covering the Agent Loop, 13 tools (including parallel execution and streaming early start), 4-layer context compaction, semantic memory recall, skill system, multi-agent collaboration, and MCP integration. Each chapter's code is runnable without an API key, powered by a local mock model, with '--diff' to see newly added code. The project offers two functionally equivalent versions in TypeScript and Python, supports Anthropic and OpenAI-compatible API backends, and includes detailed architecture comparisons with Claude Code.

The project provides a complete implementation and tutorial for building a Coding Agent from scratch. The core is an Agent Loop: repeatedly calling the LLM, executing tools, and processing results until the task is complete. It implements 13 tools (e.g., file read/write, Shell, WebFetch, ToolSearch), supporting parallel execution of read-only tools and streaming output. It includes 4-layer context compaction, 5 permission modes, 4 memory types with semantic recall and async prefetch, a skill system (inline/fork modes), Sub-Agent multi-agent architecture, and an MCP client. It provides an interactive REPL CLI, session persistence, budget control (--max-cost, --max-turns), cross-platform shell auto-detection, and error retries. Each chapter includes a runnable minimal implementation, demonstrated via node steps/run.mjs <N> without needing real APIs.

  1. Developers who want to deeply understand Claude Code's inner workings but find the 500k-line codebase overwhelming, using a step-by-step tutorial to reimplement the core.
  2. Learners who want hands-on experience with Coding Agents, using runnable minimal code to quickly validate concepts without API keys.
  3. Technical instructors or bloggers needing a structured, reproducible teaching resource for topics like Agent Loop, tool systems, and context management.
  4. Developers who want to integrate a lightweight Coding Agent core into their own projects, using this as a reference or base.
  5. Researchers interested in advanced features like multi-agent collaboration and MCP integration, referencing the implementation patterns.

Key setup facts

Pulled from the install and usage notes below. The project README has the current values.

Install / run
  • npm install && npm run build
Environment variables
ANTHROPIC_API_KEY OPENAI_API_KEY OPENAI_BASE_URL
Runtime
Python 3.11+

How do you install or deploy this agent?

Clone the repository: git clone https://github.com/Windy3f3f3f3f/claude-code-from-scratch.git, then cd claude-code-from-scratch and run npm install && npm run build. For Python version (requires Python 3.11+), cd python && pip install -e .. Configure API by setting environment variables: ANTHROPIC_API_KEY (Anthropic format) or OPENAI_API_KEY and OPENAI_BASE_URL (OpenAI-compatible format).

How do you use this agent?

Run the TypeScript version: npm start for interactive REPL mode, with flags like --resume to resume last session, --yolo to skip safety confirmations, --plan for plan mode, --max-cost for spending limits. Python version uses mini-claude-py command. In-session commands include /clear, /cost, /compact, /memory, /skills. To run tutorial chapters: node steps/run.mjs <N> where N is chapter number; use --diff to see code changes, --py for Python version, --live to connect to real models.

Safety boundaries, hardening & integrations

Operational blast radius, source-verified safety controls, and first-run hardening steps before connecting this agent to real workspaces.

Declared capability surface (blast radius)

Local shell command execution

Can run terminal commands; pair with approval gates or container/OS sandboxing.

Local filesystem read/write

Modifies local files; work on a clean Git branch or dedicated worktree.

Outbound network access

Makes outbound requests; verify telemetry settings and model data routing on private repos.

External MCP tool bridge

Inherits capabilities of connected MCP servers; audit third-party servers before enabling.

What are this agent's strengths and limitations?

Pros
  • Every chapter's code runs without an API key, using a local mock model, making it easy to learn and debug.
  • Provides both TypeScript and Python versions to suit different language preferences.
  • Detailed architecture comparison tables clearly show differences from Claude Code.
Limitations
  • Educational nature; feature completeness and robustness are not production-grade compared to Claude Code.
  • Default model claude-opus-4-6 may require a valid API key, and there is no built-in model fallback strategy.
  • Advanced features like context compaction are simplified implementations that may differ from the original behavior.

How does this agent compare with similar options?

Compared to Claude Code, this project is positioned as a learning minimal implementation: only 13 tools (vs. 66+ in Claude Code), ~5000 lines of code (vs. 500k+), simplified permission system (5 modes vs. 7-layer + AST), and multi-agent only supports Sub-Agent (vs. Coordinator + Swarm).

Key facts side by side with the most closely related agents.

Agent Source review Form / cost Stars Updated Language Full support on
Claude Code From Scratch This agent 62 · Some gaps CLIFree + model costs ★ 2.9k 3d ago HTML OpenAI API · Claude API
PI from Scratch 56 · Major gaps CLIFree + model costs ★ 1.3k 1mo ago TypeScript OpenAI API
Learn Claude Code: Harness Engineering for Real Agents 57 · Major gaps CLIFree + model costs ★ 81k 18d ago Python Claude API
Donggua's AI Learning Notes: In-depth Pi-Agent SDK Tutorial 49 · Major gaps Web appFree ★ 3.8k 3mo ago MDX —

How does FollowAgents rate this agent?

FollowAgents source review · FARS-2.1
Some gaps
62/ 100 5-point scale 3.1 / 5
Trust 13/29
Reliability 8/14
Adaptability 12/18
Convention 12/18
Effectiveness 12/13
Verifiability 5/8
Why each dimension lost points
Trust13 / 29 · 2.2/5

The code and documentation describe permission modes, confirmation flows, deny-first rules, and a session whitelist; they also state that MCP connects external tools over stdio, giving some support for data-flow transparency and ordinary confirmation. Deductions: --yolo can bypass confirmations, dangerous-command protection relies on regexes that the documentation says can miss cases, and the packet gives limited evidence of credential protection, fine-grained tool permissions, or rollback. The project describes itself as an independent learning implementation inspired by publicly observable behavior and disclaims Anthropic affiliation, supporting limited attribution but not independent verification of Claude Code internals.

Reliability8 / 14 · 2.9/5

The README, package scripts, Python entry point, and test files jointly show two language implementations, retries, budget limits, and an organized test suite; their main architectural descriptions broadly align. Deductions: some README capability claims cannot be checked against this source sample, and some features are described only in summaries. Evidence about user-facing error messages and recovery guidance is limited. No execution result is inferred from this static review.

Adaptability12 / 18 · 3.3/5

The tutorial clearly targets readers learning coding-agent principles and progresses from the core loop to permissions, memory, skills, and MCP. Deductions: although it distinguishes a learning implementation from a production product, some capability boundaries are summarized rather than fully demonstrated; the sampled skill descriptions give limited evidence about avoiding unintended triggers; TypeScript, Python, and multiple API configurations are offered, but environment and deployment guidance is limited.

Convention12 / 18 · 3.3/5

Navigation, chapter structure, quick starts, command examples, project layout, and the permissions chapter are clear. The MIT license text is complete, and the regex protection limitations are stated. Deductions: the sample contains no version history, and maintenance responsibility and update path are unclear; package and README metadata provide some naming and version information but no full stability policy.

Effectiveness12 / 13 · 4.6/5

Chapter commands, diff viewing, two language entry points, and a local mock teaching path make the material usable for step-by-step learning and reuse; the comparison and architecture explanations add learning value. Deductions: live model use requires API configuration and can incur costs, although budget flags are offered; real-agent permission and safety behavior still depends on configuration and the specific tool call.

Verifiability5 / 8 · 3.1/5

The README's chapter claims partly correspond to the supplied permissions documentation, entry-point code, package scripts, and tests; the permissions chapter also distinguishes its simplified demo from the fuller repository implementation. Deductions: this is only a sample of files, so many README claims cannot be checked individually here, and claims and code do not provide independent corroboration for every feature. The project distinguishes publicly observable behavior from actual internal implementation, reducing the risk of presenting inference as fact, but tutorial descriptions are largely supported by the project itself.

Risks and how to mitigate them
  • This is a learning-oriented agent implementation. Live model use requires API credentials, and --yolo skips confirmations. The documentation explicitly says the dangerous-command regexes can miss cases.
  • This assessment uses only the supplied static source sample; code was not executed, and files outside the sample are unknown.
Evidence confidence: Low Reviewed Nov 08, 2026 Reviewed revision 0b4523608664 New commits since this review; the score may not cover them
See the full review method →
Maintain this project? Add the FARS badge to your README

The badge shows the current review score and verdict and links back to this page. It refreshes about once an hour after a re-review.

FARS

[![FARS review](https://followagents.com/badge/claude-code-from-scratch.svg)](https://followagents.com/en/agents/claude-code-from-scratch)
<a href="https://followagents.com/en/agents/claude-code-from-scratch"><img src="https://followagents.com/badge/claude-code-from-scratch.svg" alt="FARS review"></a>

Recent releases

Latest entries from the project's GitHub Releases. Notes are quoted from upstream as written, not rewritten or tested by FollowAgents.

  1. v1.0.0
    Release notes excerpt
    Initial release
    View on GitHub ↗

FAQ

Do I need an API key to run the tutorial chapters?
No, they run with a local mock model by default; use --live flag to connect to real APIs.
Which model backends are supported?
Anthropic format via ANTHROPIC_API_KEY and OpenAI-compatible format via OPENAI_API_KEY/OPENAI_BASE_URL.
Is this project affiliated with Anthropic?
No, the project states that Claude Code is a trademark of Anthropic and this is an independent learning reimplementation.
How to customize the model?
Set the environment variable MINI_CLAUDE_MODEL or pass --model as a command-line argument (CLI takes precedence).
Is there a Python version?
Yes, functionally equivalent to TypeScript, requires Python 3.11+, and runs via mini-claude-py command.
Was this page helpful?
View on GitHub ↗ Install ↓

Host ecosystems

Compare agents like this one

The same FARS review applied across the shortlist this agent qualifies for.

Related concepts