What Is Loop Engineering in AI Coding?

Loop engineering is the practice of designing autonomous systems — called loops — that prompt AI coding agents on your behalf, rather than prompting the agents yourself. Instead of typing instructions into Claude or Cursor and waiting for a response, you define a goal and a trigger, and the loop handles everything in between. The agent starts itself, writes code, checks its own progress, and keeps iterating until the goal is reached. You walk away. The loop works.

This concept exploded into the developer community after two of the most respected engineers in AI — Boris Cherny from Anthropic and Peter Steinberger from OpenAI — both talked about it publicly within the same weekend. Boris put it simply in a viral interview: "I don't prompt Claude anymore. I have loops that are running. They're the ones that are prompting Claude." Peter's tweet echoed the same idea and hit 5 million views in under 24 hours. Suddenly, everyone wanted to know: what exactly is a loop, and how do you build one?

What Is Agentic Coding and How Does It Work?

To understand loops, you first need to understand the workflow they're replacing. Traditional agentic coding — sometimes called vibe coding — works like this: you write a prompt, your AI agent writes some code, you review it, then you write another prompt. It's a back-and-forth process where the human is always in the middle, always directing the next step.

Loop engineering removes that human bottleneck. Instead of being the one who decides what the agent does next, you become the architect of the system that makes those decisions automatically. You're no longer a prompter. You're an engineer designing a factory that runs itself.

At its core, a loop only needs two things:

  • A trigger — something that starts the loop (a PR being opened, a scheduled time, or a human kicking it off manually)
  • A goal — the end state the agent is trying to reach, which must be verifiable in some way

The goal can be deterministic — like all tests passing or a function executing without errors — or non-deterministic, where an AI judges whether the goal has been completed. If this sounds familiar, it should. Loop engineering borrows directly from reinforcement learning, where an agent learns by receiving a verifiable reward signal when it succeeds.

How Do You Use Loops in Claude Code?

If you're using Claude Code, there's a built-in feature that makes looping incredibly straightforward. Just type /loop followed by a time interval and your goal. For example:

  • /loop every 5 minutes — compare what we've built with our full spec in spec.md and continue building until we complete it

Every five minutes, Claude spins up a new agent. That agent checks what's been built against the spec, identifies what's missing, builds more of it, and then the next loop kicks off and does the same. It keeps going — agent after agent — until the spec is fully satisfied.

You can also drop the time interval and just run /loop with a goal, which means a human starts it manually and the agent loops continuously until it reaches the end state. No scheduled intervals, just a relentless sprint toward the finish line.

How Do You Set Up Automations in Cursor?

Cursor has a dedicated Automations tab that lets you configure loop-style workflows visually. Here's how it works in practice: you set a trigger — like a pull request being opened on a GitHub repo — and then define what you want the agent to do each time that trigger fires.

A real-world example: every time a PR is opened on a project, the automation triggers an agent that reviews the PR for issues, fixes them automatically, commits back to the same PR, ensures all tests pass, and makes sure all CI checks go green. If tests fail, the agent fixes those too. The human never touches it.

There are three types of triggers available in Cursor Automations:

  • Action-based — something happens, like a PR opening or a file being saved
  • Schedule-based — also known as a cron job, running every 30 minutes, hourly, daily, etc.
  • Human-initiated — you manually start the loop with a defined goal

You can also give loops additional capabilities called skills, and even build logic that allows the loop to get smarter as it iterates. But at its simplest, every loop is just a trigger plus a goal.

What Is the Difference Between a Loop and an Automation?

These two terms are often used interchangeably, but there's a meaningful distinction. An automation executes a fixed series of steps. It runs the same instructions every time, like a script. A loop, on the other hand, contains decision-making logic. The loop actively evaluates whether it has reached its goal and decides whether to continue or stop.

That internal judgment — "Have I finished yet?" — is what separates a loop from a simple automation. Without it, you just have a scheduled task. With it, you have an autonomous agent that governs its own progress.

Is Loop Engineering Too Expensive for Most Developers?

Honestly? Right now, yes — for most people. The more you remove humans from the coding process, the more tokens your AI agent consumes. And tokens cost money. When Peter Steinberger disclosed his monthly usage earlier this year, it was $1.3 million in tokens. That's not a typo.

Both Anthropic and OpenAI give their own employees essentially unlimited token budgets, which is precisely why engineers like Boris and Peter are able to experiment freely with loop engineering. The rest of the industry doesn't have that luxury.

That said, this is not a permanent problem. The history of technology is clear: what is expensive today becomes cheap tomorrow. Compute costs fall, models become more efficient, and techniques that only the top companies could afford eventually become accessible to everyone. Loop engineering will follow that same curve. It's just early.

The bigger challenge right now isn't even cost — it's defining goals clearly enough for loops to work well. When the goal is deterministic (all tests pass), loops are clean and reliable. When the goal is abstract (build this feature), you need a complete, precise spec written upfront. For many developers, that level of upfront clarity is genuinely difficult to produce. Vague goals lead to loops that burn tokens indefinitely without ever truly finishing.

Will AI Eventually Replace Engineers With Autonomous Loops?

This is where it gets philosophical — and a little unsettling. Right now, humans are still required in the loop because we are the ones setting the direction. We decide what to build. We define the goal. The loop executes toward it.

But the logical endpoint of loop engineering is a system where AI doesn't just execute toward a human-defined goal — it decides the goal itself. AI with taste. AI that determines which features to build, which products to ship, which companies to start. At that point, the AI is designing its own factory, which is the definition of recursive self-improvement.

We're not there yet. But the trajectory is clear. Engineers are already moving from writing code, to writing prompts, to designing loops. The next step is loops that design better loops. The role of the human engineer is shifting — fast — from implementer to architect to director of systems we may eventually not fully control.

Whether that's exciting or terrifying probably depends on how good you are at writing specs.