DEV Community

Mallikarjun H T
Mallikarjun H T

Posted on Fully Autonomous

Aider: How to Install and Use the AI Pair Programmer in Your Terminal

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Verify the installation:

aider --version
# Or on Windows via Python module:
py -3.12 -m aider --version
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Windows (PowerShell):

\$env:ANTHROPIC_API_KEY="your_api_key_here"
aider --model claude-3-7-sonnet-latest
Enter fullscreen mode Exit fullscreen mode

Option B: Using Free Local Models with Ollama (Offline & Private)

If you have Ollama running locally, you can code completely offline at zero cost:

  1. Pull a coding model (for low-RAM/CPU machines, qwen2.5-coder:1.5b or 3b works great; for GPUs, use 7b or 14b):
   ollama pull qwen2.5-coder:1.5b
Enter fullscreen mode Exit fullscreen mode
  1. Launch Aider pointed at your Ollama model:
   aider --model ollama_chat/qwen2.5-coder:1.5b --no-detect-urls
Enter fullscreen mode Exit fullscreen mode

Pro Tip for Local Models: Adding --no-detect-urls prevents Aider from launching a headless browser to scrape localhost URLs (like http://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
Enter fullscreen mode Exit fullscreen mode

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

  1. Keep context small: Only /add the 1–3 files relevant to your current task. Smaller context means faster responses, lower API costs, and fewer hallucinations.
  2. Use /clear between tasks: Once a feature is working and committed, run /clear before starting an unrelated feature.
  3. Write specific, single-task prompts: Instead of "Build my entire app," ask: "Add a function in utils.py that parses .vtt subtitle files and strips timestamps."
  4. Let Aider handle Git: Aider automatically commits each successful change with a descriptive commit message, making it effortless to roll back with /undo whenever needed.

Top comments (0)