Loop Engineering: How to Build Agents That Improve Their Own Work

Most people still operate AI agents by hand
They enter one task
Wait for one response
Review the result themselves
Correct the mistakes themselves
Then send another prompt
The human is still doing the looping
The next stage looks different
You stop prompting the agent step by step
You build a loop around it
The loop gives instructions
Checks the output
Chooses the next action
And keeps running until the result meets the standard
That is loop engineering
The idea is simple
Stop spending your time prompting agents manually
Start designing the systems that prompt them for you
"You should not be prompting coding agents anymore You should be designing loops that prompt your agents"
Boris Cherny leads Claude Code at Anthropic
He described the same shift through his own workflow:
"I do not prompt Claude anymore I have loops running that prompt Claude and figure out what to do My job is to write loops"
Why most people still do not build real loops
Loops sound incredible until you see the token bill
A normal agent loop can consume context extremely fast:
Every retry costs tokens
Every correction costs tokens
Every verification step costs tokens
Every subagent adds another bill
That is the hidden limitation people rarely discuss
Loop engineering is not difficult because the concept is hard to understand
It is difficult because most users cannot afford unlimited agent runs
The obvious response is:
"Easy for you to say, you have unlimited OpenAI access"
And that criticism is fair
This is why cheap models with large context windows matter so much
To run useful loops every day, you need:
Without those things, loops remain expensive experiments
With them, loops become practical systems that can run real work
The old workflow vs the new workflow
For the last two years, most people have used agents like this:
You prompt
The agent responds
You review the answer
You notice a problem
You prompt again
It works, but it does not scale
The old workflow:
The new workflow:
A prompt gives an agent a single instruction
A loop gives the agent an entire job
What loop engineering actually means
Loop engineering means building repeatable feedback cycles around AI agents
The objective is straightforward:
Move from an initial attempt to a verified result
Without a human controlling every step
The basic loop contains five stages:
If the result passes the check, ship it
If the result fails, return it to the loop
That is the entire concept
You are not trying to write one flawless prompt
You are creating a system
One that improves imperfect outputs until they meet the requirement
Single-agent loops
Loops generally come in two sizes
The smaller version uses one agent to complete the whole cycle
It discovers what needs to happen
Plans the work
Performs the task
Reviews the result
And tries again when something fails
It is similar to one person editing their own draft until it is ready
Single-agent loops work well for:
One agent
One feedback cycle
Continuous self-improvement
Fleet loops
A fleet loop operates at a larger scale
One orchestrator receives the main objective
It divides the objective into smaller pieces
Those pieces are assigned to specialist agents
Each specialist can also delegate narrow tasks to smaller subagents
Example:
Goal: Build a productivity app
Orchestrator owns the mission
↓ ↓ ↓
Research Engineering QA
Specialist Specialist Specialist
↓ ↓ ↓
Web Researcher Code Writer Test Writer
+ Debugger + Bug TrackerThis is no longer one agent working by itself
It is closer to a small autonomous team running a project from beginning to end
Open loops vs closed loops
This is the most important practical difference
Not every loop works the same way
Open loops
Open loops are exploratory
You provide a broad goal and allow the agent to discover its own path
The agent may discover useful things you never specified
But it can also become expensive and chaotic
Open loops can:
Open loops are exciting
But they are usually not the best starting point
Closed loops
Closed loops have clear boundaries
The human defines the path first
The loop still operates independently, but it stays inside explicit rules
A closed loop includes:
This is the version that creates value today
It costs less
It is easier to trust
It produces cleaner results
Start with closed loops
Make them more open only after your checks are strong enough
The 6 building blocks of an effective loop
Every loop follows the same five-stage cycle conceptually
In practice, six building blocks make that cycle useful
1 Automations
Automation is the heartbeat of the loop
It starts the process without requiring you to remember to launch it manually
Examples:
If you still start every action yourself, the loop is not doing enough
2 Worktrees
Worktrees become important when several agents edit code at the same time
Without isolation, agents collide
Two agents may change the same file
One agent may overwrite another agent's work
A worktree gives every agent a separate workspace and branch
That lets multiple agents work in parallel
Without turning the repository into a mess
3 Skills
Skills store reusable knowledge about the project
Stop explaining the same context during every run
Write the important information once
Let every future loop reuse it
Useful skill files can contain:
Without skills, every loop begins from a cold start
With skills, every run begins with knowledge accumulated from earlier work
4 Plugins and connectors
A loop that can only read local files has limited value
Connectors allow it to interact with the tools where your real work happens
Examples:
This is the difference between:
"Here is a possible fix"
And:
"I opened the PR and connected it to the ticket"
"Then I monitored CI and posted the final update"
5 Subagents
The maker and the checker should not always be the same agent
An agent that wrote the code may be too forgiving when reviewing it
An agent that drafted an article may overlook the same weak sections twice
Use separate agents for:
Quality improves when the reviewer is independent
The creator should not be the only one checking the work
6 Memory
Memory allows the loop to continue across multiple runs
The model forgets
The repository does not
The notes do not
The project log does not
Memory can be stored in:
A long-running loop must remember what has already been attempted
What worked
What failed
And what still needs to be completed
Without persistent memory, the loop starts from zero every time
Real examples of loops
These workflows make the idea concrete
Coding loop
Read VISIONmd + ARCHITECTUREmd
↓
Plan the next change
↓
Edit the code
↓
Run the tests
↓
If tests fail → inspect the error → fix → test again
↓
If tests pass → summarize the changes
↓
StopA human does not need to drive every stage
The agent writes, tests, corrects, and verifies its own work
Research loop
Define the research question
↓
Find relevant sources
↓
Summarize the evidence
↓
Verify every claim against the sources
↓
Compare conflicting information
↓
Create the final synthesis
↓
Stop when the confidence threshold is reachedThis produces a much stronger result than asking for one quick summary
Content loop
Define the topic + audience + objective
↓
Create the first draft
↓
Send it to a critique agent
↓
Rewrite using the critique
↓
Score it against the success criteria
↓
If it passes → publish
↓
If it fails → rewrite againThe loop turns one idea into a repeatable content system
Sales outreach loop
Define the ICP
↓
Find leads that match the profile
↓
Enrich each lead with company data
↓
Qualify them against the criteria
↓
Personalize the message
↓
Run a quality review
↓
Send or escalate to a humanEvery example uses the same skeleton:
Goal
Action
Check
Fix
Repeat until the job is complete
Prompt engineer vs loop engineer
This is the new skill gap opening in 2026
Prompt engineer
A prompt engineer concentrates on better instructions
They improve the wording
They produce a stronger single response
But after the agent finishes, a human still has to review everything
The human remains the feedback loop
Loop engineer
A loop engineer builds the feedback system itself
They determine:
A prompt engineer says:
"Write a function for me"
A loop engineer says:
"Write the function"
"Test it and fix it until every test passes"
"Then summarize the change"
The tools may be identical
The mindset is completely different
The highest-leverage AI builders are moving beyond better instructions
They are creating systems that discover and plan
Execute and verify
Then stop at the correct moment
The short version
Loop engineering is the move from manual prompts to automated feedback cycles
The shift:
The 6 things you build:
The 2 sizes:
The 2 types:
The 5 stages:
The real cost problem:
The mindset change:
That is the real unlock
Stop searching for one perfect prompt
Build a loop that keeps making imperfect outputs better
A dependable loop will beat a perfect prompt
If you read this far
Follow @elune0x and bookmark this article
Come back to it when you're ready to build your own loops
