Loops
The best agentic loops by category: what each one does, what it runs in, when it stops, and a prompt you can paste in.
What's a loop?
A repeating cycle for your agent: act, check the result, improve, and stop only when a condition you can verify is true.
How to run one
Paste a loop's prompt into Claude Code, Codex or Cursor. To keep it running on its own, use a runner: /goal or /loop in Claude Code, Codex Goal Mode, or the Ralph loop.
Where these come from
Loops.fyi ↗ The broadest directory: copyable loops for Claude Code, Codex and Cursor, plus the runners and plugins.
Loop Library ↗ Forward Future's catalog, with the Loopy skill that finds, adapts and runs loops for you.
Awesome Agentic Loops ↗ Production-grade loops: each has proof of completion, saved state, a stop condition and approval gates.
AetherAI3 agentic-loops ↗ Audit-and-fix loops for backends, frontends, infrastructure, security, tests and tech debt.
Keeps Claude working until a condition you can verify is true. The built-in version of the Ralph loop, no script needed.
Runs a task on a cadence you describe in plain English, like a scheduler inside your session.
The official Ralph loop: a stop hook feeds your prompt back in every time Claude tries to finish, until the task is done.
The original pattern: a bash loop that starts a fresh agent session on the same prompt each time, with progress kept in files.
Codex Goal ModeBuilt-in
Codex's built-in long-horizon mode: it keeps working toward an objective you set until it is met.
A skill that finds, adapts, creates and runs loops for you from the Loop Library, and audits loops that misbehave.
Rewrites a vague request into a precise, checkable goal before any code is written.
Writes down the done-criteria first, then refuses to call anything done without evidence for each one.
Reads the code and plans first, waits for your OK, then builds with tests and commits.
Build-test-fix pair loopPrompt
Two roles, a builder and a checker. Every failure goes back to the builder until everything is green.
Reproduces the bug first, then tests one hypothesis at a time until the cause is proven.
Writes failing tests first, then implements without touching the tests until they pass.
Flaky-test huntPrompt
Finds tests that pass and fail at random and fixes the root cause instead of retrying them.
Small refactors that keep behaviour identical, reverting any step that turns a test red.
Dependency upgrade loopPrompt
Upgrades a dependency in small steps against a test baseline, so you know exactly what broke.
Test, mutation and chaosPrompt
Fills coverage gaps, finds tests that verify nothing, and injects failures into dependencies.
Works through review comments one at a time and replies to each with what changed.
Two-model review loopPrompt
Alternates reviews between models from different providers, so one model's blind spots get caught.
Claude writes the code, Codex reviews it, and they go back and forth until the review passes.
PR CI babysitterPrompt
Watches a PR's CI, fixes each failure, and pushes until the checks go green.
Stale PR review resolverPrompt
Clears old PRs stuck on unresolved review threads, one thread at a time.
A generator and a hostile reviewer argue over each change until the reviewer runs out of objections.
Karpathy's overnight research loop: one editable file, a frozen evaluator, one number. Only changes that beat the best result are kept.
Single-metric experiments where only measured gains survive. Works for prompts, pages, build times and more.
AutoloopHarness
Metric-driven propose, evaluate and keep loop, with all its state in plain markdown files.
autoresearch skillSkill
Karpathy's autoresearch pattern packaged as an installable skill, for any metric you can measure.
The RatchetPrompt
One change at a time, measured, kept only if it proves better. The ratchet never slips backwards.
Labels every factual claim in a draft as proven, weak or unsupported, then fixes or cuts the weak ones.
Timed, small, verified repo improvements: one fix per cycle, one commit each.
Weekly status loopPrompt
Updates STATUS.md each week from your real sources and carries open threads forward.
Queue triage loopPrompt
Works through a queue (issues, tickets, inbox) one item at a time and logs a note for each.
Production error sweepPrompt
Reads production errors, groups them, and fixes the most frequent real one.
Core hygiene sweepPrompt
Checks whether source-of-truth docs have drifted from the code and flags contradictions in one bounded pass.
Cost budget watchPrompt
Turns API spend and provider failures into a short list of decisions, before the bill surprises you.
Sweeps a web app for missing security headers and common OWASP issues, fixing one at a time.
Audits APIs for security flaws, N+1 queries, dead code and logging problems, and fixes them.
Checks your own agents against OWASP's agentic risks: tool schemas, excess privilege and prompt injection.
AI security red teamPrompt
Attacks your AI features for injection, data poisoning, jailbreaks and supply-chain risk.
Builds from a mock, screenshots the result, compares, and iterates until it matches.
Checks against WCAG 2.2 AA and fixes the single most harmful blocker each pass.
First-run UX loopPrompt
Goes through onboarding as a brand-new user and fixes the worst obstacle each pass.
UX/UI visual integrityPrompt
Visual regression, stateful UI checks and graceful degradation, across every screen.
Reviews components and bundle size, then checks the live accessibility tree for roles, focus and contrast.
Finds docs that disagree with how the product actually behaves, and updates them.
At each milestone, sweeps the README and docs so they describe what just shipped.
An evidence-based website overhaul: simpler pages, technical SEO, accurate entity data for AI answers, and accessibility.