A new open-source tool called LoopFlow is bringing structured loop engineering to Claude Code, letting developers define automated pipelines where AI agents write code, verify it, and iterate until a verification gate passes or the budget runs out.
The Core Idea: Loops, Not Prompts
For two years, the workflow has been: write a prompt, read the output, write another prompt. You held the tool by the hand the entire time. LoopFlow flips that dynamic. As Boris Cherny, creator of Claude Code, put it: 'I don't prompt Claude anymore. I have loops running that prompt Claude.' The tool lets you declare a goal, a pipeline of agents, and a verification gate in a single YAML file โ then step back while the system iterates.
Three Sharp Edges LoopFlow Addresses
The raw approach to AI coding loops has three well-known failure modes. First: agents grade their own homework. A model that wrote buggy code will happily declare it fixed. Second: unattended loops burn money fast โ a loop making mistakes is also a loop spending tokens with no oversight. Third: the agent forgets everything between runs, re-deriving what the previous run already learned. LoopFlow's answers are surgical. Gates use a separate agent with a distinct persona that must output 'VERDICT: PASS' before the loop can succeed โ no self-grading allowed. Budgets enforce hard USD ceilings enforced twice: by LoopFlow's runner and by Claude Code's own --max-budget-usd flag on every step. Memory is a plain Markdown file per loop, appended after each run and injected into every subsequent prompt.
Anatomy of a Loop
A loop definition lives in YAML under .loopflow/loops/. Each loop specifies steps as separate headless Claude Code runs (claude -p), with optional git worktree isolation to prevent loops from clobbering each other or your working tree. Every step receives the loop's memory, outputs from earlier steps in that iteration, and โ on retries โ the gate's feedback.
Starter Loops and Scheduling
Running 'loopflow init' scaffolds three production-ready loops: test-and-fix (the canonical write/verify pair), debt-audit (a discovery loop maintaining .loopflow/reports/debt-audit.md), and docs-sync (finds drifted documentation, fixes it in isolation, verifies claims against source). The tool deliberately ships without a daemon โ use cron, Windows Task Scheduler, or CI to trigger loops on your preferred schedule.
Programmatic API and Roadmap
Beyond the CLI, everything is available programmatically via 'import { loadLoop, runLoop } from "@loopflow/cli"'. Future plans include a built-in scheduler with cron expressions in loop.yaml, parallel steps fanning out across worktrees, structured gate verdicts via --json-schema, full loop run history, and adapters for other headless agents like the Codex CLI.
Key Takeaways
- LoopFlow solves self-grading through separate verification gates that must explicitly output VERDICT: PASS
- Dual budget enforcement (runner + Claude Code native) prevents runaway costs in unattended loops
- Memory files make every iteration smarter by preserving context across runs
- Git worktree isolation keeps multiple loops from fighting over the same codebase
- The tool requires no API keys, no daemon, and no cloud โ if Claude works locally, LoopFlow works
The Bottom Line
LoopFlow is exactly the kind of tooling the AI coding space needs right now: small, sharp, and opinionated about how autonomous agents should behave. The YAML-first design means loops are portable, auditable, and composable โ you can steal starter templates from the community cookbook or build your own. If you're running Claude Code without structured iteration logic, you're doing it wrong.