Prompt engineering & loop engineering, clearly explained!
At its core, an agent is a while loop:
- The model runs
- It requests tool calls
- The tool results return to the context
- The model runs again until it stops requesting tools
ReAct described this form of loop back in 2022-23, and almost every agent/framework runs a similar implementation of this.
So loops aren't a new thing at all, and the above implementation of loops was solved a long time ago.
What wasn't solved is the loop around the above loop, and this is what Boris/Peter talked about recently.
In the most common setup, you are the loop around the loop.
- You write a prompt
- Read the turns the agent runs
- Write the next prompt
- And repeat, catching failures as it runs
Now there are attempts to let the system run the outer loop too, so that you can eliminate yourself.
- It starts on a schedule or an event
- It runs for many turns with no prompt in between
- It decides on its own when it's done
- It comes back only when something needs you
Consider a failing test in CI to understand this.
In the current way, you paste the error into the agent, read the fix, run the tests, and paste the next failure back in until they pass.
So every turn goes through you.
The loop runs those same turns on its own.
It triggers on a schedule, reads the failure, drafts a fix on a branch, runs the tests, and feeds a failure back in as the next turn, until they pass or it hits a turn limit.
A separate reviewer checks the fix, opens a PR if it's clean, and flags it for a human if it isn't.
So the inner loop was always automatic. The part being automated now is your involvement in that loop.
None of that comes for free though, as expected.
> Sitting in the outer loop gave you the flexibility to stop, possess project memory, and be the reviewer. But each of those now has to exist in the system.
> Also, while sitting in the loop was slow, you understood the system.
But one big downside of taking yourself out is that you keep the ownership, but would likely lose the understanding.
> Inherently, a loop doesn't know when to stop on its own either. It will take the agent's word that the work is done and stop on a fix while the tests still fail, so the stop has to be a real check, plus a turn or token cap to avoid infinite loops.
> The context grows every turn, and the model gets worse as its context fills up.
So the loop should trim it and keep summaries instead of full history, move large outputs to files, and split subtasks into separate runs.
> Lastly, the agent can't be the one to check its own work, since it will pass whatever it wrote.
A separate model or a binary/deterministic test should provide that signal.
And the cost for all this adds up fast since every turn sends the whole context again, so a long loop can spend many times what a single prompt would.
If you want to dive deeper, my co-founder wrote a full breakdown, from the loop above to a run that finishes on its own, with the code behind each part.
Read it below.
🚨🇺🇸 | EXCELENTE NOTICIA: Tras el impresionante éxito de la salida a la bolsa de SpaceX, se reveló que Elon Musk planea lanzar su propio servicio de red móvil celular luego de adquirir recientemente el espectro inalámbrico de 65 MHz perteneciente a EchoStar por 17 mil millones de dólares, con el objetivo de competir con las gigantes de telecomunicaciones al ofrecer una cobertura global mediante sus satélites Starlink.
Loop Engineering is the next step after prompt engineering.
Most people still use Claude Code, Codex, Cursor, or Grok like a chat box:
Prompt.
Wait.
Copy.
Fix.
Prompt again.
This repo shows the next step:
You stop prompting the agent.
You design the loop that prompts the agent for you.
Inside:
→ Daily triage loops
→ PR babysitter loops
→ CI sweeper loops
→ Dependency sweeper loops
→ Changelog drafter loops
→ Post-merge cleanup loops
→ Issue triage loops
It also gives you CLIs to:
• Scaffold a loop
• Estimate token cost
• Audit if your repo is ready
• Add memory/state
• Add human handoff
• Add verification gates
• Run agents safely through GitHub Actions
The wild part is the shift in thinking.
Prompt engineering was about writing better instructions.
Loop engineering is about building a system where agents keep working, checking, fixing, and escalating without you babysitting every step.
This is what AI coding looks like when it stops being a chat session and starts becoming an operating system for software teams.
Repo: https://t.co/2USzC6KHUt
Welcome a new member of the 𝕏 family.
@XMoney is starting its rollout to a select group of US Premium+ members as we refine and elevate the experience ahead of a wider launch.
Excited to see it out in the wild.
Feedback is crucial - let’s make it better.
⭕️ El mensaje del presidente electo de #Colombia a @RicardoBSalinas
🔹“ #TíoRichie, necesitamos a empresarios como usted invirtiendo aquí en Colombia, con toda la seguridad jurídica y la seguridad física. Necesitamos titanes como usted en Colombia y en #México”, dijo @ABDELAESPRIELLA.
Ahora sí, oficialmente quiero felicitar a mi amigo, empresario y presidente electo de #Colombia, @ABDELAESPRIELLA, por su contundente triunfo en las elecciones del pasado domingo. Los colombianos han hablado y han decidido apostar por un mejor rumbo para su país, lejos del #NarcoRégimen.
En Colombia, el tigre va para adelante… y en México también. ¡Nos vemos pronto!
De risa loca ayer con los chairos…
😂😂😂😂
Defendiéndole con uñas y dientes la virginidad del culo a AMLO, como si de todos modos no le hubiera dado el cogidón de su vida Calderón en el 2006…
Desde que el presidente Trump cerró USAID:
Fue derrocado el tirano Maduro
Ganó la derecha en Perú
Ganó la derecha en Chile
Ganó la derecha en Bolivia
Ganó la derecha en Ecuador
Ganó la derecha en Honduras
Ganó la derecha en Colombia.
Gracias Presidente Trump. 🇺🇸🦅
the four pillars of loop engineering.
the loop itself is six lines, and nobody competes on it. every serious agent framework lands on the same tiny while-loop. model reads context, calls a tool, you feed the result back, repeat until it stops asking.
so if that part is solved, what is everyone actually engineering?
the answer is everything around the model. Boris Cherny, who built Claude Code, put it plainly. he doesn't prompt Claude anymore, he writes loops and lets them run.
that shift has a name now, and it rests on four pillars that are harder than the six lines make them look. these are the parts that actually break:
→ knowing when to stop. a terminal message ends the turn, not the task. an agent will write failing code, glance around, and declare victory. "done" has to mean the tests pass, not the agent feeling good about its work.
→ keeping the context clean. long loops rot from the inside as old outputs and dead ends pile up. a worse context produces a worse decision, which adds more noise, and the agent gets dumber the longer it runs. you fight it by treating context as a budget, not a bucket.
→ tools the agent can actually use. pile on a hundred tools and it loses track of which one to reach for. writes have to be safe to repeat, because loops retry, and a retried "create customer" call leaves you with duplicate records.
→ something that can say no. left alone, an agent agrees with itself. the fix is to separate the maker from the checker so the worker never grades its own homework.
put those four together and your job changes. you stop steering the agent move by move and start designing the system that steers it.
Karpathy runs research loops overnight that tweak a script, test it, keep what works, and throw away what doesn't, with himself nowhere in the loop. he arranges it once and hits go.
the model is becoming a commodity. the loop around it is where the real engineering lives now.
the best builders stopped asking what they should tell the agent to do. they started asking what system would do this without them.
I wrote the full breakdown. the article is quoted below.
stay tuned for more on this!
HE TURNED A $599 MAC MINI INTO A CLAUDE SECOND BRAIN USING OBSIDIAN, PYTHON AND A FEW ALWAYS-ON LOOPS
not a fancy SaaS dashboard. not another chat tab. a tiny box on a desk that can pull lectures, transcribe audio, read articles, clean notes and write everything into a local vault while he sleeps
Steve Jobs wanted the Mac mini to be the small affordable Mac anyone could put on a desk. now that same tiny Apple box can run Claude loops 24/7, process 100+ saved links, turn 2-hour lectures into structured notes, and send a morning brief for a few dollars in API calls
the real trick is the loop. trigger, do, verify, retry, stop. Claude does the thinking, Obsidian stores the memory, and the Mac mini keeps running even when nobody is touching the keyboard
bookmark this before you think a second brain needs another $29/month app
APPLE JUST SHOWED HOW TO RUN 10 AI AGENTS LOCALLY ON MAC - NO CLOUD, NO API KEYS, ZERO COSTS
00:10 Apple engineer says: "your data stays on your device, AI available anywhere at any time, zero usage costs"
agent reads your code, checks GitHub, finds what needs attention and writes a report - all on your Mac, nothing goes to the internet
10 agents work simultaneously - one writes code, another tests, third fixes bugs - parallel with no queue
built a full iPad app from scratch in 2 minutes, fixed its own mistakes and compiled without issues
takes 5 minutes to set up - and you never pay again for a bot that runs 24/7