Skip to content
Agent 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 iterationsStop rules and safety limits
The prompt

Copy the Lint Until Clean loop

Stops when the linter reports zero errors and zero warnings for the chosen scope, or after 10 iterations. Edit the settings block, then paste the whole prompt into your agent.

lint-until-clean.prompt.md
You are running the "Lint Until Clean" loop.

Settings (edit before running):
- Lint command: npx eslint . --format json
- Autofix command: npx eslint . --fix
- Test command: npm test
- Scope: the whole repository
- Max iterations: 10

Goal: zero lint errors and warnings in the scope above.

Before the loop: run the autofix command once, then the test command. If tests fail after autofix, revert the autofix and continue without it.

Each iteration:
1. Run the lint command and count remaining violations by rule.
2. Pick the rule with the most violations. Read the rule's documentation if its intent is not obvious.
3. Fix every violation of that rule with real code changes.
4. Run the test command. If anything fails, fix your change, not the test.
5. Log: iteration, rule, violations fixed, total remaining.

Stop when:
- The linter reports zero errors and warnings. Success.
- You reach the max iteration count.
- A rule conflicts with the codebase's intended style. Stop and report it as a config decision for a human.

Rules:
- Do not add disable comments, change lint configuration, or add files to ignore lists.
- Keep behavior identical. Lint fixes are not the place for refactors or new features.
- Touch only files with violations for the current rule.

Final report: violations by rule before and after, and any rules you recommend changing with reasons.
When to use it

When this loop fits

  • You turned on a stricter lint config and now have hundreds of warnings to burn down.
  • A legacy directory was excluded from linting and you want to bring it back in.
  • You want lint fixes grouped by rule so reviewers can check one kind of change at a time.
How it works

What happens on each pass

The agent repeats these steps until the stop condition holds or it runs out of iterations.

  1. Run the linter. Run the lint command with machine-readable output and count violations by rule.
  2. Apply safe autofixes. Run the linter's own autofix once, then re-run the tests to confirm nothing changed behavior.
  3. Fix one rule at a time. Pick the rule with the most remaining violations and fix every instance by hand.
  4. Verify. Run the tests and the linter again and record the new totals.
Recommended servers

MCP servers for this loop

The 6 strongest of 842 matching servers, ranked by how closely they fit and then by trust score.

More in Developer tools
  • Trust score 66 of 100, Good

    mcp-lint

    by robert19001-cmyk · TypeScript

    Lint MCP tool schemas for eight clients and score recovery.

    Registry
    LicenseQualityMaintenanceLicense: A. MIT is a permissive open source license.Quality: Not graded. No README or tool list has been captured yet.Maintenance: D. Last commit or release 6 months ago.
    1 stars—/wk weekly downloads— tools
  • Trust score 55 of 100, Fair

    Markdown linter, workspace-scoped stdio MCP server, and self-hosted text-only remote MCP server.

    Registry
    LicenseQualityMaintenanceLicense: Not graded. No license is recorded for this server.Quality: Not graded. No README or tool list has been captured yet.Maintenance: Not graded. No commit or release date has been recorded.
    — stars—/wk weekly downloads— tools
  • Trust score 55 of 100, Fair

    Ruff Python linting for AI agents, pay-per-call via x402 ($0.005 USDC on Base).

    Registry
    LicenseQualityMaintenanceLicense: Not graded. No license is recorded for this server.Quality: Not graded. No README or tool list has been captured yet.Maintenance: Not graded. No commit or release date has been recorded.
    — stars—/wk weekly downloads— tools
  • Trust score 52 of 100, Fair

    Lint Dockerfiles for root users, latest tags, secrets in ENV or ARG, missing HEALTHCHECK and more.

    Registry
    LicenseQualityMaintenanceLicense: Not graded. No license is recorded for this server.Quality: Not graded. No README or tool list has been captured yet.Maintenance: Not graded. No commit or release date has been recorded.
    — stars—/wk weekly downloads— tools
  • Trust score 52 of 100, Fair

    DraftCheck: flags AI-writing patterns in prose with fix hints. Deterministic linter, not a detector.

    RegistryRemote
    LicenseQualityMaintenanceLicense: Not graded. No license is recorded for this server.Quality: C. 65/100 for listing completeness. Lost points: no listed tools, short summary.Maintenance: Not graded. No commit or release date has been recorded.
    — stars—/wk weekly downloads— tools
Run it

How to run this loop

  1. Connect the tools. Install a server the loop can use, for example mcp-lint, or rely on your agent's built-in terminal and file access.
  2. Edit the settings block. Replace the example commands, targets, and limits with your project's own. Keep the iteration cap low on the first run.
  3. Paste it into an agent session. Start a fresh session in Claude Code, Cursor, or VS Code agent mode, in the repository root, and paste the prompt.
  4. Review before you merge. Read the final report and the diff. The loop leaves its work for you to review rather than shipping it.
FAQ

Lint Until Clean questions

When does the Lint Until Clean loop stop?

It stops as soon as the linter reports zero errors and zero warnings for the chosen scope. It also stops after 10 iterations by default, or earlier when the prompt's own stop rules say it is stuck, and then reports what changed and what is left. Change the cap in the settings block at the top of the prompt.

Why does the prompt ban eslint-disable comments?

Disable comments are the fastest way for an agent to reach zero, and they leave every problem in place. Banning them forces real fixes. If a rule genuinely does not fit your code, the loop stops and flags it so a person can change the config deliberately.

Does this loop work with linters other than ESLint?

Yes. Swap the commands for Ruff, Pylint, RuboCop, golangci-lint, Clippy, or any linter that can report violations by rule. Machine-readable output such as JSON makes the per-rule counts more reliable.

Keep exploring
All loops