14 steps • 3 tiers • From prompter to architect

Loop Engineering
a practical guide.

Most developers still prompt coding agents by hand. The next era belongs to those who design the loops that prompt the agents.

Codez
@0xCodez • 14-step roadmap
Addy Osmani
@addyosmani • The 5 building blocks
6.8M views
19.7k bookmarks
~4×
Anthropic's review-adjusted gain (the 8× headline counts lines)
5
Core building blocks
4
Conditions to pass first
11
Common failure modes
Where it sits

Four layers, each one wrapping the last

Loop engineering doesn't replace what came before it. Each layer moves further from the model and closer to the system around it.

LAYER 01
Prompt
How the task is expressed. Shapes model behavior.
LAYER 02
Context
Which instructions, data, and tools are available. Shapes model understanding.
LAYER 03
Harness
Connects the model to files, tools, and feedback. Shapes system reliability.
LAYER 04
Loop
How the system observes, acts, verifies, and recovers — on repeat. You are here.
The Framework

Three tiers to mastery

TIER 1
The Why & The Test
01-04
Decide if loops are even worth building for your work. Run the honest 4-condition test.
Start here
TIER 2
The 5 Building Blocks
05-09
Automations, Worktrees, Skills, Connectors, and Sub-agents. The primitives of every reliable loop.
Master the primitives
TIER 3
Build It Right
10-14
State files, minimum viable loops, failure modes, comprehension debt, and the security tax.
Don't build a money pit
Addy Osmani @addyosmani
"Loop engineering is replacing yourself as the person who prompts the agent. You design the system that does it instead. A loop here can be thought of a recursive goal where you define a purpose and the AI iterates until complete. It's roughly five building blocks."
Key insight: "The agent forgets, the repo does not."
Boris Cherny Creator & head of Claude Code, Anthropic
"I don't prompt Claude anymore. I have loops running. They're the ones prompting Claude and figuring out what to do. My job is to write loops."
Worth noting: he reports not having hand-written code in eight months — and running hundreds to tens of thousands of agents on some days.
INTERACTIVE TOOL

Should you even build a loop?

Run the 4-condition test + 30-second checklist. Most developers fail at least one.

The 4-Condition Test
From AlphaSignal analysis + practical experience
Step 02
Readiness Score
0/4
30-Second Loop Check
Step 04
PART 01 / 03

The Why & The Test

Steps 01–04
PART 02 / 03

The 5 Building Blocks

Steps 05–09 • Aligned with Addy Osmani's framework
Before you build

Two decisions that set the cost

The building blocks are the same either way. These two choices decide whether the loop is affordable and whether you can trust it.

DECISION 01 — HOW BOUNDED?
Closed loop
Start here
You design the path first. The loop still runs on its own, but inside rules you set: clear goal, defined steps, evaluation after each step, a stop condition, and a hand-off point when it gets stuck.
Cheaper, more reliable, cleaner output. This is the version that pays off today.
Open loop
Later
You give a broad goal and let the agent search for the path. It can discover things you never specified — and it can try too many paths, drift from the real goal, and generate low-quality output quickly.
Open the loop up only once your checks are strong enough to catch the drift.
DECISION 02 — HOW BIG?
Single-agent loop
One agent discovers, plans, executes, checks, and improves. Like one person rewriting their own draft. Good for focused scopes: a bug fix, a research summary, a content draft.
≈ 50K–200K tokens per medium run
Fleet loop
An orchestrator owns the mission and splits it across specialists, each of which may call narrower sub-agents. Closer to a small team running a project end to end — and the review burden scales with it.
≈ 500K–2M tokens per run
The honest default for a first loop: closed and single-agent. It is the cheapest thing that can still teach you whether your gate actually catches bad work — which is the only question that matters before you scale up.
HOW A HEALTHY LOOP WORKS

The Minimum Viable Loop

01 • TRIGGER
Automation
Scheduled run, webhook, or event fires the loop.
02 • CONTEXT
Skill + State
SKILL.md + STATE.md give persistent memory & project knowledge.
03 • EXECUTE
Maker Sub-agent
Writes code, explores, proposes changes in a clean worktree.
04 • VERIFY
Checker Sub-agent + Gate
Objective test / build / linter decides pass or fail.
05 • ACT
Connectors
Open PR, update Linear, post in Slack. Human gate for irreversible actions.
Feedback loop returns to state + automation
REAL-WORLD EXAMPLE

What one healthy loop actually looks like

From Addy Osmani

An automation runs every morning on the repo. Its prompt calls a triage skill that reads yesterday’s CI failures, the open issues, the recent commits, and writes the findings into a markdown file or a Linear board.

For each finding that is worth doing, the thread:
  • • Opens an isolated worktree
  • • Sends a sub-agent to draft the fix
  • • Sends a second sub-agent to review that draft against the project skills and existing tests

Connectors let the loop open the PR and update the ticket. Anything the loop can’t handle lands in the triage inbox. The state file is the spine — it remembers what got tried, what passed, what is still open, so tomorrow morning the run picks up where today stopped.

You designed it once. You are not prompting any of those steps.
INTERACTIVE BUILDER

Design your first loop

Answer a few questions. Get a concrete starter configuration you can implement today.

PART 03 / 03

Build It Right or Don’t Build It

Steps 10–14

The mistakes that turn loops into money pits

These are the patterns that cause loops to fail silently or explode in cost.

SINCE THE ORIGINAL THREADS

Four things worth knowing

The roadmap above still holds. These landed after it and change how you'd build.

CONTEXT
Compaction is not enough on its own
Summarizing a full context window now ships natively. But for very long jobs Anthropic found it still had to do full context resets, rebuilding each session from a structured handoff file. Write progress after every step, not at the end.
REALITY CHECK
Most production agents are short and supervised
A survey of 306 practitioners found 68% of production agents run ten steps or fewer before a human steps in, and 74% still rely mainly on human evaluation. The systems that work are small, not autonomous.
COST
Your bill scales with iterations, not model choice
Context gets re-read every pass, so cost tracks how many times the loop cycles. Cost per accepted change is the number that actually measures loop health — and almost nobody tracks it.
ACCOUNTABILITY
Acting agents need an audit trail
Once a loop takes actions rather than suggesting them, someone has to answer which agent did that and whether it was allowed to. Log the actor, the action, and the approval on every write.
THE BOTTOM LINE

Your job moved up
a level.

"Build the loop. Stay the engineer."
For two years the leverage was in the prompt. That phase is ending. The next leverage point is one floor up: the system that decides what agents work on, when, with what gate, and what state survives between runs.
Sourced from Anthropic engineering docs (Effective harnesses for long-running agents, the compaction API),
Addy Osmani’s work on loop engineering, AlphaSignal analysis,
Measuring Agents in Production (306-practitioner survey), and real-world production patterns • 2026