Mini Claude
Code.

A coding agent built from scratch in ~500 lines of TypeScript. Six episodes, one working repository. No framework, no hidden layers — every file readable in one sitting.

MIT · runs on Node 20+ · Anthropic SDK only

By the numbers

~500
Lines of code
4
Source files
1
Runtime deps
6
Episodes

The six episodes

Each episode reads like a chapter. Each chapter maps to a file you can open right now.

  1. EP 01
    Mini Claude Code · Episode 01: A 40-Line REPL That Actually Remembers
    Start of a hands-on series where we build a working coding agent from scratch in TypeScript. Episode 1 gets the smallest possible loop running — stdin, streaming, and a conversation that survives turns.
    14 min
    →
  2. EP 02
    Mini Claude Code · Episode 02: Teaching the Agent to Use Tools
    Episode 2 gives our REPL its first three tools — read_file, list_dir, run_bash — and walks through the tool-use loop with the Anthropic SDK. We handle stop reasons, tool errors, and the surprisingly tricky part of what to put back in the conversation.
    16 min
    →
  3. EP 03
    Mini Claude Code · Episode 03: Editing Files Without Wrecking the Repo
    Episode 3 adds the apply_patch tool — the one where most agents quietly destroy your work. We build a strict unified-diff applier with dry-run preview, workspace guardrails, and a confirmation gate that survives a Claude in a bad mood.
    17 min
    →
  4. EP 04
    Mini Claude Code · Episode 04: Making the Agent Forget on Purpose
    Episode 4 attacks the token bill head-on. We implement observation masking (the JetBrains-style trick that beats LLM summarization on cost and quality) and add an auto-continue path so max_tokens truncation stops silently breaking tool sequences.
    16 min
    →
  5. EP 05
    Mini Claude Code · Episode 05: Spawning Sub-Agents With Their Own Context
    Episode 5 splits the agent in two. We add a spawn_subagent tool that dispatches a scoped task to a fresh Claude with its own tool set and its own context window, then returns a compact summary. The pattern behind Anthropic's 'token usage explains 80% of variance' finding, in ~90 lines.
    17 min
    →
  6. EP 06
    Mini Claude Code · Episode 06: The Eval Loop That Finally Tells You If You Made It Worse
    Season finale. We build a 15-task SWE-lite harness that runs the agent end-to-end against verifiable code tasks, then wire in prompt caching so iteration is cheap. Pass rate, mean turns, and cost per task — pinned as a baseline you can regress against.
    18 min
    →

Run it in three commands

Clone, install, launch. Then talk to it.

git clone https://github.com/claude-community/mini-claude-code
cd mini-claude-code
cp .env.example .env    # add ANTHROPIC_API_KEY
npm install
npm start

Built for real repositories

What's next

The eval harness ships with three seed tasks. The plan is to grow it toward a 15-task SWE-lite subset and pin a baseline you can regress against. If you want to add tasks, open a PR.