Skip to content

Claude Code, under the hood.

If you use coding agents for real work, you need the operating model: loops, tools, context, permissions, verification, and failure. This guide gives you that model in 18 essays, with diagrams you can run.

Essays18
Acts5
Total reading1h 30m
Diagrams73 interactive
ReadIn order, or stand-alone

The two-loop state machine from essay 01. Every diagram in the guide works like this one: press a control, watch the mechanism move.

two loops · one user turn
OUTER LOOP · THE SESSION INNER LOOP · ONE MODEL RUN 1 · input 2 · route input 3 · save the turn 4 · build the prompt 5 · enter the loop 10 · save the result 11 · await next turn build requestper pass trim?window check call modelstream start read streamblock by block tool asked?watch the stream run toolssafe ones together attach resultsas a new turn a turn ending
the input router Your text arrives. It isn't a prompt yet.

ways a pass says "go again"

a tool was requested trimmed, retrying hit output limit, retrying a stop was blocked you typed something

ways a turn ends

completed turn limit prompt too long a stop hook refused you interrupted model error
The token never exits on a tool result. It loops back into the model call with the result attached, and only leaves when the turn reaches one of its possible endings.

Act I · The anatomy of one turn

4 essays

What happens, end to end, when you send one message.

Act II · What a turn costs, and what survives it

4 essays

The model forgets, the window is finite, every token is paid for. The constraints that explain everything next.

Act III · The disciplines of acting well

5 essays

Given those limits, how a good agent behaves: think before it touches, look before it reads, stay under control, fail cleanly, prove the work.

Act IV · Beyond a single agent

3 essays

When one agent is not enough: how it spawns others, which primitive to reach for, and how you extend the whole thing.

Act V · Where this is all going

2 essays

Where the half-built corners point, and the single shape every serious coding agent is converging on.

Index of figures

73 interactive diagrams

Every diagram is addressable. Use this as the map once you know which mechanism you want to revisit.

The twenty minute path.

The essays build, but each one earns its slot on its own. If you only have twenty minutes, read the agent loop, then context, then done means verified.