Skip to main content

Command Palette

Search for a command to run...

Aider: a Real Aid

Published
•3 min read•View as Markdown

I'm no fan of the GitHub Copilot IDE extension. Talking to the model through a chat interface felt slow and cumbersome. I couldn't figure out how to configure and automate it, or use it effectively in TDD. However, Copilot does offer a range of powerful models at an attractive price.

Meet Aider: the CLI Pair Programmer

Aider is a commandline-based AI assistant written in Python that can connect to pretty much any model you care to name, including Copilot's API. The assistant is very configurable, switching context and modes in-chat is intuitive, and its agentic behaviour is well thought out.

If you write tests and want an assistant to take care of the code, this one is for you.

Test-Driven, AI-Assisted Development

My TDAID workflow looks like this:

  1. Create a feature branch
  2. Write a test list
  3. While items remain on the test list:
    1. Write a failing test
    2. Add the prod code file(s) that will need to be changed to Aider's context
    3. Tell Aider to iterate: run tests, read output, edit prod code, repeat
    4. Once all tests are passing, Aider creates a commit on the feature branch
    5. I can review the changes and either refactor myself or get the model to do it
    6. Occasionally ask Aider to suggest entries for the test list
  4. Interactive rebase then merge

There's plenty of work I'm still doing myself. In particular writing the test list and the actual tests is something I want to maintain full control over. I also make sure to add the test list and prod files to Aider's context, but not the test files. Aider builds a map of the entire repo anyway, and by keeping test files out of its context the assistant can never "accidentally" edit or remove tests.

The change → test → verify loop at step 3.3 is made possible by two lines in Aider's configuration:

auto-test: true
dirty-commits: false

This is telling Aider to test after every change, and to not commit until all of its tests are passing.

Slow is Smooth, Smooth is Fast

Learning to work in conjunction with Aider took a little time. There are many things to be aware of both in terms of Aider's own options and in terms of the models that it connects to. However, I found that this initial slowdown was in itself beneficial. It forced me to reflect on what actually needed doing. Being forced to provide concise, focused feedback to the model improves my own understanding. Reading my own test list is much easier for myself after I have taken care to make it as clear as possible for the assistant.

These small benefits, plus the big one of getting the assistant to write your code for you, result in a massively reduced cognitive load when programming.