Aider: Terminal AI Coding Assistant That Understands Project Structure and Edits Multiple Files
Aider moves multi-file edits into the terminal: a repo map sends signatures, each edit is a commit, /undo reverts it. Five commands, three flags, five traps.
📜 Table of Contents
📖 Keep reading
Aider tutorial: multi-file edits, repo map and auto git commits in the terminal
Aider is an AI pair programmer that runs in your terminal. Unlike editor autocomplete, it works on the repository: you add files to the chat, the model edits them directly, and every change becomes a git commit you can undo with one command. It fits server-side scripting, cross-file refactors, and adding tests to legacy code.
Before you install
| Requirement | Why | If missing |
|---|---|---|
| A git repo | Commits and undo depend on git | Run git init first |
| A model API | OpenAI, Anthropic, DeepSeek or local Ollama | You lose multi-file editing |
| Clean working tree | Otherwise you cannot tell whose change is whose | Commit or stash first |
pipx install aider-chat
aider --version
Wiring up a model
export DEEPSEEK_API_KEY=sk-xxx
aider --model deepseek/deepseek-chat
For daily use, put it in ~/.aider.conf.yml:
model: deepseek/deepseek-chat
weak-model: ollama/qwen2.5-coder:7b
auto-commits: true
map-tokens: 1024
weak-model handles commit messages and chat summaries; a cheap or local model there keeps costs down. For local models, start Ollama first and use aider --model ollama/qwen2.5-coder:7b, checking exact names with ollama list.
The daily loop
cd project && aiderto start and build the repo map./add src/api.py src/models.py— the model can only edit files in the chat. Do not/add .casually.- Describe the task in plain language.
- Review the diff; it commits automatically.
/undoif wrong. /tokensto check context usage,/clearbefore the next task.
| Command | Purpose |
|---|---|
/add /drop |
Add or remove chat files |
/diff |
Review uncommitted changes |
/undo |
Revert the last commit |
/run |
Run a shell command and feed output back |
/test |
Run your test command |
/ask |
Ask without editing |
/architect |
Plan first, then edit |
What repo map buys you
Repo map is a tree-sitter summary of classes, function signatures and call relationships — signatures only, not full text. --map-tokens sets its budget, around 1024 by default (check aider --help). For large repos raise it to 2048–4096; for single scripts set it to 0 and spend the budget on content instead.
Three upgrades
- Architect mode (
--architect): a strong model plans, an editor model implements. Better for messy, multi-step changes. - Read-only conventions (
--read CONVENTIONS.md): style rules and banned libraries stay out of diffs. - Auto lint and test (
--auto-lint --auto-test --test-cmd "pytest -q"): failures get fed back for a second pass.
Common traps
Asking for ten files at once invites errors — split the task. Never run without git. Commit messages come out in English by convention, not by bug. Very large files can truncate with diff-only models; narrow the file set instead. Avoid --yes in environments where tests delete data or send requests.
FAQ
Does it conflict with Cursor or Copilot? No. Use the editor for day-to-day code and Aider for refactors and servers.
Can it run offline? Yes with a local model, but small models are weak at multi-file edits.
Does it understand Chinese? Yes for instructions; commits stay English.
How do I control cost? Cheap weak model, modest --map-tokens, and /clear on long sessions.
Commands follow the official docs and
aider --help; flags change between releases.
Related
Written by our editorial team; tools listed here are tested or verified against public sources. Links point to official sites or GitHub repos for reference only — no paid placements.