Linting and testing

Aider can automatically lint and test your code every time it makes changes. This helps identify and repair any problems introduced by the AI edits.

Linting

Aider comes with built in linters for most popular languages and will automatically lint code in these languages.

Or you can specify your favorite linter with the --lint-cmd <cmd> switch. The lint command should accept the filenames of the files to lint. If there are linting errors, aider expects the command to print them on stdout/stderr and return a non-zero exit code. This is how most linters normally operate.

By default, aider will lint any files which it edits. You can disable this with the --no-auto-lint switch.

Testing

You can configure aider to run your test suite after each time the AI edits your code using the --test-cmd <cmd> switch.

Aider will run the test command without any arguments. If there are test errors, aider expects the command to print them on stdout/stderr and return a non-zero exit code. This is how most test tools normally operate.

To have aider automatically run the test command, use the --auto-test switch.

Compiled languages

If you want to have aider compile code after each edit, you can use the lint and test commands to achieve this.

  • You might want to recompile each file which was modified to check for compile errors. To do this, provide a --lint-cmd which both lints and compiles the file. You could create a small shell script for this.
  • You might want to rebuild the entire project after files are edited to check for build errors. To do this, provide a --test-cmd which both builds and tests the project. You could create a small shell script for this. Or you may be able to do something as simple as --test-cmd "dotnet build && dotnet test".

Manually running code

You can use the /run command in the chat to run your code and optionally share the output with aider. This can be useful to share error messages or to show aider the code’s output before asking for changes or corrections.

Aider v0.43.5-dev

/run python myscript.py

Traceback (most recent call last):  
 File "myscript.py", line 22, in \<module\ 
   raise ValueError("something bad happened")  
ValueError: something bad happened  

Add the output to the chat? y