// SERIES
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.
- EP 01Mini Claude Code · Episode 01: A 40-Line REPL That Actually RemembersStart 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.→
- EP 02Mini Claude Code · Episode 02: Teaching the Agent to Use ToolsEpisode 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.→
- EP 03Mini Claude Code · Episode 03: Editing Files Without Wrecking the RepoEpisode 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.→
- EP 04Mini Claude Code · Episode 04: Making the Agent Forget on PurposeEpisode 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.→
- EP 05Mini Claude Code · Episode 05: Spawning Sub-Agents With Their Own ContextEpisode 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.→
- EP 06Mini Claude Code · Episode 06: The Eval Loop That Finally Tells You If You Made It WorseSeason 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.→
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 startBuilt for real repositories
- apply_patch uses byte-exact context matching — refuses to apply on drift
- .bak backup written next to every edited file
- run_bash has 15s timeout and 20KB output cap
- read_file / list_dir refuse to escape the workspace root
- sub-agents cannot spawn more sub-agents (no recursion)
- y/N confirmation before every write, unless MCC_AUTO_APPROVE=1
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.