Aider: How to Install and Use the AI Pair Programmer in Your Terminal
If you want an AI coding assistant that edits files directly in your repository, runs git commits automatically, and works with both cloud APIs and free local models via Ollama, Aider is one of the fastest tools you can add to your terminal.
Unlike browser-based chat tools where you constantly copy and paste snippets back and forth, Aider maps your codebase, applies multi-file edits cleanly, and tracks every change with Git.
Prerequisites
Before installing Aider, make sure you have:
- Python 3.10 to 3.12 installed (very new releases like Python 3.14 can occasionally lack prebuilt wheels for AI dependencies).
- Git installed and initialized in your project folder (
git init).
Step 1: Install Aider
Open your terminal (PowerShell on Windows, Terminal on macOS/Linux) and install aider-chat via pip:
python -m pip install aider-chat Windows Tip (If aider is not recognized or you have multiple Python versions)
If you run into PATH issues or dependency build errors on a newer Python version, target Python 3.12 explicitly using the Windows Python Launcher:
py -3.12 -m pip install aider-chat Verify the installation:
aider --version # Or on Windows via Python module: py -3.12 -m aider --version Step 2: Connect an LLM (Cloud or Local)
Aider supports almost every major LLM provider—including Anthropic, OpenAI, Gemini, DeepSeek, and local models via Ollama.
Option A: Using Cloud Models (Claude, GPT, Gemini)
Set your API key as an environment variable and launch Aider:
macOS / Linux:
export ANTHROPIC_API_KEY=your_api_key_here aider --model claude-3-7-sonnet-latest Windows (PowerShell):
\$env:ANTHROPIC_API_KEY="your_api_key_here" aider --model claude-3-7-sonnet-latest Option B: Using Free Local Models with Ollama (Offline & Private)
If you have Ollama running locally, you can code completely offline at zero cost:
- Pull a coding model (for low-RAM/CPU machines,
qwen2.5-coder:1.5bor3bworks great; for GPUs, use7bor14b):
ollama pull qwen2.5-coder:1.5b - Launch Aider pointed at your Ollama model:
aider --model ollama_chat/qwen2.5-coder:1.5b --no-detect-urls Pro Tip for Local Models: Adding
--no-detect-urlsprevents Aider from launching a headless browser to scrape localhost URLs (likehttp://127.0.0.1:11434) if you paste them into your prompt—saving hundreds of megabytes of RAM.
Step 3: Essential Aider Workflow & Commands
Navigate to your project folder and launch Aider with the specific files you want it to edit:
cd my-project aider app.py utils.py Once inside the Aider prompt, you can type plain English instructions—or use built-in slash commands to control context and Git:
| Command | What It Does |
|---|---|
/add <file> | Adds a file to the active chat context so Aider can read and edit it. |
/drop <file> | Removes a file from context to save tokens and keep prompts fast. |
/clear | Clears conversation history (essential for keeping local models fast). |
/diff | Shows the exact diff of the last change Aider made. |
/undo | Reverts the last Git commit created by Aider if you don't like the edit. |
/run <cmd> | Runs a shell command (like pytest or python app.py) and shares output with Aider. |
/exit | Exits the Aider session. |
4 Best Practices for Getting Clean Code from Aider
- Keep context small: Only
/addthe 1–3 files relevant to your current task. Smaller context means faster responses, lower API costs, and fewer hallucinations. - Use
/clearbetween tasks: Once a feature is working and committed, run/clearbefore starting an unrelated feature. - Write specific, single-task prompts: Instead of "Build my entire app," ask: "Add a function in
utils.pythat parses.vttsubtitle files and strips timestamps." - Let Aider handle Git: Aider automatically commits each successful change with a descriptive commit message, making it effortless to roll back with
/undowhenever needed.