Coding

Aider

Try it

Aider AI 编程助手,精通终端内 AI 编程、Git 集成、多模型支持、代码重构

What it does

简介 Aider 是一款运行在终端中的 AI 结对编程工具,能直接编辑本地 Git 仓库中的代码。 它的核心理念是"对话即编程"——你用自然语言描述需求,Aider 自动修改代码并生成 Git commit。

The skill document

Aider - 终端内 AI Pair Programming 工具

简介

Aider 是一款运行在终端中的 AI 结对编程工具,能直接编辑本地 Git 仓库中的代码。 它的核心理念是"对话即编程"——你用自然语言描述需求,Aider 自动修改代码并生成 Git commit。

核心功能

  • 自动 Git Commit:每次代码修改自动生成语义化的 commit message
  • 多文件编辑:一次对话中同时修改多个文件,保持跨文件一致性
  • 文件管理:通过 /add 和 /drop 精确控制 AI 可见的上下文范围
  • 代码地图(Repo Map):基于 tree-sitter 构建仓库结构索引,帮助 AI 理解项目全貌
  • Linting 集成:修改后自动运行 linter,发现问题自动修复

支持的模型

模型推荐场景配置方式
Claude Sonnet 4日常编码(默认推荐)--model sonnet
Claude Opus 4复杂架构重构--model opus
GPT-4oOpenAI 生态用户--model gpt-4o
DeepSeek V3高性价比选择--model deepseek
Ollama 本地模型离线/隐私场景--model ollama/qwen2.5-coder

常用命令

# 启动 Aider
aider                          # 当前目录启动
aider --model sonnet           # 指定模型
aider file1.py file2.py        # 预加载文件

# 会话内命令
/add src/main.py               # 添加文件到上下文
/drop src/test.py              # 从上下文移除文件
/undo                          # 撤销上一次 AI 修改(git undo)
/diff                          # 查看当前修改的 diff
/run pytest tests/             # 运行命令并将输出发给 AI
/test pytest tests/            # 运行测试,失败时自动修复
/architect                     # 切换到 Architect 模式
/ask                           # 只问不改代码
/clear                         # 清空对话历史

配置文件

在项目根目录创建 .aider.conf.yml:

model: sonnet
auto-commits: true
gitignore: true
dark-mode: true
map-tokens: 2048
lint-cmd: "ruff check --fix"
test-cmd: "pytest tests/ -x"

环境变量配置(~/.bashrc 或 ~/.zshrc):

export ANTHROPIC_API_KEY="sk-ant-..."
export OPENAI_API_KEY="sk-..."

Architect 模式

Architect 模式采用"先规划再编码"的两阶段策略:

  1. Architect 模型(如 Opus)负责分析需求、制定修改方案
  2. Editor 模型(如 Sonnet)负责执行具体的代码修改

启用方式:

aider --architect --model opus --editor-model sonnet

适合复杂重构任务,Architect 模型产出高质量方案,Editor 模型高效执行。

与同类工具对比

特性AiderClaude CodeCursor
运行环境纯终端纯终端IDE
Git 集成自动 commit手动 commit无
文件管理/add /drop 手动自动检索自动检索
上手难度低低极低
适合场景精确控制上下文探索式开发GUI 偏好者

典型使用场景

  • 快速修 Bug:描述问题,Aider 定位并修复,自动 commit
  • 添加新功能:/add 相关文件,描述需求,多文件协同修改
  • 代码重构:Architect 模式规划方案,批量重命名/拆分/合并
  • 写测试:/add 源码文件,要求生成对应的单元测试
  • 代码审查辅助:/ask 模式分析代码逻辑,不做修改

安装

pip install aider-chat
# 或使用 pipx 隔离安装
pipx install aider-chat

Related skills

Generate and edit Draw.io, Mermaid, and Excalidraw diagrams from natural language using a structured JSON spec.

by nssa.io1.0k installs47 stars

Join a video meeting as an AI bot with voice, avatar, and screenshare across four operating modes.

by johnpatternai22 installs8 stars

Stores durable facts in a categorized, plain-markdown vault on disk, alongside your agent's built-in memory.

by Iván559 installs18 stars

Find why your productivity system keeps failing, then apply the smallest fix — capacity math, bottleneck routing, durable local notes.

by Iván855 installs69 stars

Run Git operations — commits, branches, merges, rebases, conflict resolution, and recovery — with safety rules enforced.

by Iván535 installs31 stars

Fetch raw ad creative, app, ranking, and revenue data from AdMapix as structured JSON.

by fly0pants4.3k installs296 stars

More from zhangifonly

Browse all skills

Get end-to-end guidance for QQ open platform development — official Bot API, channels, Mini Programs, and OAuth2.0.

by zhangifonly67 installs

Zero-dependency Python CLI for WeChat Official Account APIs with a real production-incident pitfall guide.

by zhangifonly102 installs1 stars

AI 小红薯 — 只允许智能体发言的图文社区。发帖、评论、点赞、加入圈子。

by zhangifonly39 installs2 stars

滴滴出行决策助手。Use for: (1) 按预算/时段/人数在快车/特惠/拼车/专车间选型并估算费用区间, (2) 早晚高峰/恶劣天气/节假日的叫车策略, (3) 企业版 API 对接与用车规则配置。DiDi ride-hailing decision guide: product selection and...

by zhangifonly25 installs

伙伴云零代码平台指南。Use for: (1) 零代码数据表格应用搭建(表格/看板/仪表盘)方法, (2) 与简道云/明道云/飞书多维表格的选型对比, (3) 从 Excel 迁移到在线协作数据库的路径设计。Huoban zero-code platform guide: app building, compet...

by zhangifonly25 installs

明道云 APaaS 平台指南。Use for: (1) 零代码应用搭建与 APaaS 能力边界(工作表/工作流/API集成), (2) 私有化部署选型——明道云是国内私有化最成熟的零代码方案之一, (3) 与 SaaS 型竞品的对比决策。Mingdao APaaS guide: app building, pri...

by zhangifonly25 installs