Build your own Claude Code
Setup & the shape of an agent·5 min

What you're building

0 / 1

You're building Claude Code: a real terminal coding agent. By the end it reads, writes, and edits files, runs bash, asks permission before it does anything risky, spawns subagents, talks to MCP servers, fires hooks, loads skills, compacts its own context when the conversation grows too long, and fixes real repositories.

Every step is graded with zero LLM judgment — a test's exit code and a byte-for-byte diff decide whether you passed, never another model's opinion. You write TypeScript; the grader checks behavior.

A chatbot talks. An agent acts.

A chatbot returns text and stops. An agent acts — it has two things a chatbot doesn't:

  • Hands — tools. Reading a file, writing one, running a shell command. Real side effects on a real filesystem.
  • A will — a loop that decides when it's done. The model proposes an action, your code runs it, the result goes back, and the model decides whether to act again or stop.

Everything else in this course — permissions, the sandbox, subagents, MCP, hooks, skills, compaction — is what you wrap around hands and a will so they're safe, extensible, and able to survive a long session.

The loop

The agent loop — the model proposes, your code disposes
model ── tool_use ──▶ [ your tools run for real ] ── tool_result ──▶ model ── … ──▶ end_turn
  │                                                                          │
  └── "I want to run bash"                              "I've seen enough, I'm done" ┘

The model never touches your filesystem. It emits a tool_use — "run this command" — and waits. Your code runs the tool for real, captures the result, and feeds it back as a tool_result. The model reads that, decides what to do next, and the loop turns again until it signals end_turn. The whole course is iterations on this picture.

The 15-chapter tower

You build the agent one floor at a time, and each floor stands on the one below it:

  1. The loop — the heartbeat that turns tool_use into tool_result and stops on end_turn.
  2. Read tools — view, glob, grep: the agent learns to see the world.
  3. The write tool — create: the first real side effect.
  4. The edit tool — str_replace, with read-before-edit and stale-write guards.
  5. The bash tool & your first real fix — wire everything into the loop and fix a planted bug end-to-end. This is claude-code-lite, complete.
  6. Permissions — allow / ask / deny rules and modes: the brakes.
  7. The sandbox — OS-style containment so an allowed action still can't escape the tree.
  8. Subagents — spawning child agents with their own context.
  9. MCP client — speaking the Model Context Protocol to outside tools.
  10. MCP server — exposing your own tools over MCP.
  11. Hooks — running your code on the agent's lifecycle events.
  12. Skills — loading reusable capabilities on demand.
  13. Compaction — summarizing old turns so a long session fits the context window.
  14. Plan & tasks — structured planning and task tracking.
  15. The CLI — the terminal interface that ties it together.

Chapter 5 is the hinge: by then you have a working agent. Everything after it makes that agent safe, extensible, and durable.