Aider: Terminal AI Coding Assistant That Understands Project Structure and Edits Multiple Files

📘 Tutorials 2026-07-19 · Updated 2026-11-22 3 min read

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

  1. cd project && aider to start and build the repo map.
  2. /add src/api.py src/models.py — the model can only edit files in the chat. Do not /add . casually.
  3. Describe the task in plain language.
  4. Review the diff; it commits automatically. /undo if wrong.
  5. /tokens to check context usage, /clear before 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

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

Related Articles
2026-08-11
LLM Context Window 2026: 128K vs 1M Tokens and What the Real Limits Are
2026-08-13
Cursor Rules 2026: The Complete Guide to .cursorrules Files That Make AI Write Your Style
2026-08-13
FLUX Models Explained 2026: Architecture, Sizes and How Black Forest Labs Changed Image AI
2026-08-28
How Affiliate Marketing Works in 2026: The Business Model Behind Coupon Sites
2026-07-27
Fine-Tune Llama 4 on Custom Data 2026: Step-by-Step Guide
2026-08-07
Local AI Assistant on Linux: Full Offline Setup with Ollama and Open WebUI

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.

💬 Comments (0)

No comments yet. Be the first!

Login to comment