Auto lint-and-test fix loop with Aider
Added Updated Copyable prompt below
Published Last verified
Our verdict
One of the cheapest reliability wins for a coding agent: Aider lints every file it edits by default and, with --auto-test, runs your test suite after each change, then offers to fix what fails. It stops after 3 fix attempts per message, so a stubborn failure comes back to you instead of looping. The loop is only as good as your checks: a slow or flaky suite makes every edit slow or noisy.
- Who it's for
- Anyone using Aider on a project with tests
- Leverage
- Agent self-corrects against your own checks
- Effort
- Low
- Date added
What Aider's lint-and-test loop does
Aider lints the files it edits after every change, using built-in linters for most popular languages or the command you give with --lint-cmd. With --test-cmd and --auto-test it also runs your test command after each change. If either command exits non-zero, Aider shows the output to the model and asks whether to attempt a fix; with --yes-always it goes straight to the fix. You can also run /lint and /test by hand in the chat, or use aider --test to run the tests, fix what fails and exit.
How builders use Aider's lint-and-test loop
- Put the commands in .aider.conf.yml at the repo root (lint-cmd, test-cmd and auto-test: true) so every session uses them.
- Use a linter that accepts file names, because Aider passes the edited files to your lint command; give per-language commands as "language: cmd".
- Wrap formatters such as pre-commit in a small script that runs them twice, so a reformat on the first pass isn't mistaken for a lint error.
- For compiled languages, make the test command build first, for example --test-cmd "dotnet build && dotnet test".
- Keep the test command fast and scoped to the package you're changing so the loop doesn't stall every edit.
- Share program output such as a stack trace with /run before asking Aider for a fix.
The settings at a glance
From Aider's options reference and YAML config docs, checked 13 Nov 2026. In .aider.conf.yml the key is the flag without its dashes (auto-test: true), and each flag also has an environment variable, such as AIDER_AUTO_TEST.
| Setting | Default and how to change it |
|---|---|
| Lint command | Built-in linters. Set your own with --lint-cmd; Aider passes it the edited files. Repeat it, or use "language: cmd", for several languages |
| Auto-lint | On. Lints every edited file; turn off with --no-auto-lint |
| Test command | None. Set it with --test-cmd; it runs with no extra arguments |
| Auto-test | Off. --auto-test runs the test command after every edit |
| Test and exit | Off. --test runs the tests, fixes problems found, then exits |
How the loop behaves
- After an edit, Aider commits it, lints the edited files, then runs the tests if auto-test is on.
- A failure is any non-zero exit code, and Aider expects the errors on stdout or stderr, which is how most linters and test runners already work.
- Each fix attempt counts as a reflection; after 3 in one message Aider stops with an "Only 3 reflections allowed" warning.
- Fixes are ordinary git commits, so /undo drops a bad one.
Aider's lint-and-test loop: limits and gotchas
- Auto-test is off by default; until you set --test-cmd and --auto-test, only linting runs.
- The 3-attempt cap means hard failures land back with you, so read the last error before you re-prompt.
- Formatters that exit non-zero after changing files look like lint errors unless you wrap them.
- The test command runs after every edit, so a suite that takes minutes makes every change take minutes.
- The model can make tests pass by editing the tests, so review diffs to test files.
- Aider's latest tagged release is v0.86.0 from August 2025 and the last code push was in May 2026, so support for the newest models may lag.
Aider's lint-and-test loop compared with other tools here
- Claude Code hooks: the Claude Code way to get the same guarantee: scripts that run your formatter, linter or tests at set points, every time.
- Aider: the main entry for the tool itself: repo map, switching models per task and /undo.
- Aider conventions file: the other half of a reliable setup: conventions stop style fights, the loop stops broken code.
- Cursor Bugbot: reviews the pull request afterwards; the fix loop catches failures before a commit reaches a PR.
When to pick Aider's lint-and-test loop
- Use this if you run Aider on a project with a linter and tests that finish in seconds.
- Use Claude Code hooks instead if Claude Code is your main agent.
- Add a PR reviewer such as Bugbot on top if several agents or people push to the same repo.
- Leave auto-test off for exploratory sessions on a slow suite, and run /test by hand when you're ready.
Copy this: Command and config
aider --lint-cmd "npx eslint" --test-cmd "npm test" --auto-test
# or once, in .aider.conf.yml at the repo root:
lint-cmd: npx eslint
test-cmd: npm test
auto-test: true
# then in chat:
/add src/lib/pricing.ts src/lib/pricing.test.ts
Fix the rounding bug described in issue #42. Keep tests green.Aider's lint-and-test loop questions
Does Aider lint automatically?
Yes. Auto-lint is on by default and covers every file Aider edits, using built-in linters for popular languages unless you set --lint-cmd. Tests only run automatically once you set --test-cmd and --auto-test.
How many times will Aider try to fix a failure?
Up to 3 fix attempts per message. After that it stops and leaves the failure for you.
Will Aider fix errors without asking?
It asks "Attempt to fix lint errors?" or "Attempt to fix test errors?" first. Run it with --yes-always to accept automatically, for example in scripts.
Can I use a formatter as the linter?
Yes, but formatters often exit non-zero after changing files. Aider's docs suggest a wrapper script that runs the formatter twice, so only real problems fail.
Related discoveries
See the newest picks →- ToolCoding & Shipping Agents
Sphinx: quiz yourself before shipping agent code
MIT Git hook that quizzes you on what your coding agent's change does before a protected push continues.
Effort: MediumPrompt#Plugin / extension#Open source
- ToolCoding & Shipping Agents
Shannon: open-source A.I. pentester for web apps and APIs
Keygraph's AGPL-3.0 A.I. pentester: it reads your web app's source, then attacks a running copy and only reports vulnerabilities it could actually exploit.
Effort: MediumPrompt#Open source#Self-hostable
Get the best new A.I. picks in your inbox
The best new agent workflows and tools we’ve vetted, with a clear verdict on each. Short, occasional, useful.