Agent loops for coding agents
An agent loop is a prompt that keeps a coding agent working through one check-and-fix cycle until a condition you can measure is true: the build is green, coverage clears a target, an audit comes back clean. Each loop below is ready to paste into Claude Code, Cursor, or any agent with tools, with an iteration cap, stop rules, and the MCP servers that help it run.
- Build & CI
Build Until Green
An agent loop that runs your build and tests, fixes the first real error, and repeats until everything passes or it hits the iteration cap.
Up to 10 iterationsOpen loop - Build & CI
CI Watch and Fix
A loop that watches the CI run on your pull request, reads the failing job's logs, pushes a focused fix, and waits for the next run to go green.
Up to 5 iterationsOpen loop - Build & CI
Dependency Upgrades Until Green
Upgrade outdated packages one at a time, run the tests after each bump, and revert anything that breaks, so every upgrade in the batch is known good.
Up to 15 iterationsOpen loop - Build & CI
Container Until Healthy
An agent loop that builds your Docker image, starts the container, probes its health endpoint, and fixes the Dockerfile or config until it serves traffic.
Up to 8 iterationsOpen loop - Testing
Coverage Until Threshold
Measure test coverage, write meaningful tests for the least covered code, and repeat until the project clears your coverage target without padding.
Up to 8 iterationsOpen loop - Testing
Flaky Test Hunter
Re-run your test suite to expose flaky tests, find the root cause of each one, fix it, and prove the fix with a long streak of consecutive passes.
Up to 6 iterationsOpen loop - Testing
TDD Red-Green Loop
Build a feature test first: write one failing test per acceptance criterion, make it pass with minimal code, refactor, and move on to the next one.
Up to 12 iterationsOpen loop - Testing
Bug Repro Until Fixed
Turn a bug report or error event into a failing regression test, fix the code until that test passes, and confirm nothing else in the suite broke.
Up to 8 iterationsOpen loop - Code quality
Lint Until Clean
An agent loop that runs your linter, fixes violations one rule at a time with real code changes instead of disable comments, and repeats until zero remain.
Up to 10 iterationsOpen loop - Code quality
Strict Types Until Zero
Tighten type checking one directory at a time, fix the new type errors with real types instead of any or ignore comments, and repeat until the checker passes.
Up to 10 iterationsOpen loop - Code quality
Dead Code Sweep
Find unused files, exports, and dependencies with a static analyzer, remove them in small batches, and run the build and tests after each removal.
Up to 8 iterationsOpen loop - Security
Dependency Audit Until Clean
Run a vulnerability audit on your dependencies, fix high and critical findings with the smallest safe upgrades, and repeat until the audit is clean.
Up to 8 iterationsOpen loop - Security
Secret Scan Until Clean
Scan the repository for committed credentials, move each one to environment configuration, flag it for rotation, and re-scan until no findings remain.
Up to 6 iterationsOpen loop - Security
Static Analysis Until Clean
Run a static application security scanner, fix each real finding at its source, document false positives, and re-scan until no high findings remain.
Up to 8 iterationsOpen loop - Docs
Docs Until In Sync
Check every code sample and command in your README and docs against the real code, fix what drifted, and repeat until all examples run as written.
Up to 8 iterationsOpen loop - Docs
Docstrings Until Covered
Find public functions, classes, and endpoints with missing or stale reference docs, write accurate docstrings, and repeat until doc coverage hits your target.
Up to 8 iterationsOpen loop - Data
Query Until Verified
Write a SQL query for a business question, run it on a read-only connection, and refine it until row counts, totals, and sanity checks reconcile.
Up to 6 iterationsOpen loop - Data
Data Checks Until Clean
Run data quality tests on a pipeline or model, trace each failure to the transformation that caused it, fix it, and rebuild until every test passes.
Up to 8 iterationsOpen loop - Data
Migration Round Trip
Apply a database migration to a scratch database, roll it back, apply it again, and compare schemas until the migration is clean in both directions.
Up to 6 iterationsOpen loop - Browser & QA
Accessibility Audit Until Clean
Drive a real browser through your key pages, run an automated accessibility audit, fix each violation in the source, and re-audit until every page passes.
Up to 10 iterationsOpen loop - Browser & QA
Smoke Test Until Clean
Walk through your app's critical flows in a real browser, capture console errors and failed requests, fix them, and repeat until every flow runs clean.
Up to 8 iterationsOpen loop - Browser & QA
Web Vitals Until Budget
Measure Core Web Vitals and bundle size with Lighthouse, fix the biggest offender, and re-measure until each key page fits your performance budget.
Up to 8 iterationsOpen loop
What makes a good agent loop
- A settings block. Commands, targets, and limits sit at the top of the prompt, so you adapt a loop to your project by editing a few lines instead of rewriting it.
- One small change per pass. The agent runs a check, fixes one cause, and checks again. Small steps keep each change reviewable and stop one bad edit from snowballing.
- A stop condition the agent can verify. Exit codes, coverage numbers, and audit counts are things the agent can read from command output, so it knows when it is done instead of guessing.
- Hard limits and safety rules. Every loop has an iteration cap, a rule for when it is stuck, and a list of things it must never do, such as force-pushing, silencing tests, or touching production.
- The right tools. Loops run best when the agent can reach your repository, CI, browser, or database directly. Each loop page lists matching MCP servers from the directory, ranked by trust score.