Mental Models for the AI EconomyAI Development
Loop Engineering: The Definitive Field Guide
The leverage point in software has moved from writing prompts to designing the loops that prompt your agents. The complete field guide — Ralph, maker-checker, worktrees, AGENTS.md, memory, and MCP — from someone who runs these loops across a live portfolio.
For two years the skill was prompting — you held the agent one turn at a time. That era is closing. The new skill is designing the loop that prompts the agent for you: a system that finds work, decomposes it, hands it out, checks it, records what happened, and decides what to do next.
- 1Fresh context — A brand new agent instance reads PROMPT.md. Nothing carries over from the last iteration — that is the point, not a limitation.
- 2Read state — fix_plan.md, the specs, the git log. The disk remembers what the model cannot, so the loop picks up where the last one stopped.
- 3Do one thing — Exactly one increment — and the agent chooses which one matters most. Widen this only once the project is stable.
- 4Back-pressure — Build it, test it, type-check it. Anything that can reject bad output goes here. Without this station the loop is just a very fast way to be wrong.
- 5Commit and kill — Write the plan back, commit, then destroy the context. Empty TODO means exit. Otherwise the wheel turns again.
That ring is the whole discipline in one picture. Five stations, turning without you. The leverage didn't vanish when agents got good — it moved one floor up, from the prompt to the machine that writes the prompts. This is the complete parts list, the assembly order, the maturity ladder, and the failure modes, from running these loops across a live portfolio of products.
A loop is a task plus a check plus a stop condition. Everything else — model choice, connectors, sub-agents, worktrees — is in service of making the check real enough that you can walk away. Most people build the task and skip the check, then wonder why autonomy burned them.
You might be getting very good at a skill that is quietly being retired.
Where the term came from, who named it, and why the technique is a year older than the word.
In early June 2026 a phrase stabilized across the builder community almost overnight. Peter Steinberger, who built OpenClaw, put it bluntly: stop prompting your coding agents and start designing the loops that prompt them. Boris Cherny, who leads Claude Code at Anthropic, described his own workday the same way — he no longer prompts Claude; he writes loops that prompt Claude and figure out what to do next.
On June 7, 2026, Addy Osmani published the essay that turned those one-liners into a named discipline: loop engineering. He didn't invent the practice — he caught an idea moving fast, gave it a name, and gave it a parts list. O'Reilly Radar republished the essay on June 22, which is how it reached most of the industry.
But the technique predates the name by nearly a year. In July 2025, Geoffrey Huntley published "Ralph Wiggum as a 'software engineer'" — a bash while loop wrapped around a coding agent that he used to build an entire programming language. Ralph is the ancestor of everything here, and still the clearest way to understand what a loop is, because it removes everything inessential.
My stance, stated the way both authors stated theirs: this is early, the failure modes are real, and a loop that runs unattended is also a loop that makes mistakes unattended. But the shape of the work has genuinely changed. If you build software with AI agents, this is the thing worth getting good at now — not despite the difficulty, but because the difficulty is where the professional edge lives.
There are three floors to this building. Most people are still working on the ground one.
A map that tells you which floor you are on right now, and what the one above it actually gives you.
The reason this went mainstream so fast is that it stopped being a tool thing. A year ago a loop meant a pile of bash you owned and maintained forever. Now the pieces ship inside the products — the same primitives, whether you're in Claude Code or the Codex app. Once you see the shape is identical, you stop arguing about which tool and design a loop that works regardless of which one you're sitting in.
A loop is two things. Almost everyone builds the first one and skips the second.
The one sentence the rest of this guide is an elaboration of.
Strip away the tooling and a loop is almost embarrassingly simple:
The entire craft is in making the check real and defining when to stop. Model choice, harness, connectors, sub-agents — all secondary to those two things.
Six parts. Four of them stop the agent guessing; two of them let you leave the room.
What each primitive gives you, why it exists, and the split that decides how you spend your time.
A working loop is built from six primitives. Five do the work; the sixth remembers it.
| Primitive | What it gives | Why it's in the loop |
|---|---|---|
| Skills | Instructions | Reusable, invocable know-how, so the agent doesn't re-derive your conventions every run |
| Memory | State | What's done, what's next, what "done" even means — held on disk across runs |
| MCP / connectors | Access | Issue trackers, databases, staging APIs, Slack — the tools you already use |
| AGENTS.md | Rules | How to build, run, and reason about this repo — read first, every run |
| Worktrees | Isolation | Separate checkouts, so agents working at once don't collide |
| Sub-agents | Separation | Maker/checker split — one agent proposes, a different one verifies |
The distinction that matters most: skills, memory, MCP, and AGENTS.md are the four knowledge surfaces — instructions, state, access, and rules. Worktrees and sub-agents are the two structural primitives. Get the knowledge surfaces right and the agent stops guessing. Get the structural ones right and the loop can run unattended without turning into a mess. If your loop is producing confident nonsense, the problem is almost always a knowledge surface. If it's producing a tangle, the problem is structural.
The two tools have already converged
These primitives ship inside both major products and map almost one-to-one. Design for the shape, not the vendor.
| Primitive | Claude Code | Codex app |
|---|---|---|
| Automations | scheduled tasks, cron, /loop, /goal, hooks, GitHub Actions | Automations tab (project, prompt, cadence); Triage inbox; /goal |
| Worktrees | git worktree, --worktree, worktree isolation on a subagent | built-in worktree per thread |
| Skills | Agent Skills (SKILL.md) | Agent Skills (SKILL.md), $name invocation |
| MCP / connectors | MCP servers plus plugins | Connectors (MCP) plus plugins |
| Sub-agents | subagents in .claude/agents/, agent teams | subagents as TOML in .codex/agents/ |
| State | Markdown (AGENTS.md, progress files) or Linear via MCP | Markdown or Linear via connector |
The names differ. The capability is identical. Stop being loyal to a tool and start being fluent in a pattern.
The dumbest technique in this article built a working programming language.
Why a one-line bash loop outperforms a long, careful session — and the four rules that make it survive contact with real work.
Before the primitives shipped inside the products, there was Ralph — still the purest expression of a loop. Geoffrey Huntley named it in July 2025. The name has two origins, both of which he owns: Ralph Wiggum, the cheerful Simpsons character who rams a doorframe and announces "I'm helping!" — and "ralph" as slang for vomiting, roughly how Huntley felt realizing how cheap autonomous code generation had become. His framing is that the technique is "deterministically bad in an undeterministic world." Once you see why that's a feature, the rest clicks.
Short Ralph — a while loop and a prompt
You feed the same prompt file to a fresh agent instance, over and over, until the work is done. Progress accumulates in files and git history — never in the model's context window. My first reaction was "that can't possibly work." It does. Huntley used exactly this shape to build CURSED, a production-grade programming language the model had no training data for. A contact of his delivered a $50k contract MVP for roughly $297 in tokens.
LLMs degrade as context fills. Huntley pins the practical clip at around 147k–152k tokens against an advertised 170k–200k window; past that, output quality drops and tool calls start failing. A long continuous session inevitably drifts into that zone, loses the plot, and confidently makes things worse. Ralph sidesteps this by killing context after every increment and starting clean.
The cardinal rule: one thing per loop. Ask Ralph to do exactly one thing, and trust it to choose which thing matters most. Relax that as the project stabilizes — but the moment it goes off the rails, narrow back to one. You have roughly 170k of usable context and you re-spend it every iteration, so frugality is survival.
Long Ralph — persistence with structure
The naive loop works for small tasks. To ship something real, it needs structure around it without abandoning the fresh-context principle.
Ralph's honest caveats
Huntley is blunt about the boundaries, and any field guide has to carry them faithfully:
- Ralph is a greenfield technique. In his words, there's no way he'd use it in an existing codebase. It bootstraps new projects, and gets you roughly 90% of the way — not 100%.
- Senior expertise is non-negotiable. Anyone claiming a tool does 100% of the work with no engineer is, in his phrasing, peddling nonsense. Ralph gets tuned by a senior operator — like a guitar — every time it drifts.
- You will wake up to a broken codebase sometimes. The call is whether to reset hard and re-run, or craft new prompts to rescue it. That judgment is the job.
Your agent is the single worst-qualified judge of the code it just wrote.
The one structural move that makes walking away from a running loop defensible.
The most valuable structural decision in any loop is separating the agent that writes from the agent that checks. The reason is simple and human: the model that wrote the code is too loyal to its own work to grade it honestly. It chases its reward function — compiling code — and will happily wave through a placeholder it wrote ninety seconds ago. A second agent, with different instructions and sometimes a different model, catches what the first one talked itself into.
This matters specifically inside a loop: the loop runs while you're not watching, so a verifier you actually trust is the only reason you can walk away. It's also, under the hood, what a goal-style stop condition does — a fresh model decides whether the work is done, applying the maker/checker split to the exit condition itself.
One caution: sub-agents burn tokens, since each runs its own model and tool calls. Spend the checker where a second opinion is worth paying for — architecture-bearing changes, security-sensitive diffs — not on trivial edits.
You design this once. Then you stop prompting individual steps forever.
The end-to-end shape, from a planning conversation to a pull request waiting for you.
The thing to notice: you designed this once. You didn't prompt any individual step. That's the whole idea made real — and it's the same pipeline in Claude Code or Codex, because the pieces are the same pieces.
The fastest way to get burned is to climb one rung higher than your checks can carry.
Five levels of autonomy, what each one asks of you, and an honest read on where professional work actually sits.
Loop engineering isn't all-or-nothing. There's a maturity ladder, and the discipline is not climbing faster than your verification can support.
- 1Manual control — You prompt every turn. The agent is a tool you hold. Nothing happens that you did not just ask for. Every engineer starts here and there is no shame in staying.
- 2Task review — You approve each task. The agent proposes the work; you sign off before it runs. This is where you find out whether your decomposition is real or wishful.
- 3Agent in a worktree — You review the output. The agent works alone in its own checkout. You read the result, not the process. The worktree is what makes walking away survivable.
- 4Checker plus PR — You review the PR. A second agent verifies the first, then the loop opens a pull request. Your judgment moves from the diff to the decision.
- 5Auto-merge — You set policy and spot-check. Green checks merge without you. Real, but reserve it for narrow, well-fenced changes where your automation genuinely carries the risk.
Most professional work today lives at levels 3 and 4. Level 5 is real, but reserve it for narrow, well-fenced changes where your automated checks genuinely carry the risk. Climbing a rung before your verification is ready is the single most common way loop engineering goes wrong.
Every risk here gets sharper as your loop gets smoother. None of them get milder.
The five failure modes, including the two that do not show up until months later.
This is the section most write-ups skip, and the one that separates a professional from a button-presser.
Two checklists. One for what you feed the loop, one for the loop itself.
The practical part: what makes a task loop-ready, and what keeps a running cycle from hurting you.
Get the tasks right
Get the cycle right
Set your loops up. But remember that prompting your agents directly is still effective. This is a balance, not a replacement.
If you keep one thing from all of this, keep the stack.
Six primitives, each with one job, and the three tensions every design choice resolves.
- Ralph → iterations. The engine: fresh context, one thing per loop, disk as memory.
- Maker–checker → verification. The trust: the agent that writes never grades its own work.
- Worktrees → parallelism. The scale: isolated checkouts, so many agents run without collision.
- AGENTS.md → rules. The knowledge: how this project builds, runs, and must not be broken.
- Memory → state. The spine:
fix_plan.md, git history, and specs holding what's done and what's next. - MCP → workflow. The reach: connectors that let the loop act inside your real environment.
Build the loop. But build it like someone who intends to stay the engineer, not just the person who presses go. The leverage moved. The responsibility didn't.
Sources and further reading
- Geoffrey Huntley — Ralph Wiggum as a "software engineer" (July 14, 2025): the origin of the technique, the fresh-context philosophy, and the canonical prompts. ghuntley.com/ralph
- Addy Osmani — Loop Engineering (June 7, 2026): the essay that named the discipline and gave it a parts list. addyosmani.com/blog/loop-engineering
- Boris Cherny (Head of Claude Code, Anthropic) — public talks and posts on writing loops rather than prompts.
- Peter Steinberger — the sentence that lit the fuse: design the loops that prompt your agents.
- O'Reilly Radar — republished Osmani's essay on June 22, 2026, carrying it to the wider industry.
The framing, the maturity ladder, the risk taxonomy, and the integration checklists are my own synthesis, drawn from running these loops across a live portfolio of products.
Get the next essay the day it publishes.
A few a month, written from real builds. Unsubscribe in one click.

Senior product manager and builder — 15+ years shipping enterprise products (AT&T, BMW Group), now running his own with AI. These essays are field notes from that loop: what AI actually changes about work, product, and the economics underneath. Based in South Florida.
- AI DevelopmentThe Agent Harness — Setting Up Claude Code Like You Mean It
An AI coding model on its own is a brilliant intern with amnesia. The harness — twelve parts of configuration, rules, and checks you wrap around it — turns it into a teammate you'd put on a real codebase.
Interactive deck · 14 slides - Future of WorkAutomate the Thirty
Every role breaks down the same way: mostly rules, a little judgment. AI doesn't come for the judgment. It comes for the thirty things you were never actually hired to do.
4 min read - Future of WorkYour AI Just Quoted a Client a Price. Can You Actually Deliver It?
Every CEO wants faster proposals. Almost nobody's asking the scarier question: does the AI writing them have any idea what your business can actually pull off?
5 min read