The Ultimate Guide to Loops
How to design cheap and effective loops in Claude code or Codex.
Last week the whole AI community was abuzz with the concept of loops.
Only the lazy one didn’t mention or cite them in some way.
It all started with Boris Cherny (Claude Code Founder) saying that “he doesn’t write prompts anymore, he only designs loops”.
Then Peter Steinberger (the brain behind the OpenClaw) picked up the pace, posting a note on his X account:
The 8.3m reach is already enough to skyrocket the concept to stardom.
What the hell is a loop and why do those big names bet so heavily on it?
My take is that loops are so over-hyped because they are easy to grasp.
They promise (1) “presumably better” quality execution against the set goal; (2) more autonomy from the operator (meaning you as the one who’s prompting the agents).
Ultimately, it’s a simple engineering concept that means that the same function runs many times until it reaches the goal (e.g. maximum number of iterations).
That’s what makes it so attractive.
But I don’t buy stuff at face value.
I’m flooded with skepticism when the hype wave hits. The concept of loops is no exception.
Both Boris and Peter can easily spend unlimited budgets on tokens. If you let your loop roam freely on extra-effort, well, this is going to eat your limits alive.
Secondly, the longer it runs, the more context rot the agents get. What if the first agent’s stochastic response was biased? Then each new loop iteration would just amplify those biases even further.
Ultimately, why is it better than just manual iterations, which give you more control over the direction and the context you feed in?
I decided to dive into this rabbit hole and figure it out for myself.
🔁 The Concept of a Loop
What is a Loop?
You hand the machine a goal, it runs one pass, it checks the result against that goal, and if the work falls short it goes again.
Same function, fresh attempt, over and over, until the output either clears the bar you set or hits the ceiling you set - usually a cap on iterations so it does not burn through your wallet.
This is a classic engineering concept (e.g. while-statement is a foundational function in each programming language). What changed is what sits inside the loop.
Each pass now spins up an agent that reads files, writes code, runs the script, reads the error, and goes again. The body of the loop grew a brain, and that one upgrade is why everybody suddenly cares about a forty-year-old idea.
Types of Loops
There are three types of loop concepts in circulation right now.
The Ralph Loop is brute force. A script feeds the agent the same prompt and context and every iteration wipes out the previous existing state.
The built-in loops in editors like Cursor and Windsurf keep a shorter leash. The agent iterates inside your IDE, holds the file tree in view, and stops to ask when it is unsure.
The Claude Code and Codex loops are the ones Boris and Peter are backing. These agents plan, spawn helpers, run their own checks, and decide for themselves whether to go another round.
The most important question out of this comparison is - what does each pass carry into the next one?
Think of the model as having a fixed budget of attention, call it 100 percent. A genuinely hard task burns through it fast, half gone in the first few moves.
Pile more onto one long session and it has less and less left to think with, so it starts cutting corners. You have seen it happen: the answers get lazier the longer a chat runs.
That is the case against the marathon session (one you get with the IDE). It carries everything forward, so the context rots, and a wrong turn early on drags down every step after it.
Ralph runs to the opposite extreme. It wipes the slate between runs and carries nothing, so attention is always full and early mistakes are avoided.
The problem is that it also throws away whatever it just learned, and it has no test to tell a good pass from a bad one. Fresh every single time, and blind every single time.
A good loop threads between the two. It resets the heavy working context each pass, writes down a short, checked summary of what it learned, and carries only that forward. Then it runs a hard test before moving on.
The test catches a bad pass and bins it. The summary tracks the progress. The reset keeps the next pass from inheriting the mess. Each pass gets full attention, nothing rots, nothing snowballs, and the loop still accumulates.








