aider is AI pair programming in your terminal
Aider is a command line tool that lets you pair program with LLMs, to edit code stored in your local git repository. Aider will directly edit the code in your local source files, and git commit the changes with sensible commit messages. You can start a new project or work with an existing git repo. Aider is unique in that it lets you ask for changes to pre-existing, larger codebases. Aider works well with GPT 3.5, GPT-4o, GPT-4 Turbo with Vision, and Claude 3 Opus. It also supports connecting to almost any LLM.
See the installation instructions for more details, but you can get started quickly like this:
$ pip install aider-chat
# To work with GPT-4o
$ export OPENAI_API_KEY=your-key-goes-here
$ aider
# To work with Claude 3 Opus:
$ export ANTHROPIC_API_KEY=your-key-goes-here
$ aider --opus
Here are some example transcripts that show how you can chat with aider
to write and edit code with GPT-4.
Hello World Flask App: Start from scratch and have aider create a simple Flask app with various endpoints, such as adding two numbers and calculating the Fibonacci sequence.
Javascript Game Modification: Dive into an existing open-source repo, and get aider's help to understand it and make modifications.
Complex Multi-file Change with Debugging: Aider makes a complex code change that is coordinated across multiple source files, and resolves bugs by reviewing error output and doc snippets.
Create a Black Box Test Case: Aider creates a "black box" test case without access to the source of the method being tested, using only a high level map of the repository based on tree-sitter.
You can find more chat transcripts on the examples page.
aider
from the command line with set of source files to discuss and edit together. Aider lets the LLM see and edit the content of those files.Run the aider
tool by executing the following command:
aider <file1> <file2> ...
If your pip install did not place the aider
executable on your path, you can invoke aider like this:
python -m aider.main <file1> <file2>
Replace <file1>
, <file2>
, etc., with the paths to the source code files you want to work on.
These files will be "added to the chat session", so that the LLM can see their contents and edit them according to your instructions.
You can also just launch aider
anywhere in a git repo without naming
files on the command line. It will discover all the files in the
repo. You can then add and remove individual files in the chat
session with the /add
and /drop
chat commands described below.
If you or the LLM mention one of the repo's filenames in the conversation,
aider will ask if you'd like to add it to the chat.
Think about the change you want to make and which files will need to be edited -- add those files to the chat. Don't add all the files in your repo to the chat. Be selective, and just add the files that the LLM will need to edit. If you add a bunch of unrelated files, the LLM can get overwhelmed and confused (and it costs more tokens). Aider will automatically share snippets from other, related files with the LLM so it can understand the rest of your code base.
Aider also has many
additional command-line options, environment variables or configuration file
to set many options. See aider --help
for details.
Aider supports commands from within the chat, which all start with /
. Here are some of the most useful in-chat commands:
/add <file>
: Add matching files to the chat session./drop <file>
: Remove matching files from the chat session./undo
: Undo the last git commit if it was done by aider./diff
: Display the diff of the last aider commit./run <command>
: Run a shell command and optionally add the output to the chat./voice
: Speak to aider to request code changes with your voice./help
: Show help about all commands.See the full command docs for more information.
/run
command to run tests, linters, etc and show the output to the LLM so it can fix any issues.{
alone on the first line to start a multiline message and }
alone on the last line to end it./run
or by pasting it into the chat. Let the LLM figure out and fix the bug.See the installation instructions.
For more information, see the FAQ.