LoopFlow
Tutorial Workshop Keywords ๐ŸŽฎ LoopFlow Lab
Keywords / loop

loop

A self-correcting unit of work. Compose

Syntax

loop "<name>":

What it does

The core construct of LoopFlow: a goal, a way to verify it (done when), the repeated steps (each cycle), and what to do on failure. Every cycle runs plan โ†’ act โ†’ observe, then the done when predicate decides โ€” pass and the loop stops, fail and it reflects the failure into the next plan. That back-edge is the whole point: a loop is a normal agent that checks its own work and tries again until a verifiable definition of done is met.

Reach for a loop when the task is repeatable and "done" is checkable โ€” a bug with a failing test, a refactor gated by a command, a migration with a verification step. If there's no way to verify completion, there's no loop; the done when line is written first, before any behavior, because a check that can never pass loops forever. The smallest real loop is just a goal and a done when; everything else โ€” look at: for scope, human gates for risky work, after N tries for a thrash guard โ€” is added as the job demands. Blocks start at column 0 and their body is indented two spaces.

Example

loop "fix the failing checkout tax test":
  goal: the tax line is correct at checkout
  done when "pnpm test checkout" passes
  each cycle: plan, then act, then observe
  when it fails: reflect, then plan again
examples/fix_test.loop

How it runs

โœ“ pass planeach cycle actmake the change observerun done-when stopgoal met โœ“ when it fails โ†’ reflect, then plan again
Every cycle runs plan โ†’ act โ†’ observe; the done when check decides โ€” pass โ†’ stop, fail โ†’ reflect into the next plan.

Example โ€” with a thrash guard

loop "fix billing apostrophe bug":
  goal: settings save when the company name has an apostrophe
  done when the test "billing.spec.ts::apostrophe" passes
  look at: billing/form.tsx, api/settings.ts, and the last failure
  when it fails: reflect, then plan again
  after 6 tries: stop and warn "thrashing"
the finish line first, the safety net last

Common mistakes

Related