}

Aider: AI Pair Programming from the Terminal — Complete Guide 2026

Aider: AI Pair Programming from the Terminal — Complete Guide 2026

What is Aider?

Aider is an open-source AI coding assistant that runs entirely in your terminal. Unlike Copilot (IDE plugin) or Cursor (separate editor), Aider works with your existing editor and git workflow:

  1. You open your editor and describe what you want
  2. Aider calls Claude or GPT-4o with your code as context
  3. Aider applies the changes directly to your files
  4. Aider creates a git commit automatically

Why terminal over IDE plugin? - Works with any editor (Vim, VS Code, Emacs, Helix) - Full git integration — every AI change is a committed, reviewable diff - Supports local models via Ollama - Scriptable and automatable

Installation

pip install aider-chat

Setup: Connect to Claude (recommended)

export ANTHROPIC_API_KEY="sk-ant-..."
aider --model claude-opus-4-5

Or GPT-4o:

export OPENAI_API_KEY="sk-..."
aider --model gpt-4o

Or local Ollama (free):

aider --model ollama/codellama --no-auto-commits

First Session

cd my-project
aider main.py utils.py  # add specific files to context

Inside the aider prompt:

> add a function that validates email addresses using regex

Aider will: 1. Show you the proposed changes as a diff 2. Ask for confirmation 3. Apply changes and create a git commit

Key Commands

Inside an aider session:

/add filename.py      # add a file to the context
/drop filename.py     # remove a file from context
/files                # list files in context
/git status           # run git command
/run pytest           # run a shell command
/ask what does X do   # ask without modifying files
/help                 # show all commands
/exit                 # quit

From the shell, before starting:

aider --help          # all CLI options
aider --show-diff     # always show diffs before applying
aider --no-auto-commits  # don't auto-commit
aider --read README.md   # add file as read-only context

Architect Mode: Better for Complex Tasks

Architect mode uses two models: one to design the change, another to implement it. This produces better results for complex refactoring:

aider --architect --model claude-opus-4-5 --editor-model claude-haiku-4-5

The architect model (opus) thinks through the approach, the editor model (haiku) implements it cheaply.

Configuration File

Create .aider.conf.yml in your project root:

model: claude-opus-4-5
auto-commits: true
dirty-commits: false
show-diff: true
read:
  - README.md
  - CONVENTIONS.md  # coding conventions for this project
map-tokens: 2048

.aiderignore: Exclude Files

Like .gitignore but for aider:

# .aiderignore
*.pyc
__pycache__/
node_modules/
.env
migrations/

Repo Map: Aider Understands Your Codebase

Aider builds a "repo map" — a compact representation of your entire codebase's structure. Even for files not in context, aider knows: - Function signatures - Class definitions - Module relationships

This is why it can add a function to utils.py that correctly integrates with main.py even if you only opened one file.

Real Workflow Example

# Start a new feature
git checkout -b feature/add-caching
aider app.py cache.py

> add redis caching to the get_user() function with a 5 minute TTL

# Review the diff, confirm
# Aider commits: "feat: add redis caching to get_user()"

> add unit tests for the cache behavior

# Aider commits: "test: add unit tests for get_user cache"

/run pytest tests/

> the test_cache_expiry test is failing, fix it

# Aider reads the test output and fixes the bug

Cost Management

# Use cheaper model for simple tasks
aider --model claude-haiku-4-5  # 60x cheaper than Opus

# Check token usage after session
aider --stats

# Set spending limits in your Anthropic dashboard

Typical cost: 5-10 cents per session for moderate tasks with claude-haiku-4-5.

Scripting Aider

# Apply a change non-interactively
aider --message "add type hints to all functions in utils.py" utils.py

# Pipe from stdin
echo "fix all TODO comments" | aider --message - *.py

Leonardo Lazzaro

Software engineer and technical writer. 10+ years experience in DevOps, Python, and Linux systems.

More articles by Leonardo Lazzaro