GUIDES Apr 24, 2026 9 min read

Aider Terminal Setup Guide: Install and Configure AI Pair Programming in Your CLI

TL;DR Aider is an open-source AI pair programmer that runs entirely in your terminal — bring your own API key. Install via pip or pipx, set an API key environment…

by Bugi 9 min
TL;DR

  • Aider is an open-source AI pair programmer that runs entirely in your terminal — bring your own API key.
  • Install via pip or pipx, set an API key environment variable, and run aider in any git repo.
  • Supports Claude, GPT-4o, Gemini, and local models out of the box.

Overview

Aider is a command-line AI coding assistant that edits files directly in your local repository. Unlike IDE-based tools, it operates entirely within the terminal — you describe what you want in natural language, and Aider proposes and applies code changes across multiple files.

It works with any LLM that exposes a chat API: OpenAI, Anthropic, Google, or local models via Ollama. Because it integrates with git, every change Aider makes is automatically committed with a descriptive message, giving you a clean undo path.

This guide covers installation on macOS, Linux, and Windows, API key configuration, first-run usage, and practical tips for getting productive fast.

Aider · quick reference
Vendor
Paul Gauthier (open source)
Latest version
0.7x.x
Pricing
Free (bring your own API key)
Platforms
macOS · Linux · Windows
License
Apache 2.0

Prerequisites

Before installing Aider, make sure you have these in place:

  • Python 3.9+ — Aider is a Python package. Run python --version to check.
  • Git — Aider creates commits automatically. It expects to run inside a git repository.
  • An API key — from at least one LLM provider (OpenAI, Anthropic, Google, etc.). Local models via Ollama work too, but are slower for complex edits.
  • A terminal emulator — any standard terminal works. On Windows, use PowerShell or Windows Terminal rather than the legacy Command Prompt for best results.
Note
Aider itself is free. You pay only for the API tokens consumed by whatever model you connect.

Step 1: Install Aider

The recommended installation method is pipx, which installs Aider in an isolated Python environment and avoids dependency conflicts with your other projects.

1
Install pipx (if needed)
pipx manages isolated Python CLI tools.
2
Install Aider
One command, all dependencies handled.
3
Verify the installation
Confirm Aider runs and prints its version.

macOS / Linux:

# Install pipx if you don't have it
python -m pip install pipx
python -m pipx ensurepath

# Install Aider
pipx install aider-chat

# Verify
aider --version

Windows (PowerShell):

# Install pipx
python -m pip install pipx
python -m pipx ensurepath

# Restart your terminal, then:
pipx install aider-chat

# Verify
aider --version

Alternative — plain pip:

pip install aider-chat

This works but risks dependency collisions in shared Python environments. Prefer pipx for a clean setup.

Tip
On macOS, you can also install via Homebrew: brew install aider.

Step 2: Configure Your API Key

Aider needs an API key to communicate with an LLM. The simplest approach is setting an environment variable.

For Anthropic (Claude):

export ANTHROPIC_API_KEY=sk-ant-your-key-here

For OpenAI:

export OPENAI_API_KEY=sk-your-key-here

For Google Gemini:

export GEMINI_API_KEY=your-key-here

To persist the key across terminal sessions, add the export line to your shell profile:

# For bash
echo 'export ANTHROPIC_API_KEY=sk-ant-your-key-here' >> ~/.bashrc

# For zsh (default on macOS)
echo 'export ANTHROPIC_API_KEY=sk-ant-your-key-here' >> ~/.zshrc

Alternatively, create a .env file in your project root:

ANTHROPIC_API_KEY=sk-ant-your-key-here

Aider reads .env automatically. Add .env to your .gitignore to keep your key out of version control.

Warning
Never commit API keys to git. Add .env to .gitignore immediately if you use a dotenv file.

Step 3: Run Aider in a Project

Navigate to any git repository and launch Aider:

cd /path/to/your/project
aider

That’s it. Aider scans the repo, and you get an interactive prompt where you type natural language instructions. It decides which files to edit, shows you a diff, and commits the changes.

Specifying files explicitly:

aider src/app.py src/utils.py

This limits Aider’s context to just those files, which reduces token usage and keeps the model focused.

Choosing a model:

# Use Claude Sonnet
aider --model sonnet

# Use GPT-4o
aider --model gpt-4o

# Use a specific Anthropic model
aider --model claude-sonnet-4-20250514

~/my-project

$ aider --model sonnet
Aider v0.7x.x
Model: claude-sonnet-4-20250514 with diff edit format
Git repo: .git with 47 files
Repo-map: using 1024 tokens
> Add a health check endpoint to app.py
Applied edit to src/app.py
 Commit abcd123: feat: add /health endpoint

Step 4: Essential Commands Inside Aider

Once you’re in the Aider prompt, these commands give you control over the session:

Command What it does
/add <file> Add a file to the chat context
/drop <file> Remove a file from context
/ls List files currently in context
/diff Show the last diff Aider applied
/undo Undo the last git commit Aider made
/model <name> Switch to a different model mid-session
/tokens Show current token usage
/help List all available commands
/exit or Ctrl + D Quit Aider

The /undo command is particularly useful. Because Aider auto-commits each change, undoing is always one command away.

Takeaway

Use /add and /drop to control context size — smaller context means lower cost and more focused edits.

Step 5: Create a Configuration File

For project-specific defaults, create a .aider.conf.yml file in your repository root:

# .aider.conf.yml
model: sonnet
auto-commits: true
dark-mode: true
gitignore: true

You can also set user-wide defaults at ~/.aider.conf.yml. Project-level config overrides user-level config.

Common configuration options:

# Model and provider
model: sonnet
# Edit format: diff, whole, udiff
edit-format: diff
# Disable auto-commits if you prefer manual control
auto-commits: false
# Enable pretty, colored output
pretty: true
stream: true
# Map repository structure (helps the model navigate large codebases)
map-tokens: 1024
Tip
Run aider --help to see every flag. Any CLI flag can go in the YAML config without the -- prefix.

Step 6: Use Aider With Local Models (Optional)

If you want to avoid API costs entirely, Aider works with local models via Ollama or any OpenAI-compatible endpoint.

# Install Ollama (macOS/Linux)
curl -fsSL https://ollama.com/install.sh | sh

# Pull a coding model
ollama pull deepseek-coder-v2

# Run Aider with the local model
aider --model ollama/deepseek-coder-v2

Local models are slower and less accurate than cloud models for complex multi-file edits, but they work offline and cost nothing beyond electricity. Good for prototyping and simple edits.

Tips and Best Practices

1. Keep context small. Only /add the files Aider actually needs to edit. Dumping your entire codebase into context wastes tokens and confuses the model.

2. Write specific prompts. “Fix the bug” is vague. “The /users endpoint returns 500 when the email field is missing — add validation and return a 422″ gives Aider something concrete to work with.

3. Use /undo freely. Aider commits every change. If a result is wrong, /undo it and rephrase your request. This is faster than trying to manually revert partial edits.

4. Pair it with git branches. Start a feature branch before an Aider session. If the session goes sideways, you can reset the entire branch without affecting main.

5. Check your token usage. Run /tokens periodically. Large repositories with many files in context can burn through API credits fast, especially with Opus-class models.

How much does Aider cost to use?
Aider itself is free and open source. You pay only for the LLM API tokens you consume. Costs depend on the model — Claude Sonnet is significantly cheaper per token than Claude Opus, for example. A typical coding session uses $0.05–$2.00 in API credits depending on context size and number of edits.
Can Aider work without an internet connection?
Yes, if you use a local model via Ollama or another local inference server. Cloud-based models (OpenAI, Anthropic, Google) require an internet connection. Run aider --model ollama/deepseek-coder-v2 for fully offline operation.
Does Aider modify files automatically or ask first?
Aider shows you the proposed diff before applying changes, but it applies and commits them in a single step by default. You can undo any change instantly with the /undo command. To require manual approval, disable auto-commits with --no-auto-commits.
Which LLM model works best with Aider?
Aider regularly benchmarks models on its coding leaderboard. As of early 2026, Claude Sonnet and GPT-4o offer the best balance of quality and cost. Claude Opus produces the highest quality edits but costs more. For budget-conscious use, Claude Haiku or local models work for simpler tasks.
Can I use Aider in a project that doesn’t use git?
Aider requires a git repository. If your project isn’t tracked by git, run git init before starting Aider. The git integration is core to how Aider tracks and undoes changes — it’s not optional.
How is Aider different from GitHub Copilot or Cursor?
Aider runs in the terminal, not in an IDE. It edits files directly rather than offering inline suggestions. It works with any editor setup and any LLM provider. The tradeoff: no visual IDE integration, but full control over which model you use and no subscription fee beyond API costs.
Does Aider support monorepos or large codebases?
Yes. Aider uses a “repo map” to understand project structure without loading every file into context. Control the map size with --map-tokens. For large repos, explicitly /add only the files relevant to your task rather than relying on automatic file discovery.
How much does Aider cost to use?
Aider itself is free and open source. You pay only for the LLM API tokens you consume. Costs depend on the model — Claude Sonnet is significantly cheaper per token than Claude Opus, for example. A typical coding session uses $0.05–$2.00 in API credits depending on context size and number of edits.
Can Aider work without an internet connection?
Yes, if you use a local model via Ollama or another local inference server. Cloud-based models (OpenAI, Anthropic, Google) require an internet connection. Run aider –model ollama/deepseek-coder-v2 for fully offline operation.
Does Aider modify files automatically or ask first?
Aider shows you the proposed diff before applying changes, but it applies and commits them in a single step by default. You can undo any change instantly with the /undo command. To require manual approval, disable auto-commits with –no-auto-commits.
Which LLM model works best with Aider?
Aider regularly benchmarks models on its coding leaderboard. As of early 2026, Claude Sonnet and GPT-4o offer the best balance of quality and cost. Claude Opus produces the highest quality edits but costs more. For budget-conscious use, Claude Haiku or local models work for simpler tasks.
Can I use Aider in a project that doesn’t use git?
Aider requires a git repository. If your project isn’t tracked by git, run git init before starting Aider. The git integration is core to how Aider tracks and undoes changes — it’s not optional.
How is Aider different from GitHub Copilot or Cursor?
Aider runs in the terminal, not in an IDE. It edits files directly rather than offering inline suggestions. It works with any editor setup and any LLM provider. The tradeoff: no visual IDE integration, but full control over which model you use and no subscription fee beyond API costs.
Does Aider support monorepos or large codebases?
Yes. Aider uses a repo map to understand project structure without loading every file into context. Control the map size with –map-tokens. For large repos, explicitly /add only the files relevant to your task rather than relying on automatic file discovery.