Claude Code Nano

Build your own Claude Code. A guided project: you implement a working ~350-line agent in TypeScript — the same core loop the real Claude Code runs — yourself, problem by problem, against a provided read-only test harness.

There is no planner, no graph, no framework hiding the trick. An agent is a model that can ask for things, plus a harness that runs them and reports back, looped until the model stops asking. Six required lectures plus a bonus, one file (index.ts), five sections, ten points. By the end you run your own agent against a real API and watch it find and fix a planted bug in a JavaScript file.

Who this is for

A fluent programmer who is newer to TypeScript / Node specifically: async/await, promises, and the Node APIs this uses (fs, child_process, readline) are explained as they appear, and TypeScript syntax gets light scaffolding. The lectures are direct technical prose — they state how the harness works plainly, without analogies.

What you’ll be able to do

The lectures

The course builds one file in dependency order. Each lecture fills exactly one region of index.ts, using the identifiers already declared in the skeleton. index.ts is the only editable file; tests/, fixtures/, and solution/ are read-only harness.

#LectureBuildsPoints
01The Shape of an AgentThe whole spec, hand-traced; environment; Problem 0 warm-up1
02Tools I: EyesrunTool dispatch for read_file, list_files2
03Tools II: Handswrite_file, edit_file (the uniqueness invariant), bash2
04The Permission Gatepreview + confirm; async/await for real1.5
05The Agent LoopcallModel + agentLoop — the boss level2.5
06The REPL and the Endgamemain() REPL, crash recovery, live acceptance run1
07Subagents: The Task Tool bonusThe task tool — agentLoop recurses on itself+1

Points (10 + 1 bonus)

Self-graded — points exist for pacing, not stakes. Each lecture is earned by its ./ok NN suite going green plus checking your unlock-question answers against the appendix (spoilers, collapsed by default, on each lecture page). Lectures 01–06 are the graded 10; the bonus lecture 07 takes you to 11 out of 10.

LecturePointsEarned by
011Problem 0 green (./ok 00) + unlock answers
022./ok 02 green + unlocks
032./ok 03 green + unlocks — checkpoint: all five tools done
041.5./ok 04 green + unlocks
052.5./ok 05 green + unlocks (the boss level)
061./ok 06 green + unlocks; the live fixture-bug run is the payoff
07 bonus+1./ok 07 green + unlocks — the bonus point (11/10)
Extra0NANO.md / /context viz — bragging rights only

Getting the starter files

Download starter.zip and unpack it. It contains the skeleton index.ts (fully-typed signatures with YOUR CODE HERE stubs), the read-only test harness (tests/, fixtures/), the ok runner, and the Node project files. It does not contain the reference solution — the appendix snippets on each lecture page are the only answer key.

First run:

unzip starter.zip
cd claude-code-nano
npm install
./ok 00

Expect ./ok 00 to fail on one test:

× Problem 0: warmup() must return 61001 (fix the off-by-two in index.ts)
AssertionError: expected 60999 to be 61001

That failure is the shipped, pre-course state — it’s Problem 0 in Lecture 01. The other two setup tests (Node version, importing index.ts doesn’t crash) already pass. Fixing warmup() so ./ok 00 goes green confirms your toolchain works end to end, and you’re off.

No API key is needed for any ./ok run — every test scripts a fake model, so the whole suite runs offline and free. You only need an ANTHROPIC_API_KEY once, for Lecture 06’s live acceptance run.