We use cookies to understand how the site is used and to display ads. Analytics and advertising only run after you accept. You can change your choice anytime. Privacy policy

Skip to content
devvkit
$devvkit learn --librarie aider-guide

Aider Guide

[ai][coding][pair-programming][git]
AI / LLM Tools
Install
pip install aider-chat
# or: uv tool install aider-chat
# Set API key:
export ANTHROPIC_API_KEY=sk-ant-...
export OPENAI_API_KEY=sk-...

Aider is an AI coding assistant that runs in your terminal. Unlike generic chat UIs, Aider understands your git repo: it reads files context, suggests changes, and applies them directly to your code with proper git commits. It's like having a senior dev who never gets tired.

Aider supports multiple LLM backends: Claude 3.5 Sonnet (best for coding), GPT-4o, DeepSeek Coder, and local models via Ollama. It auto-commits before each change so you can always `git diff HEAD~1` or undo with `git reset`.

The `/add` command tells Aider which files to consider. The `/read-only` command adds files for context without allowing edits. Use `--model` to switch backends. Aider's "architect" mode has one model plan and another implement. GUI: Continue.dev (VS Code), Cursor (IDE) for editor-integrated AI.

Setup

Start chat· Launch aided coding session.
aider --model claude-sonnet-4-20250514
# Or set env:
export ANTHROPIC_API_KEY=sk-ant-...
aider --model claude-sonnet-4-20250514

# With GPT-4o:
export OPENAI_API_KEY=sk-...
aider --model gpt-4o

Basic Chat

Ask and edit· Request a code change.
# Aider will:
# 1. Read the added files
# 2. Edit them with your changes
# 3. Git commit with a descriptive message

# Example prompts:
"Add error handling to the file upload function"
"Refactor this into a class with type hints"
"Add unit tests for the UserService"
"Fix the off-by-one bug in the pagination"

File Management

Add files for editing· Tell Aider which files to edit.
# In chat:
/add src/main.py
/add src/utils/*.py
# Make files read-only (context only):
/read-only src/config.py

# Or from CLI launch:
aider src/main.py src/utils/*.py

Git Integration

Undo last change· Roll back AI edit.
/undo         # Undo the last AI change
/git diff     # See what changed
/git commit -m "fix: actually fix it"
/git diff HEAD~1  # Review last commit

# Aider auto-commits every change with:
# "aider: <description of change>"
Git workflows· Integration commands.
/commit      # Commit any uncommitted changes
/diff        # Show diff of pending changes
/run pytest  # Run tests and show results

# Aider uses the repo's git history to
# understand context and make better edits

Models

Use local models· Ollama with Aider.
aider --model ollama/llama3.2 \
  --ollama-base-url http://localhost:11434

# Best local coding models:
aider --model ollama/qwen2.5-coder:7b
# or:
aider --model ollama/deepseek-coder:6.7b

# For weaker models, add --weak-model flag

Tricks

Architect mode· Plan + implement split.
aider --model claude-sonnet-4-20250514 \
  --editor-model gpt-4o
# One model plans (architect)
# Another implements (editor)

# Or use Aider with --architect flag:
aider --architect --model claude-sonnet-4-20250514
Voice input· Speak your prompts.
aider --voice              # Uses microphone
# Requires: python -m pip install pyaudio
# Speaks: "Add a function to calculate fibonacci"
# Aider hears, transcribes, and implements
Lint & fix· Auto-fix lint errors.
aider --lint              # Lint repo and fix issues
# Or during session:
/lint                     # Lint current files

aider --test              # Run tests and fix failures
aider --test-cmd "npm test"  # Custom test command