Lesson 04 · Loop Engineering
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.
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.
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.
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.
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.
Primary source: Adversarial code review by Addy Osmani. Pair it with the code agent orchestra.
spec-verifier
agent and test it against a change you already know is flawed.