Lesson 04 · Loop Engineering

Maker and checker

The single most useful structural decision in a loop.

Osmani does not hedge on this one:

The most useful structural thing in a loop, by far, is splitting the one who writes from the one who checks. The model that wrote the code is way too nice grading its own homework. Addy Osmani, Loop Engineering

A second agent, with different instructions and sometimes a different model, catches what the first one talked itself into.

Why this matters more inside a loop

When you prompt turn by turn, you are the checker. You read the diff before you accept it. In a loop you are asleep. So the verifier is not a nicety — it is the only reason you can walk away at all.

How it looks in Claude Code

Sub-agents live in .claude/agents/. Each gets a name, a description, instructions, and optionally its own model and reasoning effort. That last part is the lever: your security reviewer can be a strong model on high effort while your explorer is a fast read-only one. Codex does the same with TOML files in .codex/agents/.

---
name: spec-verifier
description: Verify a draft change against the project skills and
  the existing tests. Never edits files.
tools: Read, Grep, Bash
---

You did not write this code. Assume it is wrong until the tests say
otherwise. Report: does the change satisfy the stated goal, does it
break any documented project rule, do the tests actually cover it.
Answer with findings only. Do not praise the work.

The usual split, in both tools: one explores, one implements, one verifies against the spec.

The stop condition is the same idea

Claude Code's /goal keeps working until a condition you wrote is actually true, and after every turn a separate small model checks whether you are done. Osmani points out what that really is: the maker and checker split applied to the stop condition itself. The agent that wrote the code is not the one that declares it finished.

Cost Sub-agents burn more tokens, because each one does its own model and tool work. Osmani's guidance: spend them where a second opinion is worth paying for. Not everywhere.

Check yourself

Why must the verifier be a separate agent, not the same one?

What does Claude Code's /goal add over /loop?

Write one sentence of instruction that makes a verifier adversarial rather than agreeable.

Strong verifier prompts do three things: deny authorship, set the default to "wrong until proven", and ban praise. Osmani makes the full case in adversarial code review.

Read the source

Primary source: Adversarial code review by Addy Osmani. Pair it with the code agent orchestra.

Ask me. I can help you write your first spec-verifier agent and test it against a change you already know is flawed.