Week 6 · Build the Clone

The Chat Interface & Tools

The product begins

⏱ ~8 hours, hands-on🐍 Python / 🔷 TypeScript🛠 You ship: mycode v0.1 — a streaming coding agent that edits your files safely
What this week is

Weeks 1–5 gave you every primitive: the agent loop, workflow patterns, a production harness, background agents, and evals. Starting now, you stop building exercises and start building a product — a working clone of a professional AI coding agent, one subsystem per week.

By Week 12 it reads codebases, edits files, runs commands, plans, remembers, previews artifacts, traces itself, and orchestrates sub-agents. It goes in your portfolio, not in a folder of course exercises. And we are not designing in the dark: each week, after building our own version of a subsystem, we open the real Claude Code source and study the decisions a production team made.

We start with the interface, because the interface is the product. An agent that thinks brilliantly but dumps a wall of text after forty silent seconds feels broken. Then we cross the line that separates a toy from a tool: the agent stops talking about your code and starts changing it.

A tool is a contract, not a function. The model never sees your code — it sees a name, a description that says when to use the tool, and a schema of arguments. And the result is the teacher: when a tool fails, you return the error to the model as data, and a good model fixes its next call.

The walkthrough

Each part adds one capability to the same growing codebase, and each is a runnable checkpoint.

  1. 01The REPL skeletonA read-eval-print loop that feels instant and never blocks on a long model call.
  2. 02Streaming outputTokens as they arrive, so the machine visibly thinks out loud.
  3. 03Slash commands & safe interruptsAn escape hatch for everything that is not a model turn, and Ctrl-C that cancels the turn without corrupting the conversation.
  4. 04The cost meterLive token and dollar accounting, because the bill is a feature.
  5. 05Read & WriteThe two simplest tools, and the path-safety rules that keep them inside the project.
  6. 06EditExact-match replacement — why it beats "rewrite the file" for reliability and cost.
  7. 07Glob, Grep & BashFast, exact, free search first; then the most powerful and most dangerous tool, and how to scope it.
  8. 08The permission systemAllow, deny, ask — and remembering the answer for the rest of the session.
  9. 09Fix a real bugEnd-to-end milestone: the agent finds, fixes and verifies an actual bug in a real repo.

After this week you can

  • Build a responsive streaming terminal interface with safe cancellation
  • Write tool descriptions and errors a model uses correctly
  • Build a permission system you would actually trust