Skip to content

Aider

Open Source

一款开源命令行 AI 编码助手,深度集成 Git——每次改动都会自动提交,可一步回滚。

Official Site
01

概述

Aider 是目前开源世界最受好评的命令行 AI 编码助手,GitHub star 超过 39k。它与 Git 仓库深度绑定:每次 AI 代码改动都会自动提交,配合 /undo 可一步回滚——工作流与 Git 紧密耦合。2026 年它完成了一次史诗级更新。对于终端爱好者,Aider 与 Claude Code 做的是同一件事——把 AI 变成你的结对编程伙伴——但 Aider 完全开源,可接入任意模型。

核心特性:完全开源、深度 Git 集成、自动提交、/undo 回滚、支持任意模型。

02

安装

Aider 通过 pip 安装,需要 Python 3.10 或更高版本。安装后配置模型 API key 即可开始使用。

bash
# Check the Python version (3.10+ required)
python --version

# Install Aider
pip install aider-chat

# Verify the installation
aider --version

建议在虚拟环境中安装以避免依赖冲突:python -m venv venv && source venv/bin/activate

03

基本用法

在 Git 仓库目录下运行 aider 启动交互式会话。使用 /add 添加要编辑的文件,然后用自然语言描述需求。Aider 在每次改动后用 git 自动提交;使用 /undo 回滚。它支持多种模型,包括 OpenAI、Anthropic、DeepSeek。

bash
# Configure the API key (OpenAI example)
export OPENAI_API_KEY="sk-your-key"

# Use other models like DeepSeek
export DEEPSEEK_API_KEY="your-key"
aider --model deepseek/deepseek-chat

# Launch inside a Git repository
cd my-project
aider

# Common in-session commands
/add src/auth.py        # Add a file to the edit scope
/drop src/old.py        # Remove a file
/undo                   # Roll back the last AI change
/diff                   # View uncommitted changes
/ask "Explain this function"  # Ask only, no edits

Aider 只修改你 /add 过的文件,不会动其他代码——安全性高。

04

技巧

Aider 的 Git 集成是其最大卖点:每次改动都是独立提交,用 git log 可以清楚看到 AI 做了什么。使用 --architect 模式(一个模型规划、另一个执行)可提升复杂任务的质量。可以在 .aider.conf.yml 中持久化默认模型和选项。接入 DeepSeek 等模型性价比极高。

bash
# Architect mode: separate planning and execution
aider --architect --model claude-sonnet-4 --editor-model deepseek/deepseek-chat

# Persist configuration
cat > .aider.conf.yml <<EOF
model: deepseek/deepseek-chat
auto-commits: true
dark-mode: true
EOF

# Read-only mode (review code)
aider --read src/utils.py --message "Are there any bugs in this code?"

# Run directly from the command line
aider --message "Add type annotations to every function" src/auth.py

提示:对于重要分支,先用 git branch 备份;/undo 只回滚最近一次改动——多次回滚请用 git reset。

05

Configuration

Aider is configured through .aider.conf.yml in the project root, CLI flags, and environment variables. Set model API keys (OPENAI_API_KEY, ANTHROPIC_API_KEY, DEEPSEEK_API_KEY, etc.) as environment variables. The .aider.conf.yml file persists defaults like model, auto-commits, and dark-mode. Aider builds a repo map automatically so the LLM understands your whole project without you adding every file.

bash
# .aider.conf.yml (project root)
model: deepseek/deepseek-chat
auto-commits: true
dark-mode: true

# API keys (environment variables)
export OPENAI_API_KEY="sk-..."
export ANTHROPIC_API_KEY="sk-ant-..."
export DEEPSEEK_API_KEY="..."

# Pick a model per run
aider --model deepseek/deepseek-chat
aider --model claude-sonnet-4

# Architect mode: one model plans, another executes
aider --architect --model claude-sonnet-4 \
  --editor-model deepseek/deepseek-chat

# Disable auto-commit if you prefer manual commits
aider --no-auto-commits

DeepSeek is extremely cost-effective; pair it as the editor model in --architect mode with a strong planner model.

06

FAQ

Common questions cover model choice, cost, Git integration, the repo map, and architect mode. Aider only modifies files you /add, so other code is safe. Every change is auto-committed, and /undo rolls back the last change. The repo map lets the LLM navigate your project without reading every file.

bash
Q: Which model should I use?
A: DeepSeek is the most cost-effective; Claude Sonnet is stronger for
   complex refactors. Use --architect to combine a strong planner with a
   cheap editor model.

Q: How do I reduce costs?
A: Use DeepSeek for routine edits, scope files with /add, and use /ask
   (no edits) for read-only questions.

Q: How does Git integration work?
A: Every AI change is auto-committed; /undo rolls back the last change.
   For multiple rollbacks use git reset.

Q: What is the repo map?
A: A compact map of your repo so the LLM understands structure without
   reading every file.

Q: Will it edit files I didn't add?
A: No—Aider only modifies files you /add, so other code stays untouched.

For important branches, back up with git branch first; /undo only rolls back the most recent change.

Ready to try Aider?

Visit the official site for the latest version and full documentation.

Visit Aider