Aider: The AI Pair Programmer That Lives in Your Terminal
Photo by Growtika on Unsplash
Every developer has tried AI coding assistants inside their IDE — but what if your AI pair programmer could work directly with your codebase from the command line, with full context awareness, git integration, and support for the best frontier models? That’s exactly what Aider does, and it’s quietly become one of the most powerful coding tools for developers who prefer the terminal.
What is Aider?
Aider is an open-source AI pair programming tool that runs in your terminal. It connects to AI models (Claude, GPT-4, Gemini, local models via Ollama) and lets you have a conversation about your code — editing files, running tests, and committing changes automatically.
Key capabilities:
- Works with your entire codebase as context
- Automatic git commits for every AI change
- Supports Claude Sonnet/Opus, GPT-4o, Gemini 2.0, and local models
- Multi-file editing — ask it to refactor across dozens of files
- Linter/test integration — automatically fix failures
- Voice input support
- Completely open source (Apache 2.0)
Why Aider vs. Cursor/Copilot?
| Aspect | Aider | Cursor | GitHub Copilot |
|---|---|---|---|
| Interface | Terminal | IDE (VS Code fork) | IDE Plugin |
| Model choice | Any | Limited | OpenAI only |
| Git integration | Built-in auto-commit | Manual | Manual |
| Cost | API cost only | $20/mo | $10/mo |
| Context window | Full repo map | Active files | Active file |
| Open source | ✅ | ❌ | ❌ |
| Offline/local models | ✅ (Ollama) | ✅ | ❌ |
The big win for Aider: model flexibility and git workflow automation.
Installation
# Via pip (Python 3.10+)
pip install aider-chat
# Via pipx (recommended — isolated environment)
pipx install aider-chat
# Check version
aider --version
Configuration
Set up your API keys:
# Add to ~/.bashrc or ~/.zshrc
export ANTHROPIC_API_KEY=your_key_here
export OPENAI_API_KEY=your_key_here
# Or create ~/.aider.conf.yml
model: claude-sonnet-4-5
auto-commits: true
dark-mode: true
First Session
Navigate to your project and launch:
cd my-project
aider # Uses default model (Claude Sonnet)
aider --model gpt-4o # Specify model
aider src/main.py app.py # Open with specific files in context
You’ll see:
Aider v0.55.0
Model: claude-sonnet-4-5
Git repo: .git
Repo-map: using 4096 tokens
Added src/main.py to the chat.
> █
Core Commands
In-Chat Commands
/add <file> - Add file to context
/drop <file> - Remove file from context
/ls - List files in context
/diff - Show recent git diff
/undo - Undo last commit
/run <command> - Run shell command
/ask <question> - Ask without making changes
/model <name> - Switch AI model mid-session
/voice - Toggle voice input
/exit - Quit Aider
Aider in Action — Example Prompts
Add a feature:
> Add user authentication to the FastAPI app using JWT tokens.
Include login, logout, and a protected /me endpoint.
Refactor:
> Refactor the database.py module to use async SQLAlchemy.
Keep all existing tests passing.
Fix a bug:
> The tests in test_api.py are failing because the response
schema changed. Update the tests to match the current schema.
Explain and improve:
> /ask What does the process_payment function do and why
is it using a synchronous lock?
Photo by Safar Safarov on Unsplash
The Repo Map Feature
One of Aider’s most powerful features is its repo map — a compressed representation of your entire codebase’s structure that fits within the model’s context window.
Aider analyzes:
- Function and class signatures across all files
- Import relationships and module structure
- File hierarchy and naming patterns
This lets the AI understand your project architecture even when only a few files are actively in context. Ask it to:
> Add a new API endpoint that follows the same pattern as
the existing endpoints in routes/users.py
Aider will examine the repo map, identify the pattern, and apply it correctly — even if it hasn’t read every file.
Git Integration
Every change Aider makes is automatically committed with a descriptive message:
$ git log --oneline
a8f3c21 feat: add JWT authentication with login/logout endpoints
3d912b4 refactor: convert database.py to async SQLAlchemy
8e1f0ab fix: update test assertions to match new response schema
Benefits:
- Complete audit trail — see exactly what the AI changed
- Easy rollback with
/undoorgit revert - Clean commit history for code review
- Works seamlessly with your existing git workflow
Supported Models & Performance
Aider benchmarks models on real coding tasks. Current top performers:
| Model | SWE-bench Score | Best Use Case |
|---|---|---|
| Claude Opus 4 | ~55% | Complex architecture work |
| Claude Sonnet 4.5 | ~47% | Daily development (best value) |
| GPT-4o | ~40% | Good all-rounder |
| Gemini 2.0 Pro | ~38% | Long context tasks |
| Mistral Large 2 | ~33% | Budget option |
| Llama 3.1 70B (local) | ~25% | Privacy-sensitive code |
Recommended setup for most developers:
aider --model claude-sonnet-4-5
Advanced Workflows
Automated Test-Driven Development
# Start with a test file
aider tests/test_new_feature.py
# Ask Aider to make the tests pass
> Write the implementation in src/feature.py
to make all tests in test_new_feature.py pass
Aider will iteratively write code, run the tests, and fix failures until all tests pass.
Multi-File Refactoring
aider --model claude-opus-4 \
src/models/ src/services/ src/api/ tests/
> Rename the 'User' model to 'Account' everywhere.
Update all imports, references, and database migrations.
Code Review Mode
# Use /ask to get reviews without making changes
> /ask Review this authentication flow for security vulnerabilities
> /ask What are the performance implications of this database query?
> /ask Does this code follow Python best practices?
CI/CD Integration
Run Aider non-interactively in scripts:
aider --yes --message "Fix all linting errors in src/" \
--model claude-sonnet-4-5 \
src/*.py
Pricing Estimate
Aider uses AI model APIs directly — you pay only for tokens consumed:
| Task | Approximate Cost |
|---|---|
| Single file edit | $0.01 - $0.05 |
| Multi-file refactor | $0.10 - $0.50 |
| Full feature implementation | $0.50 - $2.00 |
| Daily developer usage | $5 - $20/month |
Compare: Cursor Pro ($20/mo) or GitHub Copilot ($10/mo) with model restrictions.
Tips for Effective Aider Use
- Be specific about scope: Mention exact files and functions to avoid unintended changes
- Use
/askliberally: Get explanations before committing to changes - Start small: Build confidence with single-file tasks before multi-file refactors
- Review diffs: Always check
/diffbefore moving on .aiderignore: Create this file (like.gitignore) to exclude files from context- Use voice input:
aider --voicefor hands-free coding sessions
Final Verdict
Aider is the AI coding tool for developers who want power, flexibility, and transparency. Its terminal-first approach, automatic git commits, full repo context, and support for any frontier model make it uniquely capable. The learning curve is slightly higher than point-and-click IDE tools, but the payoff is enormous — especially for complex, multi-file refactoring tasks.
Who should use Aider:
- Experienced developers comfortable in the terminal
- Teams that want AI changes tracked in git automatically
- Developers who want to use Claude/GPT-4/Gemini without IDE lock-in
- Anyone working on large codebases needing repo-wide changes
Rating: 4.5 / 5 ⭐⭐⭐⭐½
Get started: pip install aider-chat and visit aider.chat for full docs.