Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .lychee.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ exclude = [

# 对 CI 爬虫返回 403 的站点(人工访问正常)
"^https?://platform\\.openai\\.com",
# 仅对中国大陆 IP 开放
"^https?://(www\\.)?trae\\.cn",

# QQ 链接跳转
"^https?://qm\\.qq\\.com",
Expand Down
54 changes: 39 additions & 15 deletions aider/README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# Aider Best Practices

> Aider is an open-source CLI AI coding tool. Its defining feature is being **Git-native** — every change is auto-committed, with built-in version control support. It works with virtually all major LLMs (Claude, GPT, DeepSeek, Qwen, local models), making it the most flexible AI coding CLI out there.
>
> ⚠️ **Maintenance status (verified 2026-09)**: the latest PyPI release is still 0.86.2 (published 2026-02-12), and the last GitHub commit was around 2026-05 — development has clearly slowed. There is **no native MCP support**. Built-in model metadata lags behind new model releases, so newer models need a bit of manual config (see "New model config" below).

---

Expand All @@ -12,7 +14,7 @@
|---------|-------------|----------|
| **Chat Modes** | `code` / `ask` / `architect` | Different modes for different tasks |
| **Auto Git Commits** | Every change auto-committed | Roll back anytime |
| **Map Mode** | Auto-indexes project structure | Understand large codebases |
| **Repo Map** | Extracts key symbols and their definition lines (signatures), graph-ranked by references | Understand large codebases |
| **Multi-Model Support** | Claude/GPT/DeepSeek/Ollama etc. | Flexible selection, cost control |
| **Lint & Test** | Built-in code checking and testing | Auto-verify after changes |

Expand All @@ -23,7 +25,9 @@
### Installation

```bash
pip install aider-chat
python -m pip install aider-install && aider-install
# Or: uv tool install --force --python python3.12 --with pip aider-chat@latest
# Or: pipx install aider-chat

# Set an API key (pick one)
export ANTHROPIC_API_KEY=sk-xxx # Claude
Expand All @@ -37,16 +41,18 @@ export DEEPSEEK_API_KEY=sk-xxx # DeepSeek
cd /your/project
aider

# Specify a model
aider --model claude-sonnet-4-5
# Specify a model (pass the latest Claude model ID explicitly)
aider --model anthropic/claude-sonnet-5-5

# Use DeepSeek (cheaper)
aider --model deepseek/deepseek-chat
aider --model deepseek/deepseek-v4-pro

# Use a local model (free)
aider --model ollama/qwen2.5-coder
aider --model ollama/qwen3-coder
```

> The built-in aliases are outdated: `--model sonnet` → `claude-sonnet-4-6`, `--model opus` → `claude-opus-4-7`, and `--model deepseek` still points to `deepseek/deepseek-chat`, which was retired on 2026-07-24. Always spell out the full model ID.

### Three Chat Modes

```bash
Expand Down Expand Up @@ -108,23 +114,25 @@ git log --oneline # View Aider's commit history
git diff HEAD~1 # See the last change
git revert HEAD # Not happy? One-command rollback

# Set a custom commit prefix
aider --commit-prefix "[ai] "
# Mark AI commits: a Co-authored-by trailer is added by default; tune it with the --attribute-* flags
aider --attribute-commit-message-author # Prefix commit messages for AI changes with "aider: "
# Customize the commit message style
aider --commit-prompt "Write commit messages in Conventional Commits format"
```

### 4. Multi-Model Strategy

```bash
# Complex architecture design — use the strongest model
aider --model claude-sonnet-4-5
aider --model anthropic/claude-opus-5-5
/architect Design a microservices split plan

# Daily coding — use a cost-effective model
aider --model deepseek/deepseek-chat
aider --model deepseek/deepseek-v4-pro
/code Implement user-service according to the plan

# Code review — use a free local model
aider --model ollama/qwen2.5-coder
aider --model ollama/qwen3-coder
/ask Any issues with this code?
```

Expand All @@ -136,14 +144,28 @@ aider --model ollama/qwen2.5-coder

```yaml
# .aider.conf.yml
model: claude-sonnet-4-5
model: anthropic/claude-sonnet-5-5
auto-commits: true
auto-lint: true
auto-test: true
test-cmd: pytest
lint-cmd: ruff check
```

### New Model Config — `.aider.model.settings.yml`

Aider sends a `temperature` parameter by default, but newer Claude models (Sonnet 5.5, Opus 5.5, etc.) reject non-default temperature values with a 400 error. Add this to your project root or home directory:

```yaml
# .aider.model.settings.yml
- name: anthropic/claude-sonnet-5-5
edit_format: diff
use_repo_map: true
use_temperature: false
```

For models missing from Aider's built-in metadata, you'll get an "unknown context window" warning on startup. It's usually safe to ignore, or you can fill it in via `.aider.model.metadata.json`.

### Lint + Test Automation

```yaml
Expand Down Expand Up @@ -183,16 +205,18 @@ git push -u origin feature/add-notifications
| Cost control | 3/3 (free models available) | 1/3 | 3/3 |
| Best for | Flexibility, saving money, Git power users | Complex Agent tasks | Large codebase analysis |

> Gemini CLI stopped serving individual/free users (including Google AI Pro/Ultra subscribers) on 2026-06-18. Enterprise licenses and paid API keys still work; the official migration path for individuals is Antigravity CLI. The "Cost control" row no longer applies to individual users.

---

## Common Pitfalls

| Pitfall | Description | Solution |
|---------|-------------|----------|
| Auto-commit swallows WIP | Auto-commit sweeps your unstaged changes into the commit | `git stash` before session, or use a dedicated branch |
| Auto-commit commits your edits too | If a file Aider is about to edit has your uncommitted changes, it first commits them separately (`--dirty-commits` is on by default) | Commit/`git stash` yourself before the session, use `--no-dirty-commits`, or work on a dedicated branch |
| `/add` misses deps | Incomplete context, AI guesses from filenames | Have it `/ask` list dependencies first, then `/add` all of them |
| Model-switch quality drop | Cheaper model → cliff drop in output quality | Switch by task type; return to Claude for complex work |
| Lint loop burns tokens | `auto-lint` retries failing checks via LLM | `--max-reflections 3`, use `--fix` linters |
| Lint loop burns tokens | `auto-lint` retries failing checks via LLM | Use `--fix` linters; if it still loops, turn it off with `--no-auto-lint` |

👉 **Deep dive**: [Aider Pitfalls](../pitfalls/aider.en.md) — 7 real-world traps, each with Symptom / Cause / Recovery / Prevention

Expand All @@ -209,5 +233,5 @@ git push -u origin feature/add-notifications
## Further Reading

- [Aider Official Docs](https://aider.chat/docs/)
- [Aider GitHub](https://github.com/Aider-AI/aider) (42k+ stars)
- [Aider GitHub](https://github.com/Aider-AI/aider) (49k+ stars)
- [superpowers-zh](https://github.com/jnMetaCode/superpowers-zh) — Skills methodology (also supports Aider)
54 changes: 39 additions & 15 deletions aider/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Aider 最佳实践

> Aider 是一个开源的 CLI AI 编程工具,核心特色是 **Git 原生** — 每次修改自动提交,天然支持版本控制。支持几乎所有主流 LLM(Claude、GPT、DeepSeek、Qwen、本地模型),是最灵活的 AI 编程 CLI。
>
> ⚠️ **维护状态(2026-09 核实)**:PyPI 最新版仍是 0.86.2(2026-02-12 发布),GitHub 最后一次提交在 2026-05 左右,更新明显放缓;目前**没有原生 MCP 支持**。内置模型元数据跟不上新模型发布,用新模型时要自己补配置(见下文「新模型配置」)。

---

Expand All @@ -10,7 +12,7 @@
|------|------|------|
| **Chat 模式** | `code` / `ask` / `architect` | 不同任务用不同模式 |
| **自动 Git 提交** | 每次修改自动 commit | 随时可以回滚 |
| **Map 模式** | 自动索引项目结构 | 理解大代码库 |
| **Repo Map** | 提取关键符号和定义行(签名),按引用关系图排序 | 理解大代码库 |
| **多模型支持** | Claude/GPT/DeepSeek/Ollama 等 | 灵活选择,控制成本 |
| **Lint & Test** | 内置代码检查和测试 | 修改后自动验证 |

Expand All @@ -21,7 +23,9 @@
### 安装

```bash
pip install aider-chat
python -m pip install aider-install && aider-install
# 也可以:uv tool install --force --python python3.12 --with pip aider-chat@latest
# 或:pipx install aider-chat

# 设置 API Key(选一个)
export ANTHROPIC_API_KEY=sk-xxx # Claude
Expand All @@ -35,16 +39,18 @@ export DEEPSEEK_API_KEY=sk-xxx # DeepSeek
cd /your/project
aider

# 指定模型
aider --model claude-sonnet-4-5
# 指定模型(用 --model 写明最新 Claude 模型 ID)
aider --model anthropic/claude-sonnet-5-5

# 用 DeepSeek(便宜)
aider --model deepseek/deepseek-chat
aider --model deepseek/deepseek-v4-pro

# 用本地模型(免费)
aider --model ollama/qwen2.5-coder
aider --model ollama/qwen3-coder
```

> 注意内置别名已经过时:`--model sonnet` → `claude-sonnet-4-6`,`--model opus` → `claude-opus-4-7`,`--model deepseek` 仍指向已于 2026-07-24 下线的 `deepseek/deepseek-chat`。建议始终写完整模型 ID。

### 三种 Chat 模式

```bash
Expand Down Expand Up @@ -106,23 +112,25 @@ git log --oneline # 看 Aider 的提交记录
git diff HEAD~1 # 看最后一次修改
git revert HEAD # 不满意?一键回滚

# 设置自定义提交前缀
aider --commit-prefix "[ai] "
# 区分 AI 提交:默认已加 Co-authored-by trailer,可用 --attribute-* 系列开关调整
aider --attribute-commit-message-author # AI 改动的 commit message 加 "aider: " 前缀
# 自定义 commit message 风格
aider --commit-prompt "用中文写 Conventional Commits 格式的提交信息"
```

### 4. 多模型策略

```bash
# 复杂架构设计 — 用最强模型
aider --model claude-sonnet-4-5
aider --model anthropic/claude-opus-5-5
/architect 设计微服务拆分方案

# 日常编码 — 用性价比模型
aider --model deepseek/deepseek-chat
aider --model deepseek/deepseek-v4-pro
/code 按方案实现 user-service

# 代码审查 — 用免费本地模型
aider --model ollama/qwen2.5-coder
aider --model ollama/qwen3-coder
/ask 看看这段代码有没有问题
```

Expand All @@ -134,14 +142,28 @@ aider --model ollama/qwen2.5-coder

```yaml
# .aider.conf.yml
model: claude-sonnet-4-5
model: anthropic/claude-sonnet-5-5
auto-commits: true
auto-lint: true
auto-test: true
test-cmd: pytest
lint-cmd: ruff check
```

### 新模型配置 — `.aider.model.settings.yml`

Aider 默认会发 `temperature` 参数,而新一代 Claude(Sonnet 5.5、Opus 5.5 等)会拒绝非默认的 temperature,直接 400 报错。在项目根目录或 home 目录加:

```yaml
# .aider.model.settings.yml
- name: anthropic/claude-sonnet-5-5
edit_format: diff
use_repo_map: true
use_temperature: false
```

Aider 内置元数据里没有的模型,启动时会提示未知上下文窗口,一般可以忽略,也可以在 `.aider.model.metadata.json` 里补上。

### Lint + Test 自动化

```yaml
Expand Down Expand Up @@ -181,16 +203,18 @@ git push -u origin feature/add-notifications
| 成本控制 | ★★★(可用免费模型) | ★☆☆ | ★★★ |
| 适合 | 灵活、省钱、Git 重度用户 | 复杂 Agent 任务 | 大代码库分析 |

> Gemini CLI 已于 2026-06-18 停止为个人/免费用户(含 Google AI Pro/Ultra 订阅)提供服务,企业授权和付费 API Key 仍可用;个人用户官方迁移路径是 Antigravity CLI。表中「成本控制」一栏对个人用户已不适用。

---

## 常见陷阱

| 陷阱 | 说明 | 解决 |
|------|------|------|
| auto-commit 吃变更 | 自动提交把你未 stage 的工作一起吞了 | 会话前 `git stash`,或开独立分支 |
| auto-commit 顺手提交你的改动 | Aider 要改的文件里如果有你没提交的改动,它会先把这些改动单独 commit 一次(`--dirty-commits` 默认开) | 会话前自己先 commit/`git stash`,或 `--no-dirty-commits`,或开独立分支 |
| /add 漏依赖 | 上下文不全,AI 靠文件名脑补 | 让它先 /ask 列出所有依赖再 /add |
| 模型切换质量塌 | 切到便宜模型后产出质量断崖下跌 | 分任务类型切,复杂任务回 Claude |
| lint 循环烧 token | auto-lint 失败反复让 LLM 修 | `--max-reflections 3`,lint 用 `--fix` 模式 |
| lint 循环烧 token | auto-lint 失败反复让 LLM 修 | lint 用 `--fix` 模式;修不好就 `--no-auto-lint` 先关掉 |

👉 **深度展开版**:[Aider 陷阱合集](../pitfalls/aider.md) — 7 个真实踩坑场景,每个带症状 / 根因 / 出坑 / 预防

Expand All @@ -207,5 +231,5 @@ git push -u origin feature/add-notifications
## 延伸阅读

- [Aider 官方文档](https://aider.chat/docs/)
- [Aider GitHub](https://github.com/Aider-AI/aider)(42k+ star)
- [Aider GitHub](https://github.com/Aider-AI/aider)(49k+ star)
- [superpowers-zh](https://github.com/jnMetaCode/superpowers-zh) — Skills 方法论(也支持 Aider)
12 changes: 7 additions & 5 deletions aider/templates/aider.conf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@
# 复制到项目根目录,命名为 .aider.conf.yml

# 模型配置
model: claude-sonnet-4-5
model: anthropic/claude-sonnet-5-5 # 新 Claude 模型需在 .aider.model.settings.yml 设 use_temperature: false
# 其他选择:
# model: deepseek/deepseek-chat # 便宜,适合日常编码
# model: ollama/qwen2.5-coder # 免费,需要本地跑 Ollama
# model: deepseek/deepseek-v4-pro # 便宜,适合日常编码(别用 deepseek 别名,它仍指向已下线的 deepseek-chat)
# model: ollama/qwen3-coder # 免费,需要本地跑 Ollama
# model: gpt-4o # OpenAI

# Git 配置
auto-commits: true # 每次修改自动 commit
commit-prefix: "[ai] " # commit 前缀,方便区分人工和 AI 修改
auto-commits: true # 每次修改自动 commit(只提交 Aider 改过的文件)
dirty-commits: true # 要改的文件里有你未提交的改动时,先单独 commit 一次
attribute-commit-message-author: true # AI 改动的 commit message 加 "aider: " 前缀,方便区分人工和 AI 修改
# commit-prompt: "用中文写 Conventional Commits 格式的提交信息" # 自定义 commit message 生成提示

# 代码质量
auto-lint: true # 修改后自动跑 linter
Expand Down
Loading
Loading