This Aider tutorial covers installing Aider with aider-install, connecting your own API key, and the git workflow that sets it apart: every AI edit becomes its own commit, /diff shows what changed and /undo discards it. Aider is open source; you pay only for model tokens, so the post ends with simple cost math against a subscription tool.
This Aider tutorial gets you from install to a safe daily workflow: install Aider with aider-install, start it in your git repository with your own model API key, add the files to change, and describe the change. Aider edits the files and commits each change separately, so you review with /diff and roll back any edit with /undo.
Commands and flags checked October 2026 against Aider's install guide, git integration docs and in-chat command list.
Most AI coding tools treat git as something you deal with afterwards. Aider puts it at the centre: each AI edit is a commit with a descriptive message, which turns "the AI changed something" into a reviewable, revertible history. That single design choice is why many developers keep Aider alongside heavier agents. For how it fits with Claude Code, Cursor and the rest, see our AI coding tools guide.
Aider tutorial: what you will have at the end
- Aider installed in its own environment, connected to a model of your choice.
- A commit-per-change workflow with review and undo built in.
- A simple way to estimate what your sessions cost.
- 01Clean working tree
Commit or stash your own changes
- 02/add the files
Only what the change needs
- 03Describe the change
One focused request
- 04Aider edits and commits
One commit per change
- 05/diff, then keep or /undo
Review before moving on
Prerequisites
- Python available on your machine (aider-install handles the rest)
- A project in a git repository
- An API key for your chosen model provider, or a local model
- A spending limit set in your provider's console
- A test command you can run, such as npm test or pytest
Step 1: install Aider and connect a model
- 1Install the installer
python -m pip install aider-install
- 2Run it
aider-install. Expected result: Aider in its own Python environment, with Python 3.12 installed separately if needed.
- 3Go to your project
cd into the repository you want to work on.
- 4Start with a model and key
For example aider --model sonnet --api-key anthropic=your-key. Expected result: Aider starts, detects the git repo and shows a prompt.
- 5Save settings
Put your usual options in a .aider.conf.yml file so you do not retype them; keep keys in environment variables, not in files you commit.
Aider's install page shows the same pattern for other providers, such as OpenAI and DeepSeek models. If you are on the Claude API, our guide to getting a Claude API key covers creating and limiting one.
The Aider git workflow, step by step
Here is the daily loop that makes Aider safe to use on real code. It relies on behaviour Aider documents on its git page.
- Start clean. Aider takes care with files that already have uncommitted changes: by default it commits your preexisting changes first, with a descriptive message, so your edits stay separate from its edits. Starting from a clean tree keeps history easy to read.
- Add only the files the change needs. Use /add for files to edit and /read-only for reference files. Aider also builds a repo map, a compact summary of your repository's files and key symbols, and sends the most relevant parts with each request, so it knows the wider codebase without you adding everything.
- Ask for one focused change. "Add input validation to the signup handler and a test for it" works better than a list of five unrelated tasks.
- Review with /diff. It shows every file change since your last message.
- Keep or /undo. /undo undoes and discards the last change. Because every change is its own commit, undo is exact.
- Run tests with /test. It runs your command and adds the output to the chat when it fails, so Aider can fix what broke.
If you prefer to review before anything is committed, start Aider with --no-auto-commits and use /commit yourself. Aider also marks its commits: by default it appends "(aider)" to the git author or committer name, and flags such as --attribute-co-authored-by change how that attribution appears.
Habits that make Aider sessions go well
The tool is simple; the results depend on how you drive it. A few habits separate productive sessions from frustrating ones.
- Write requests like tickets. Say what should change, where, and how you will know it worked. "In auth.ts, reject passwords under 12 characters and add a test in auth.test.ts" gives Aider everything it needs.
- Ask before you change. In an unfamiliar repository, spend the first few minutes in /ask mode. Understanding where things live saves several failed edits later.
- Keep commits small. One request, one change, one commit. Small commits make /undo precise and make code review by teammates realistic.
- Let tests close the loop. Run /test after each change. When it fails, Aider sees the output and can fix the problem in the next commit.
- Squash before you merge. Aider's commit-per-change history is great while working. Before a pull request, squash or rewrite the branch into commits your team wants to read.
None of this is specific to Aider, but its git-first design rewards it more than most tools. The history it leaves behind is also a record of how a feature was built, which helps when you come back to the code months later.
The commands you will use daily
| Command | What it does |
|---|---|
| /add | Add files to the chat so Aider can edit them |
| /read-only | Add files for reference only |
| /drop | Remove files to free context space |
| /ask | Ask about the code without editing files |
| /code | Ask for changes to your code |
| /architect | Plan with one model, edit with another |
| /diff | Show all file changes since your last message |
| /undo | Undo and discard the last change |
| /commit | Commit all dirty changes with a sensible message |
| /run and /test | Run a shell command; /test adds output on failure |
| /tokens | Report tokens used by the current chat context |
Two modes are worth learning early. /ask answers questions about the code without editing, which is ideal for understanding an unfamiliar repo before you change it. /architect splits work between two models, one that plans the change and one that writes the edits.
Bring-your-own-key cost math
Aider is open source, so the software is free; you pay your model provider per token. That changes how to think about cost. A subscription tool charges a flat monthly price; Aider charges whatever your sessions use.
A simple way to estimate: each request sends the added files, the relevant part of the repo map and the chat history, then receives the edit. Use /tokens to see how large your context is. As an illustrative calculation, not a measurement, at a published rate of USD 2 per million input tokens and USD 10 per million output tokens (Claude Sonnet 5.5 on Anthropic's API pricing, checked October 2026), a session of 40 requests averaging 30,000 input tokens and 2,000 output tokens each would use 1.2 million input and 80,000 output tokens, roughly USD 2.40 plus USD 0.80. Your numbers will differ, so measure a real week with /tokens and your provider's usage page before comparing.
- Pay per token used
- Cheap in light weeks, costly in heavy ones
- Pick any model, change any time
- Keep context small to keep cost small
- Flat monthly price
- Predictable, with usage limits
- Model choice set by the vendor
- Heavy users get the most value
The cost levers are the same as with any API workload: fewer files in context, shorter chats (use /clear between unrelated tasks), and a cheaper model for simple edits. If you are building products with these tools, our AI SaaS Builder program covers the full build and launch workflow.
Aider vs OpenCode
OpenCode is another open-source terminal coding agent. Its documentation says it supports 75+ LLM providers and local models, offers /undo and /redo that revert the latest message and the work after it, and includes a plan agent that analyses code without making changes (checked October 2026 on opencode.ai). The practical difference is philosophy: Aider builds its safety net from git commits, while OpenCode manages reverts inside its own session and leans further toward autonomous agents. If git history is how you think about change, Aider fits naturally; if you want an agent that runs larger tasks with less steering, OpenCode or Claude Code may suit better. Our Claude Code install guide covers that route.
Troubleshooting
- Edits land in the wrong file. The right file was not added. /add it and drop unrelated ones.
- Costs climbing. Check /tokens; drop files and /clear old chat before new tasks.
- Commits mixed with your own work. Start sessions from a clean tree, or use --no-dirty-commits if you want Aider to leave your uncommitted files alone.
- Aider does not see a new file. Files created outside the session are not in the chat until you /add them, so add new files explicitly before asking Aider to edit them.
- Edits fail to apply. Try a stronger model, or architect mode so planning and editing are split.
Aider tutorial: FAQ
What is Aider AI?
Aider is an open-source AI pair programming tool that runs in your terminal and edits the code in your local git repository. You connect it to a language model with your own API key, add the files you want changed, and describe the change. Aider edits the files and, by default, commits each change to git with a descriptive message, so every AI edit is reviewable and reversible.
How do I install Aider?
Aider's install page recommends running python -m pip install aider-install, then aider-install. That installs Aider in its own Python environment, and installs Python 3.12 separately if needed. Then change into your project folder and start it with a model and key, for example aider --model sonnet --api-key anthropic=your-key. Checked October 2026.
How do I undo a change Aider made?
Type /undo in the chat. Aider's git documentation says it undoes and discards the last change, which works because Aider commits each edit separately. Use /diff first to see every file change since your last message. If you prefer to review before anything is committed, start Aider with --no-auto-commits and commit yourself with /commit when you are happy.
Is Aider free?
Aider itself is open source and free to use. You pay the model provider for the tokens your sessions use, through the API key you connect, or nothing if you run a local model. That makes cost proportional to usage rather than a flat monthly fee, which can be cheaper or more expensive than a subscription tool depending on how much you code.
What is the difference between Aider and OpenCode?
Both are terminal-based AI coding tools that work with many model providers. Aider centres on git: it commits each change and undoes through git. OpenCode's documentation describes a terminal interface with /undo and /redo that revert the latest message and the work after it, plus separate agents such as a plan agent that analyses code without changing it. Pick by which workflow fits you.
Which model works best with Aider?
Aider works with many providers, and its install page shows examples for Anthropic, OpenAI and DeepSeek models. Strong coding models give the most reliable edits, while cheaper models suit small, well-scoped changes. Aider's architect mode can pair two models: one plans the change and another applies the edits, which lets you balance quality and cost.
From pair programming to a shipped product.
The AI SaaS Builder program, included in All Access, covers AI coding workflows, building with the Claude API, auth, billing and deployment, with the other three programs, live coaching and the private community in one subscription.
Ask builders in the free Discord
Compare AI coding setups and get unstuck with other builders.