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.
Drive lint warnings, type errors, and dead code down to zero in safe batches.
- 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
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.