Aider is an open-source AI pair programmer that runs in your terminal and makes changes directly to your code files. Unlike Cursor (an IDE) or GitHub Copilot (a code completion plugin), Aider is a command-line tool that works with any editor — you describe changes in plain English, and Aider edits your files and commits to Git. It’s particularly powerful for refactoring, implementing features, and working across multiple files simultaneously.
Why Aider?
- Any editor: Work in Neovim, VS Code, Emacs, or any editor — Aider edits files directly
- Git-native: Automatically commits changes with descriptive messages
- Multiple files: Understands and edits across your entire codebase
- Any LLM: Supports Claude (Anthropic), GPT-4o (OpenAI), Gemini, local Ollama models, and more
- Open source: No subscription required beyond LLM API costs
Installation
# Install via pip
pip install aider-chat --break-system-packages
# Or via uv (faster)
uv tool install aider-chat
# Verify installation
aider --version
API Key Setup
Aider requires an LLM API key. Get one from:
- Anthropic (Claude): console.anthropic.com
- OpenAI (GPT-4o): platform.openai.com
- Google (Gemini): aistudio.google.com
# Set environment variable (add to ~/.bashrc for persistence)
export ANTHROPIC_API_KEY=sk-ant-YOUR_KEY
export OPENAI_API_KEY=sk-YOUR_KEY
Or create ~/.aider.conf.yml:
anthropic-api-key: sk-ant-YOUR_KEY
model: claude-opus-4-5
Basic Usage
Navigate to your Git repository and launch Aider:
cd /path/to/your/project
aider
Aider starts a chat interface in your terminal. You describe what you want in plain English.
Adding Files to Context
By default, Aider doesn’t include any files. Add files to the context:
# Add specific files
aider src/main.py tests/test_main.py
# Add all Python files in current directory
aider *.py
# In the chat, add files dynamically
> /add src/utils.py
Making Your First Change
> Add error handling to the main() function in main.py — catch ValueError and log it
Aider will:
- Read the file(s)
- Generate the change
- Show a diff
- Ask for confirmation
- Apply the change and git commit
Powerful Commands
/ask — Ask Questions Without Making Changes
/ask What does the authentication middleware do?
/ask Are there any security issues in the login function?
/ask How is the database connection managed across modules?
Use /ask for understanding code without triggering edits.
/run — Execute Shell Commands
/run python -m pytest tests/
/run npm test
/run cargo build
Aider sees the output and can fix errors it finds.
/git — Git Operations
/git log --oneline -10
/git diff HEAD~1
/git status
/drop — Remove Files from Context
When the context gets too large, remove files you’re done with:
/drop src/old_module.py
/clear — Clear Chat History
Reduces token usage for long sessions:
/clear
/undo — Revert Last Change
/undo
Undoes the last git commit made by Aider.
Choosing the Right Model
Aider works with multiple models — choose based on task:
# Claude Sonnet 4.5 — best balance of capability and cost
aider --model claude-sonnet-4-5
# GPT-4o — strong alternative
aider --model gpt-4o
# Local model via Ollama — free, private (requires Ollama running)
aider --model ollama/codellama:70b
For large codebases: Claude models with 200K context windows handle more code simultaneously.
For budget use: Use claude-haiku-4-5 for simple tasks, claude-sonnet-4-5 for complex ones.
Practical Workflows
Feature Implementation
> Implement a rate limiter middleware for the Express routes — limit to 100 requests per 15 minutes per IP, return 429 status when exceeded
Aider will implement the feature, potentially across multiple files, and commit each logical change separately.
Bug Fixing
/run python app.py
[... paste error output ...]
> Fix this error
Aider reads the error, identifies the cause, and applies a fix.
Refactoring
> Refactor the database module to use connection pooling instead of creating a new connection per query. Use the existing psycopg2 package.
Writing Tests
> Write pytest unit tests for the UserAuthentication class in auth.py, covering login success, wrong password, and locked account scenarios
Code Review
/ask Review the security of the file upload handler in upload.py — look for path traversal, file type validation, and size limits
Aider in CI/CD
Aider can run non-interactively in scripts:
# Apply a change non-interactively
echo "Add type hints to all function signatures in utils.py" | aider --yes --model claude-sonnet-4-5 utils.py
--yes automatically accepts all changes without confirmation prompts.
Token and Cost Management
Aider shows token usage after each interaction. Monitor costs:
# Start with cost tracking
aider --show-model-warnings
# Use cheap models for exploration
aider --model claude-haiku-4-5 # Much cheaper than Sonnet/Opus
# Limit context with /drop when done with files
Typical session costs with Claude Sonnet:
- Small refactoring (few files): $0.05-0.15
- Implementing a feature (5-10 files): $0.20-0.60
- Large refactor (20+ files): $1-3
Aider is one of the most capable AI coding tools available — combining the power of frontier LLMs with direct Git integration and terminal-first workflow makes it uniquely effective for developers who prefer the command line.