LoopFlow
Tutorial Workshop Keywords Blog ๐ŸŽฎ LoopFlow Lab
Blog / One-shot prompts vs loops

One-shot prompts vs self-correcting loops

A one-shot prompt asks an AI coding agent for an answer and trusts the reply; a self-correcting loop verifies, retries on red, and stops only on proof.

Two ways to point an AI coding agent at a task

A one-shot prompt is the default: you describe the change, the AI coding agent edits some files, replies "Done", and the turn ends. A self-correcting loop is the other shape: you describe the change and a machine-checkable definition of finished, and the agent plans, acts, checks its own work, and keeps going until the check is green โ€” or stops and warns you it's stuck.

The difference isn't the model or the prompt quality. It's the control structure wrapped around the model. One fires once and trusts the reply. The other verifies, reflects on failure, and only stops on proof. This post walks the trade-off and shows both โ€” because a loop isn't always the right call.

Where one-shot prompts break down

A one-shot prompt has one structural flaw, and everything else follows from it: there is no verification step the agent must pass. The agent decides when it's done, and it announces done whether or not the work is done.

None of this means the model is bad. It means an unverified single shot is the wrong container for work where "done" actually has to be true.

What a self-correcting loop adds

A .loop file adds exactly the four things a one-shot prompt is missing โ€” a checkable finish line, a failure back-edge, gates on risk, and a floor so it can't spin forever.

Side by side: the same task, both ways

The one-shot prompt:

"Fix the failing checkout tax test in src/checkout and make sure nothing else breaks." The agent edits, replies "Done โ€” fixed the rounding." Did checkout.spec.ts::tax pass? The whole suite? You re-run it yourself. Failed? Re-prompt. And it may have pushed on the way.

The same task as a self-correcting loop:

loop "fix the checkout tax test":
  goal: the checkout tax test passes with no regressions
  done when the test "checkout.spec.ts::tax" passes

  look at: the checkout code, and the last failure
  allow edits automatically, but ask me before pushes

  each cycle: plan, then act, then observe
  when it fails: reflect, then plan again
  after 6 tries: stop and warn "tax fix thrashing"

It runs the test every cycle. Fails, reflects on why, fixes again. Stops only when the test is green โ€” or warns after six. Works on a branch, never touches main. The same file runs tomorrow, and a teammate can read exactly what "done" meant.

You can stack the finish line for work where one green isn't enough. Multiple done when lines are a conjunction โ€” all must pass:

loop "harden the auth middleware":
  goal: sessions expire correctly and no high-severity findings remain
  done when "pnpm test src/auth" passes
  done when "semgrep --severity=high" finds nothing

  look at: the auth middleware, and the last failure
  allow edits automatically, but ask me before touching migrations

  each cycle: plan, then act, then observe
  when it fails: reflect on which check broke, then plan again
  when blocked: ask a human
  after 8 tries: stop and warn "auth hardening stuck"

A one-shot prompt can describe both conditions. Only the loop enforces them, cycle after cycle, and self-corrects toward both.

When a one-shot prompt is still the right call

Loops cost more โ€” every cycle re-plans and re-runs the check, and that's tokens and wall-clock. Don't wrap ceremony around work that doesn't need it. A one-shot prompt wins when any of these hold:

The rule of thumb is the four-condition gate: does the task repeat, is "done" checkable, are the iterations affordable, and can the loop verify itself? All four hold โ†’ reach for a loop. Any one fails โ†’ just prompt, and move on.

The takeaway

A one-shot prompt asks the AI coding agent for an answer. A self-correcting loop asks for a result and won't stop until a real check agrees. Use the prompt for the trivial and the one-off. Reach for the loop the moment "done" has to be provably true, the agent should retry on its own, and a human needs to gate the dangerous step. Same model โ€” a container that verifies instead of hoping.

Try both shapes side by side in the playground, or learn the whole language from the first line in the tutorial.