Aider Guide
pip install aider-chat # or: uv tool install aider-chat # Set API key: export ANTHROPIC_API_KEY=sk-ant-... export OPENAI_API_KEY=sk-...
Aider is an AI coding assistant that runs in your terminal. Unlike generic chat UIs, Aider understands your git repo — it reads files context, suggests changes, and applies them directly to your code with proper git commits. It's like having a senior dev who never gets tired.
Aider supports multiple LLM backends: Claude 3.5 Sonnet (best for coding), GPT-4o, DeepSeek Coder, and local models via Ollama. It auto-commits before each change so you can always `git diff HEAD~1` or undo with `git reset`.
The `/add` command tells Aider which files to consider. The `/read-only` command adds files for context without allowing edits. Use `--model` to switch backends. Aider's "architect" mode has one model plan and another implement. GUI: Continue.dev (VS Code), Cursor (IDE) for editor-integrated AI.
Setup
aider --model claude-sonnet-4-20250514 # Or set env: export ANTHROPIC_API_KEY=sk-ant-... aider --model claude-sonnet-4-20250514 # With GPT-4o: export OPENAI_API_KEY=sk-... aider --model gpt-4o
Basic Chat
# Aider will: # 1. Read the added files # 2. Edit them with your changes # 3. Git commit with a descriptive message # Example prompts: "Add error handling to the file upload function" "Refactor this into a class with type hints" "Add unit tests for the UserService" "Fix the off-by-one bug in the pagination"
File Management
# In chat: /add src/main.py /add src/utils/*.py # Make files read-only (context only): /read-only src/config.py # Or from CLI launch: aider src/main.py src/utils/*.py
Git Integration
/undo # Undo the last AI change /git diff # See what changed /git commit -m "fix: actually fix it" /git diff HEAD~1 # Review last commit # Aider auto-commits every change with: # "aider: <description of change>"
/commit # Commit any uncommitted changes /diff # Show diff of pending changes /run pytest # Run tests and show results # Aider uses the repo's git history to # understand context and make better edits
Models
aider --model ollama/llama3.2 \ --ollama-base-url http://localhost:11434 # Best local coding models: aider --model ollama/qwen2.5-coder:7b # or: aider --model ollama/deepseek-coder:6.7b # For weaker models, add --weak-model flag
Tricks
aider --model claude-sonnet-4-20250514 \ --editor-model gpt-4o # One model plans (architect) # Another implements (editor) # Or use Aider with --architect flag: aider --architect --model claude-sonnet-4-20250514
aider --voice # Uses microphone # Requires: python -m pip install pyaudio # Speaks: "Add a function to calculate fibonacci" # Aider hears, transcribes, and implements
aider --lint # Lint repo and fix issues # Or during session: /lint # Lint current files aider --test # Run tests and fix failures aider --test-cmd "npm test" # Custom test command