Heidelberg AICurriculum
Track 13 · Advanced
13.2.7

Aider

Open-source AI pair programmer in your terminal

7 lessons 2026-08-06 AI-generated

1Overview

A terminal-only, open-source pair programmer with no GUI of its own — you point it at files from the command line, and every change lands as its own Git commit.

Aider is a free, open-source command-line tool that turns your terminal into an AI coding session. Point it at one or more files, describe what you want in plain English, and it edits those files and immediately commits the changes to Git with a descriptive message — so every AI change is a clean, reversible commit. It supports 100+ languages and works with Claude, GPT, Gemini, DeepSeek, or a local model. → Requires comfort with the terminal and your own paid LLM API key.

Aider is an open-source AI pair programmer in your terminal. Below: what it's best at, and what to watch for.

1.2After this chapter you can
Point Aider at files and describe a change in plain English
Review every AI edit as its own reversible git commit
Bring your own model — Claude, GPT, Gemini, DeepSeek, or local
1.3Best for

Reversible, auditable changes: every AI edit is its own clean git commit, so you can always roll back one step.

1.4Watch out

It auto-commits every change to Git immediately, with no confirmation prompt — and there's no GUI here, just the terminal.

1.5Free vs paid

Aider itself has no price tag or usage cap — free and MIT-licensed forever. You only ever pay your model provider, and that drops to zero on a local model.

2Lessons 7

2.1 Configure a custom editor for aider

Aider can launch your preferred text editor when you invoke the /editor command.

You will set an environment variable so aider opens VS Code (or another editor) in blocking mode.

  1. Open a terminal and edit your shell profile (e.g., ~/.bashrc or ~/.zshrc).
  2. Add the line export AIDER_EDITOR="code --wait" to the file.
  3. Source the profile (source ~/.bashrc or open a new terminal) to apply the change.
  4. Run aider --editor test.txt in any git‑tracked directory, creating a temporary file named test.txt.
  5. Edit the file in VS Code and close the window.
  • You'll see The terminal pauses while VS Code is open and resumes after you close the editor, confirming that aider respects the custom editor setting.
  • Takeaway Aider defers to the AIDER_EDITOR environment variable, letting you integrate any blocking‑mode editor into your AI coding workflow.

2.2 Set up Aider in a clean virtual environment

A Python virtual environment isolates Aider’s dependencies, preventing conflicts with other projects.

Install Aider in an isolated environment ready for use from the terminal

  1. Create a new virtual environment with python -m venv aider-env
  2. Activate the environment using source aider‑env/bin/activate on Unix or aider‑env\Scripts\activate on Windows
  3. Upgrade pip inside the environment with pip install --upgrade pip
  4. Install the helper script with python -m pip install aider-install
  5. Run aider-install to set up Aider in its own clean Python environment
  • You'll see The terminal reports that Aider has been installed and shows the path to the newly created helper executable
  • Takeaway Isolating Aider’s dependencies avoids version clashes with other tools
  • Check Which command creates a dedicated, conflict‑free installation of Aider after you have activated your virtual environment?

2.3 Edit code using natural language

Aider runs inside a Git repository, takes natural‑language prompts and edits files while automatically committing each change.

Make a code change by describing it in plain English and have Aider create a descriptive commit

  1. Navigate to your project directory with cd
  2. Start an editing session for the target file using aider path/to/file.py
  3. Enter a natural‑language instruction such as “rename function process_data to clean_data and update all calls” at the Aider prompt
  4. Confirm the proposed edit by typing y
  • You'll see A new Git commit appears in the log with a Conventional Commits style message and the file reflects the requested modification
  • Takeaway Natural‑language prompts let you treat the terminal as an interactive coding partner while Git provides a safety net for every edit
  • Check What visible evidence indicates that Aider has applied your instruction and recorded it as a commit in the repository?

2.4 Connect aider to an OpenRouter model

OpenRouter is a gateway that provides access to many LLM providers via a single API key.

You will configure aide to use an OpenRouter model for code edits.

  1. Export your OpenRouter API key: export OPENROUTER_API_KEY= (replace with the actual value).
  2. Navigate to a git repository you want to work on (cd /path/to/project).
  3. Run aider --model openrouter/anthropic/claude-3.7-sonnet to start aider with that model.
  4. In the aider prompt, type a natural‑language request such as “Add a function that returns the square of a number.”
  5. Observe the changes applied to your code and the automatic commit.
  • You'll see Aider creates a new commit with a descriptive message generated by the OpenRouter model, showing successful integration.
  • Takeaway By setting the OPENROUTER_API_KEY environment variable and specifying an openrouter model, you can route any supported LLM through OpenRouter without changing aider’s core.

2.5 Refactor controller logic into a service class while keeping a clean commit history

Aider can perform multi‑step refactors, creating separate commits for each logical change.

Extract duplicated controller code into a new service class, update tests, and generate reversible AI‑driven commits

  1. Confirm the project root is a Git repository
  2. Run aider controller.py tests/test_controller.py from the terminal
  3. Prompt Aider to “create a new service class called UserService that holds the duplicated logic from UserController”
  4. Approve each change as Aider adds the class file, modifies the controller and commits with a descriptive message
  5. Ask Aider to “update the tests so they call UserService instead of the old duplicated methods”, then approve the edits and commits
  • You'll see The Git log shows sequential commits adding UserService, updating the controller, and adjusting the tests, with all tests passing
  • Takeaway Breaking complex refactors into discrete AI‑driven steps creates an audit‑friendly history and reduces regression risk
  • Check Which part of the Git log demonstrates that Aider created separate, descriptive commits for each step of the refactor?

2.6 List available models and create a model alias

Aider can enumerate models it can reach and let you assign short aliases for convenience.

You will list all OpenRouter models and define an alias called sonnet that points to Claude 3.7 Sonnet.

  1. Run aider --list-models openrouter/ to display the catalog of available OpenRouter models.
  2. Create a file named .aider.model.settings.yml in your home directory (or project root).
  3. Add the following YAML content: `` - name: sonnet model: openrouter/anthropic/claude-3.7-sonnet ``
  4. Save the file and start aider with aider --model sonnet.
  5. Ask a simple change, e.g., “Rename variable x to count.”
  • You'll see Aider uses the alias sonnet, applies the requested edit, and makes a commit, confirming that the alias resolves to the correct provider model.
  • Takeaway Model aliases let you abstract away long model identifiers, making it easier to switch providers or models across projects.

2.7 Enable automatic linting and testing fixes

Aider can run your project's linters and test suites after each edit, automatically fixing detected issues.

You will configure aider to invoke linting and testing on every AI‑generated change.

  1. Ensure your project has a linter (e.g., flake8) and tests (e.g., pytest) installed.
  2. Create or edit the aide configuration file .aider.yml in the repository root.
  3. Add the lines: `` lint: true run_tests: true ``
  4. Start aider with aider --model openrouter/anthropic/claude-3.7-sonnet.
  5. Ask for a change that introduces a style issue, such as “Add a new function without a docstring.”
  6. After the edit, observe aider running the linter and test suite and automatically fixing the missing docstring.
  • You'll see The terminal shows linting/test output followed by a commit that includes both your requested change and the auto‑fixed style issue, confirming the feature worked.
  • Takeaway Integrating linting and testing into aider’s workflow ensures AI edits keep code quality high without manual intervention.

3You’ll know it worked 7 checkable outcomes in this chapter

  • Controller tests pass and OrderFulfilmentService.rb is added
  • The code snippets in README.md compile against the current API without deprecation errors
  • The resulting DataFrame contains one row per Observation, Condition, and MedicationRequest with a column documenting the source JSONPath for each extracted field
  • Script outputs a list of columns with their mean and standard deviation
  • A file named summary.csv appears containing only columns with data
  • Unit test reports success for mean calculation
  • The code returns to its state before the last `/undo`-ed instruction

4FAQ, Tips & How-to 39

one problem, one solution, one action

Internal tools & ops5

How-to Aider Operations +1

Controller code is tangled with duplicate logic

The refactor is done in a single aider session with a clean git history — reviewable commit by commit — and no test regressions.

~10 min · low code AI-generated
How-to Aider developer

Need a quick summary of every numeric column

Quickly spot data distribution issues without manually inspecting every column.

~10 min · low code AI-generated
How-to Aider developer

My CSV has many blank columns

It eliminates manual column cleanup, delivering a concise output with only meaningful data.

~10 min · low code AI-generated
How-to Aider developer

Column parsing code is duplicated across scripts

Centralizing parsing logic simplifies maintenance and enables reuse across scripts.

~10 min · low code AI-generated
How-to Aider developer

Unsure if my mean calculation is correct

Ensures correctness early and catches regressions automatically.

~10 min · low code AI-generated

Knowledge & docs1

How-to Aider Operations +1

README code samples are broken after an API change

Documentation drift is fixed in minutes; the next person to follow the README gets working code, not a confusing deprecation error.

~10 min · low code AI-generated

Research & data tools1

How-to Aider Physician

Raw FHIR bundles need hand review

A stack of raw FHIR bundles that previously required manual review is turned into one analysis-ready table in a single session, with full field-level traceability back to the source export.

~10 min · low code AI-generated
How-to Aider Everyone

Need to launch AI pair‑programming from the command line

You can launch Aider directly from the terminal to begin editing files with AI

**A real Aider session** in the terminal: you run `aider demo.py`, describe what you want, and Aider edits the file and commits the change to Git. Credit: aider.chat ↗
Aider is **free and open-source (Apache 2.0)** — there is no subscription. You pay only the third-party LLM's token cost for each request (you bring your own key). Lesson → AI-generated
How-to Aider Everyone

Only have an English sentence describing what you want

Aider translates a single English sentence into working Python code

Lesson → AI-generated
How-to Aider Everyone

Want to tweak code through conversation and never lose changes

You can refine code conversationally while each change is safely versioned

Every Aider edit lands as a real Git commit (shown here in Aider's browser UI) — which is exactly what makes `/undo` a clean, safe revert instead of a guess. Credit: aider.chat/docs ↗
Each request is one metered call to your chosen LLM; grouping related changes into one clear message spends fewer tokens. `/undo` is free — it is just a Git revert. Lesson → AI-generated
How-to Aider Everyone

Need to roll back the latest AI edit

You can instantly roll back any unwanted change without losing prior work

Lesson → AI-generated
How-to Aider Everyone

Lint or test failures appear

When a lint or test error appears, Aider reads the output and suggests a corrective change automatically

Still only LLM token cost; the lint and test steps run locally on your machine and add nothing beyond the model calls Aider already makes. Lesson → AI-generated
How-to Aider Everyone

Manually checking the diff and test outcome confirms that each change is safe to continue with

Lesson → AI-generated
How-to Aider Everyone

Not sure the mean calculation is correct

Introducing a focused unit test forces Aider to run the full check cycle, catching errors early

~10 min · low code Lesson → AI-generated
How-to Aider Everyone

The public leaderboard lets you pick a model that balances accuracy and expense for your workload

Aider's own **polyglot benchmark** — 225 Exercism exercises across 6 languages — ranks each model's success rate, so you can pick a cheaper model that still clears the bar for your task. Credit: aider.chat ↗
Aider itself is free and open-source (Apache 2.0) — you pay only your model provider's per-token costs. Aider reports the token count and dollar cost of each interaction in the terminal (use **`/tokens`** to see the running total for the current context), so you can watch spend live regardless of which model you choose. Lesson → AI-generated
How-to Aider Everyone

Aider automatically shows how many tokens and dollars each request consumes, helping you stay within budget

Lesson → AI-generated
How-to Aider Everyone

Edit several source files at once

You can start Aider with multiple source files so it can modify them all in one interactive session

Larger context (more files, the codebase map) means more tokens per request — another reason to pick an economical model from the leaderboard for routine work. Lesson → AI-generated
How-to Aider Everyone

One huge script you can’t reuse

You can ask Aider to move functions or logic from a monolithic script into new module files while updating imports

Lesson → AI-generated
How-to Aider Everyone

Can’t convey what’s on screen

You can give Aider a screenshot so it sees the exact visual reference instead of you describing it

Still just LLM token cost; image and web-page context add to the tokens per request, so keep references focused. Lesson → AI-generated
How-to Aider Everyone

Want to feed a webpage into an AI code helper

Aider can read a web page you supply, letting the model work from the actual page content

Lesson → AI-generated
FAQ Aider Everyone

What is Aider and what is it for?

Aider is an open-source AI pair programmer that runs in your terminal. Instead of a chat box in a browser, you start a session inside your project folder and describe the change you want in plain English; Aider edits the actual files for you and commits each change to Git. It is built for working on real code you own: writing scripts, refactoring across files, adding tests, and fixing bugs. It is not a point-and-click app builder and is less suited to pure writing tasks like reports. The big idea is that you stay in your normal local workflow and keep full control of the code through Git.

Aider ↗ AI-generated
FAQ Aider Everyone

Can I give Aider images, web pages, or use my voice?

Yes. Aider accepts images and web pages as context, so you can hand it a screenshot of a chart or a documentation page and ask it to implement or match what is shown, rather than describing it in words. It also supports voice-to-code, letting you dictate a request instead of typing, which is handy for longer instructions. For documentation you can use the '/read' command to import reference files, or '/paste' to insert clipboard contents including images. Aider supports more than 100 programming languages, including Python, JavaScript, Rust, Go, C++, PHP, HTML and CSS, so the same workflow carries across whatever stack your project uses.

Aider ↗ AI-generated
FAQ Aider Everyone

Is my code private, or does Aider run in the cloud?

Aider runs locally on your own machine and edits files in your local Git repository, so the tool itself is not a cloud service. However, your code is not fully private by default, because Aider sends the relevant parts of your files to whichever LLM provider you choose, such as Anthropic or OpenAI, in order to generate edits. If you need everything to stay on your own hardware, run Aider against a local model through Ollama so no source code leaves your machine. Aider collects anonymous usage analytics to improve the tool, but it is opt-in: a random subset of users are asked to confirm first, and it never includes your code, chat messages, or keys. You can disable it with the --no-analytics flag.

Aider ↗ AI-generated
FAQ Aider Everyone

What are the main limitations or gotchas?

Aider is terminal-only with no graphical interface, so you need basic command-line confidence to get started, and Windows users often want WSL2 for the smoothest experience. Because you pay LLM API costs directly, a heavy session on a frontier model can add up, so it pays to pick an economical model for routine work. Results also depend heavily on model quality: Aider may not work well with weaker models, which can struggle to format code edits correctly. It is a code editor, so it is less useful for pure writing tasks like lab reports or literature reviews. Finally, its safety net relies on Git, so you should work inside a repository to get clean, reversible commits.

Aider ↗ AI-generated
FAQ Aider Everyone

How does Aider compare to Claude Code?

Both are terminal-based AI coding tools that edit files in your project and lean on your Git history, so the workflow feels similar. The key difference is openness and model choice: Aider is fully open-source under Apache 2.0 and is model-agnostic, letting you bring your own key for Claude, GPT, Gemini, DeepSeek, or a free local model via Ollama, with no vendor lock-in. Claude Code is Anthropic's own tool, tightly tuned to Claude models and billed through Anthropic. Choose Aider when you want maximum control, the freedom to switch models for cost or capability, and a transparent open-source tool; choose Claude Code if you specifically want Anthropic's integrated, Claude-optimised experience.

Aider ↗ AI-generated
FAQ Aider Everyone

How much does Aider cost?

Aider itself is completely free and open-source under the Apache 2.0 license, so there is no subscription. What you pay for is the large language model it talks to, because you bring your own API key and are billed per token by that provider at the model's standard per-token rates. You can also run Aider against local models via Ollama for zero token cost. Aider shows the running token count and dollar cost of each change in the terminal so you can watch spend live.

GitHub ↗ AI-generated
FAQ Aider Everyone

How do I install Aider?

If you already have Python 3.8 to 3.13 installed, the recommended path is to run 'python -m pip install aider-install' and then 'aider-install', which sets Aider up in its own isolated environment for you. There are also one-line installers: on Mac and Linux, 'curl -LsSf https://aider.chat/install.sh | sh', and on Windows, 'powershell -ExecutionPolicy ByPass -c "irm https://aider.chat/install.ps1 | iex"'. uv and pipx are supported alternatives. After installing, you run the 'aider' command from inside your project directory. On Windows many users find WSL2 gives the smoothest experience.

Aider ↗ AI-generated
FAQ Aider Everyone

Do I need an API key to start, and which LLMs work with Aider?

Yes. Aider is free software but it needs an LLM to do the actual coding, so you supply an API key from a model provider (or run a local model). It works with most major LLMs, including Anthropic Claude, OpenAI, Google Gemini, DeepSeek, xAI, Azure, Cohere, and OpenAI-compatible endpoints. The docs highlight strong performers like Gemini 2.5 Pro, DeepSeek R1/V3, Claude 3.7 Sonnet, and OpenAI o3, o4-mini and GPT-4.1. You can switch models at launch with the --model flag (for example 'aider --model sonnet'), and Aider can also run against free local models through Ollama when you want no token cost.

Aider ↗ AI-generated
FAQ Aider Everyone

How do I start my first session and get Aider to write code?

Open a terminal in your project folder and run 'aider', optionally naming files you want it to edit, for example 'aider --model sonnet analysis.py'. Aider drops you into a chat prompt. Type your request in plain English, such as 'Read data.csv and print the mean and standard deviation for every numeric column.' Aider writes or edits the file, shows you the diff, and commits the change to Git with a sensible message. You keep the session open and refine conversationally with follow-up requests. If Aider is not already in a Git repository, it offers to create one, since its safety features depend on Git.

Aider ↗ AI-generated
FAQ Aider Everyone

How does Aider use Git, and can I undo a change I do not like?

Every time Aider edits a file, it automatically commits those changes to Git with a descriptive, Conventional Commits style message marked to show the AI was involved. That means every AI edit is its own clean, reversible commit and you always have an audit trail of exactly what changed. If a change is wrong, type '/undo' to cleanly revert that last AI commit, and '/diff' to see all file changes since your last message. Aider works best inside a Git repo and will offer to create one. You can change this behaviour with flags like --no-auto-commits or even --no-git, though disabling Git is not recommended because you lose the easy rollback.

Aider ↗ AI-generated
FAQ Aider Everyone

How do I work across multiple files in a real project?

Launch Aider with several files at once, for example 'aider --model sonnet analysis.py helpers.py', and ask for a change that spans them; Aider edits all of them in one session and commits each coherent step to Git. You do not have to load every file by hand: Aider builds a map of your codebase so the model can reason about how files relate, including callers and definitions it is not directly editing. During a session you can add or remove files with the '/add' and '/drop' commands. A good practice is to keep only the files that actually need editing in the chat, so the model is not overwhelmed by irrelevant code.

Aider ↗ AI-generated
FAQ Aider Everyone

Can Aider lint and test its own code?

Yes. Aider can automatically lint and test code after each change rather than leaving you to discover breakage later. When a lint or test surfaces an error, Aider reads the output and proposes a fix, then commits the corrected version, so both the failing and fixed states are captured in your Git history. You can also drive this manually in-chat: '/test' runs your test command and shares the result, and '/run' executes an arbitrary command and feeds its output back to the model. The lint and test steps run locally on your machine, so they add nothing beyond the model calls Aider already makes. This edit, lint, test, commit loop keeps each change verified rather than just plausible-looking.

Aider ↗ AI-generated
FAQ Aider Everyone

Which model should I pick, and how do I keep costs down?

Aider publishes a public model leaderboard based on its polyglot benchmark, which tests LLMs on 225 challenging Exercism exercises across C++, Go, Java, JavaScript, Python and Rust. The leaderboard reports each model's success rate alongside its cost, so you can deliberately trade accuracy against price. Use a frontier model for hard, multi-file work and a cheaper model for routine edits. To keep spend down, add only the files that need editing, group related requests into one clear message, and watch the live token and dollar counts Aider prints (use '/tokens' for the running total). For zero token cost on routine edits, run a free local model via Ollama.

Aider ↗ AI-generated
How-to Aider Everyone

Need to give an image or voice note as context for code

You can give Aider images, web pages, or voice to provide context for coding tasks

Aider docs: Images and web pages ↗ AI-generated
How-to Aider Everyone

Want a live code‑writing partner in your terminal

Use Aider to write or edit code through natural language chat

~10 min · low code Aider docs: Usage ↗ AI-generated
How-to Aider Everyone

Want separate Git commits for each AI edit

You get clean, reversible commits for every AI change

~10 min · low code Aider docs: Git integration ↗ AI-generated
How-to Aider Everyone

Need to edit several code files at once

Edit and commit changes across several code files in one session

Aider docs: Tips ↗ AI-generated
How-to Aider Everyone

Changes in code trigger automatic linting, testing, and commits

Get continuous verification of code changes without manual testing

~10 min · low code Aider docs: Linting and testing ↗ AI-generated

The same set on /recipes, filtered by tool and role.

5Videos 2

Learn Aider AI Chat
Software from Eduardo Garza ·~20 min ·Apr 2026 Intermediate

The practical follow-along once you know what Aider is. Fresh, dedicated Aider tutorials are scarce, so this is among the most current full walkthroughs.

6FAQ 13

What is Aider and what is it for?

Aider is an open-source AI pair programmer that runs in your terminal. Instead of a chat box in a browser, you start a session inside your project folder and describe the change you want in plain English; Aider edits the actual files for you and commits each change to Git. It is built for working on real code you own: writing scripts, refactoring across files, adding tests, and fixing bugs. It is not a point-and-click app builder and is less suited to pure writing tasks like reports. The big idea is that you stay in your normal local workflow and keep full control of the code through Git.

Can I give Aider images, web pages, or use my voice?

Yes. Aider accepts images and web pages as context, so you can hand it a screenshot of a chart or a documentation page and ask it to implement or match what is shown, rather than describing it in words. It also supports voice-to-code, letting you dictate a request instead of typing, which is handy for longer instructions. For documentation you can use the '/read' command to import reference files, or '/paste' to insert clipboard contents including images. Aider supports more than 100 programming languages, including Python, JavaScript, Rust, Go, C++, PHP, HTML and CSS, so the same workflow carries across whatever stack your project uses.

Is my code private, or does Aider run in the cloud?

Aider runs locally on your own machine and edits files in your local Git repository, so the tool itself is not a cloud service. However, your code is not fully private by default, because Aider sends the relevant parts of your files to whichever LLM provider you choose, such as Anthropic or OpenAI, in order to generate edits. If you need everything to stay on your own hardware, run Aider against a local model through Ollama so no source code leaves your machine. Aider collects anonymous usage analytics to improve the tool, but it is opt-in: a random subset of users are asked to confirm first, and it never includes your code, chat messages, or keys. You can disable it with the --no-analytics flag.

What are the main limitations or gotchas?

Aider is terminal-only with no graphical interface, so you need basic command-line confidence to get started, and Windows users often want WSL2 for the smoothest experience. Because you pay LLM API costs directly, a heavy session on a frontier model can add up, so it pays to pick an economical model for routine work. Results also depend heavily on model quality: Aider may not work well with weaker models, which can struggle to format code edits correctly. It is a code editor, so it is less useful for pure writing tasks like lab reports or literature reviews. Finally, its safety net relies on Git, so you should work inside a repository to get clean, reversible commits.

How does Aider compare to Claude Code?

Both are terminal-based AI coding tools that edit files in your project and lean on your Git history, so the workflow feels similar. The key difference is openness and model choice: Aider is fully open-source under Apache 2.0 and is model-agnostic, letting you bring your own key for Claude, GPT, Gemini, DeepSeek, or a free local model via Ollama, with no vendor lock-in. Claude Code is Anthropic's own tool, tightly tuned to Claude models and billed through Anthropic. Choose Aider when you want maximum control, the freedom to switch models for cost or capability, and a transparent open-source tool; choose Claude Code if you specifically want Anthropic's integrated, Claude-optimised experience.

How much does Aider cost?

Aider itself is completely free and open-source under the Apache 2.0 license, so there is no subscription. What you pay for is the large language model it talks to, because you bring your own API key and are billed per token by that provider at the model's standard per-token rates. You can also run Aider against local models via Ollama for zero token cost. Aider shows the running token count and dollar cost of each change in the terminal so you can watch spend live.

How do I install Aider?

If you already have Python 3.8 to 3.13 installed, the recommended path is to run 'python -m pip install aider-install' and then 'aider-install', which sets Aider up in its own isolated environment for you. There are also one-line installers: on Mac and Linux, 'curl -LsSf https://aider.chat/install.sh | sh', and on Windows, 'powershell -ExecutionPolicy ByPass -c "irm https://aider.chat/install.ps1 | iex"'. uv and pipx are supported alternatives. After installing, you run the 'aider' command from inside your project directory. On Windows many users find WSL2 gives the smoothest experience.

Do I need an API key to start, and which LLMs work with Aider?

Yes. Aider is free software but it needs an LLM to do the actual coding, so you supply an API key from a model provider (or run a local model). It works with most major LLMs, including Anthropic Claude, OpenAI, Google Gemini, DeepSeek, xAI, Azure, Cohere, and OpenAI-compatible endpoints. The docs highlight strong performers like Gemini 2.5 Pro, DeepSeek R1/V3, Claude 3.7 Sonnet, and OpenAI o3, o4-mini and GPT-4.1. You can switch models at launch with the --model flag (for example 'aider --model sonnet'), and Aider can also run against free local models through Ollama when you want no token cost.

How do I start my first session and get Aider to write code?

Open a terminal in your project folder and run 'aider', optionally naming files you want it to edit, for example 'aider --model sonnet analysis.py'. Aider drops you into a chat prompt. Type your request in plain English, such as 'Read data.csv and print the mean and standard deviation for every numeric column.' Aider writes or edits the file, shows you the diff, and commits the change to Git with a sensible message. You keep the session open and refine conversationally with follow-up requests. If Aider is not already in a Git repository, it offers to create one, since its safety features depend on Git.

How does Aider use Git, and can I undo a change I do not like?

Every time Aider edits a file, it automatically commits those changes to Git with a descriptive, Conventional Commits style message marked to show the AI was involved. That means every AI edit is its own clean, reversible commit and you always have an audit trail of exactly what changed. If a change is wrong, type '/undo' to cleanly revert that last AI commit, and '/diff' to see all file changes since your last message. Aider works best inside a Git repo and will offer to create one. You can change this behaviour with flags like --no-auto-commits or even --no-git, though disabling Git is not recommended because you lose the easy rollback.

How do I work across multiple files in a real project?

Launch Aider with several files at once, for example 'aider --model sonnet analysis.py helpers.py', and ask for a change that spans them; Aider edits all of them in one session and commits each coherent step to Git. You do not have to load every file by hand: Aider builds a map of your codebase so the model can reason about how files relate, including callers and definitions it is not directly editing. During a session you can add or remove files with the '/add' and '/drop' commands. A good practice is to keep only the files that actually need editing in the chat, so the model is not overwhelmed by irrelevant code.

Can Aider lint and test its own code?

Yes. Aider can automatically lint and test code after each change rather than leaving you to discover breakage later. When a lint or test surfaces an error, Aider reads the output and proposes a fix, then commits the corrected version, so both the failing and fixed states are captured in your Git history. You can also drive this manually in-chat: '/test' runs your test command and shares the result, and '/run' executes an arbitrary command and feeds its output back to the model. The lint and test steps run locally on your machine, so they add nothing beyond the model calls Aider already makes. This edit, lint, test, commit loop keeps each change verified rather than just plausible-looking.

Which model should I pick, and how do I keep costs down?

Aider publishes a public model leaderboard based on its polyglot benchmark, which tests LLMs on 225 challenging Exercism exercises across C++, Go, Java, JavaScript, Python and Rust. The leaderboard reports each model's success rate alongside its cost, so you can deliberately trade accuracy against price. Use a frontier model for hard, multi-file work and a cheaper model for routine edits. To keep spend down, add only the files that need editing, group related requests into one clear message, and watch the live token and dollar counts Aider prints (use '/tokens' for the running total). For zero token cost on routine edits, run a free local model via Ollama.

7Glossary 6 terms

Show the 6 terms
Aider
--model
An Aider command-line flag that specifies which AI model to use for the main chat session, for example --model claude-3-opus-20240229 to select a specific Claude model.
/undo
An Aider slash command that undoes the last git commit if it was made by Aider, restoring your files to how they were before that change.
/tokens
An Aider slash command that reports how many tokens the current chat context is using, so you can see how much of the model's context window is occupied.
auto-commit
Aider's default behaviour of committing every AI-made change to Git with an auto-written message, so each edit has an audit trail you can undo.
codebase map
An index Aider builds of your project so the model can reason across files (callers, definitions, imports) without you pasting every file in.
--model
The launch flag that sets which LLM Aider uses for the session (e.g. 'aider --model sonnet' or '--model o4-mini'), so you can match model to task.

8See also

💬 Discuss this chapter

Ask, share, or report — over on the Heidelberg AI community forum.