Skip to content

Commit 0127f23

Browse files
committed
docs: 再扩 pitfalls——加 Aider 7 个坑 + 修英文 README 锚点
pitfalls: - pitfalls/aider.md / .en.md: 7 个 Aider 专属坑 auto-commit 吃未提交变更 / /add 漏依赖 AI 脑补 / 切模型后质量塌 / auto-lint 循环烧 token / Map 模式过期 / Architect→Code 方案漂移 / amend 失控 - pitfalls/README 索引加入 Aider 行 - aider/README 补上缺失的"常见陷阱"速查表 + 深度展开链接 (之前 aider README 没有这一节,和其他工具不一致) fix: - README.en.md: 修 3 处锚点链接(#-9-tool-guides 等) 英文 heading 无 emoji 不需要 leading dash 中文侧 heading 有 emoji 所以 leading dash 正确,保留
1 parent 750a957 commit 0127f23

7 files changed

Lines changed: 480 additions & 3 deletions

File tree

README.en.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
| Cost-conscious / solo dev | [Cheatsheet](cheatsheet.en.md)[Gemini CLI](gemini-cli/) or [Aider](aider/) + local models |
3535
| Team / high-quality delivery | [Kiro](kiro/)[Code Review](common/code-review.en.md)[Testing](common/testing.en.md) |
3636

37-
**Already using AI tools?** Jump to: [Cheatsheet](cheatsheet.en.md) · [Advanced Tips](#-9-tool-guides) · [Real-World Workflows](#-real-world-workflows) · [Ecosystem](#-ecosystem)
37+
**Already using AI tools?** Jump to: [Cheatsheet](cheatsheet.en.md) · [Advanced Tips](#9-tool-guides) · [Real-World Workflows](#real-world-workflows) · [Ecosystem](#ecosystem)
3838

3939
---
4040

aider/README.en.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,19 @@ git push -u origin feature/add-notifications
185185

186186
---
187187

188+
## Common Pitfalls
189+
190+
| Pitfall | Description | Solution |
191+
|---------|-------------|----------|
192+
| Auto-commit swallows WIP | Auto-commit sweeps your unstaged changes into the commit | `git stash` before session, or use a dedicated branch |
193+
| `/add` misses deps | Incomplete context, AI guesses from filenames | Have it `/ask` list dependencies first, then `/add` all of them |
194+
| Model-switch quality drop | Cheaper model → cliff drop in output quality | Switch by task type; return to Claude for complex work |
195+
| Lint loop burns tokens | `auto-lint` retries failing checks via LLM | `--max-reflections 3`, use `--fix` linters |
196+
197+
👉 **Deep dive**: [Aider Pitfalls](../pitfalls/aider.en.md) — 7 real-world traps, each with Symptom / Cause / Recovery / Prevention
198+
199+
---
200+
188201
## Configuration Templates
189202

190203
| Template | Purpose |

aider/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,19 @@ git push -u origin feature/add-notifications
183183

184184
---
185185

186+
## 常见陷阱
187+
188+
| 陷阱 | 说明 | 解决 |
189+
|------|------|------|
190+
| auto-commit 吃变更 | 自动提交把你未 stage 的工作一起吞了 | 会话前 `git stash`,或开独立分支 |
191+
| /add 漏依赖 | 上下文不全,AI 靠文件名脑补 | 让它先 /ask 列出所有依赖再 /add |
192+
| 模型切换质量塌 | 切到便宜模型后产出质量断崖下跌 | 分任务类型切,复杂任务回 Claude |
193+
| lint 循环烧 token | auto-lint 失败反复让 LLM 修 | `--max-reflections 3`,lint 用 `--fix` 模式 |
194+
195+
👉 **深度展开版**[Aider 陷阱合集](../pitfalls/aider.md) — 7 个真实踩坑场景,每个带症状 / 根因 / 出坑 / 预防
196+
197+
---
198+
186199
## 配置模板
187200

188201
| 模板 | 用途 |

pitfalls/README.en.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@
1515
| [Claude Code](./claude-code.en.md) | 8 | Context overflow / hallucinated APIs / over-refactoring / fake verification / CLAUDE.md ignored / git amend / plan drift / subagent context |
1616
| [Cursor](./cursor.en.md) | 8 | Composer rogue / Tab blast / .cursorrules too long / @file silent fail / mode confusion / model switching / stale Notepads / stale index |
1717
| [GitHub Copilot](./copilot.en.md) | 8 | Outdated APIs / Agent reads .env / instructions too long / #file vs @workspace / MCP silent fail / IDE differences / free tier throttling / custom roles not discovered |
18+
| [Aider](./aider.en.md) | 7 | Auto-commit swallows WIP / /add misses deps / model-switch quality drop / lint loop burns tokens / stale map / Architect→Code drift / amend chaos |
1819

1920
---
2021

2122
## Other Tools
2223

23-
Windsurf / Gemini CLI / Kiro / Aider / Trae / OpenClaw pitfall pages aren't written yet. You're welcome to:
24+
Windsurf / Gemini CLI / Kiro / Trae / OpenClaw pitfall pages aren't written yet. You're welcome to:
2425

2526
1. Check if you've hit any pain points with the tool you use
2627
2. Send a PR using the template below

pitfalls/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@
1313
| [Claude Code](./claude-code.md) | 8 | 上下文溢出 / 幻觉 API / 过度重构 / 测试谎报 / CLAUDE.md 被忽略 / git amend / Plan 漂移 / Subagent 传话 |
1414
| [Cursor](./cursor.md) | 8 | Composer 脱缰 / Tab 暴吐 / .cursorrules 超长 / @file 失效 / Chat 模式混用 / 模型切换 / Notepads 过期 / 索引陈旧 |
1515
| [GitHub Copilot](./copilot.md) | 8 | 过期 API / Agent 读 .env / instructions 太长 / #file vs @workspace / MCP 失效 / IDE 差异 / 免费限流 / 自定义角色不生效 |
16+
| [Aider](./aider.md) | 7 | auto-commit 吃变更 / /add 漏依赖 / 模型切换质量塌 / lint 循环烧 token / Map 过期 / Architect→Code 漂移 / amend 失控 |
1617

1718
---
1819

1920
## 其他工具陷阱
2021

21-
Windsurf / Gemini CLI / Kiro / Aider / Trae / OpenClaw 的陷阱页还没写。欢迎:
22+
Windsurf / Gemini CLI / Kiro / Trae / OpenClaw 的陷阱页还没写。欢迎:
2223

2324
1. 看你用的工具有没有踩过坑
2425
2. 按下面模板写一篇 PR 过来

pitfalls/aider.en.md

Lines changed: 226 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,226 @@
1+
[简体中文](./aider.md) | **English**
2+
3+
# Aider Pitfalls
4+
5+
> Aider's pitfalls differ from IDE-based tools: auto-commit, manual `/add /drop`, multi-model switching — every mechanism can bite. 7 real traps.
6+
>
7+
> Hit a new one? Open an Issue or PR.
8+
9+
---
10+
11+
## Pitfall 1: Auto-Commit Swallows Your Working Tree Changes
12+
13+
**Symptom**
14+
- You have uncommitted changes across several files
15+
- You ask Aider to modify an unrelated file
16+
- After generating code, it auto-commits — and **your unstaged changes get bundled into that commit**
17+
18+
**Cause**
19+
Aider defaults to `auto-commits: true`. Its commit scope is the entire working tree diff — it doesn't distinguish "yours" from "mine." It assumes "change = commit."
20+
21+
**Recovery**
22+
```bash
23+
git reset HEAD~1 # Undo last commit, files back to working tree
24+
git status # Separate yours from Aider's
25+
# Manually commit what should be committed, discard the rest
26+
```
27+
28+
**Prevention**
29+
Pick one:
30+
1. **`git stash` before the session**: hide your WIP so Aider's commit stays clean
31+
2. **Disable auto-commit**: `aider --no-auto-commits`, or `auto-commits: false` in `.aider.conf.yml`
32+
3. **Dedicated branch**: `git checkout -b feature/xxx` before launching Aider
33+
34+
---
35+
36+
## Pitfall 2: `/add` Misses a File, AI Hallucinates to Fill the Gap
37+
38+
**Symptom**
39+
- You ask Aider to change `ServiceA`, it does
40+
- But ServiceA depends on `UtilB` whose signature actually changed — Aider doesn't know, generates code calling a nonexistent signature
41+
- Runtime: `TypeError`
42+
43+
**Cause**
44+
Aider only reads files that are explicitly `/add`-ed. Map mode indexes structure (names + positions) but **not contents**. Dependencies not added → AI guesses from names.
45+
46+
**Recovery**
47+
```
48+
/add src/utils/UtilB.ts
49+
# Let it re-read with the dependency included
50+
Re-check ServiceA's use of UtilB; make sure you're using the right signature
51+
```
52+
53+
**Prevention**
54+
Have Aider enumerate dependencies first:
55+
56+
```
57+
/ask
58+
I'm about to refactor ServiceA. List all files it directly depends on,
59+
and all files that call its public API. Give me /add commands
60+
so I can add them all at once.
61+
```
62+
63+
Then `/add` everything it listed before starting `/code`.
64+
65+
---
66+
67+
## Pitfall 3: Model Switched, Behavior Collapsed
68+
69+
**Symptom**
70+
- You used Claude, got used to its rigor
71+
- Switched to DeepSeek to save money; **same prompts, quality drops a cliff**
72+
- Complex refactors start producing odd bugs; Architect plans become shallow
73+
74+
**Cause**
75+
LLMs vary wildly in instruction-following. Same `/architect design a WebSocket notification system`:
76+
- Claude Sonnet: asks follow-ups, handles error paths
77+
- DeepSeek: gives one plan, skips edge cases
78+
- Local 7B: structurally correct but detail-poor
79+
80+
**Recovery**
81+
- Complex task, model can't keep up: switch back to Claude for that step only, then switch back
82+
- Configure tiered models: strong for reasoning, weak for commit-messages/simple tasks
83+
84+
**Prevention**
85+
Tier in `.aider.conf.yml`:
86+
87+
```yaml
88+
model: claude-3-5-sonnet # Primary
89+
weak-model: deepseek/deepseek-chat # Weak tasks (commit messages, simple completion)
90+
editor-model: claude-3-5-haiku # Editor-mode completion
91+
```
92+
93+
Or switch **by task type**:
94+
95+
| Task | Model |
96+
|------|-------|
97+
| `/architect` design | Claude Sonnet/Opus |
98+
| `/code` implement an approved plan | DeepSeek is fine |
99+
| `/ask` Q&A | any |
100+
| Large refactor | Claude Opus |
101+
102+
---
103+
104+
## Pitfall 4: Lint/Test Auto-Loop Blows Up the Bill
105+
106+
**Symptom**
107+
- You enabled `auto-lint: true` and `auto-test: true`
108+
- Aider edits, lint fails, it retries the fix, fails, retries...
109+
- A single session burns 5× expected tokens
110+
111+
**Cause**
112+
Aider's auto-lint/test retries "if it fails, let the LLM try again." If the problem isn't code-fixable (environment, dependencies), it'll retry until it hits the retry cap. Each retry costs tokens.
113+
114+
**Recovery**
115+
```
116+
/undo # Roll back this round
117+
/lint-cmd none # Temporarily disable auto-lint
118+
# Fix the real problem (environment/config), then re-enable
119+
```
120+
121+
**Prevention**
122+
- Cap retries: `aider --max-reflections 3`
123+
- Use auto-fixing linters so the linter resolves what it can before handing to AI:
124+
125+
```yaml
126+
lint-cmd: "eslint --fix" # not "eslint"
127+
```
128+
129+
- Fail-fast tests:
130+
131+
```yaml
132+
test-cmd: "pytest -x --maxfail=1"
133+
```
134+
135+
---
136+
137+
## Pitfall 5: Stale Map — References Deleted Files
138+
139+
**Symptom**
140+
- Project structure changed (directories removed, modules renamed)
141+
- Aider still "remembers" the old structure, generates imports to nonexistent modules
142+
- Or `/ls` output doesn't match disk
143+
144+
**Cause**
145+
Map mode is built **at session start**. Large git-level changes (branch switch, rebase, mass deletions) during a session don't auto-refresh the map.
146+
147+
**Recovery**
148+
Exit and relaunch Aider — the map rebuilds.
149+
Or in-session:
150+
```
151+
/reset # Clear session context
152+
/map-refresh # Re-scan project structure (if your version supports it)
153+
```
154+
155+
**Prevention**
156+
- Restart Aider after branch switches (don't span branches in one session)
157+
- Restart after mass file changes
158+
- Long sessions: `/reset` periodically to refresh state
159+
160+
---
161+
162+
## Pitfall 6: Architect Plan Is Solid, Code Execution Drifts
163+
164+
**Symptom**
165+
- `/architect` produces a clean plan, you approve it
166+
- Switch to `/code`, first couple files match — then it drifts
167+
- Final implementation looks almost nothing like the plan
168+
169+
**Cause**
170+
Architect and Code modes **share session context**, but the Architect plan is long; as Code mode edits file after file, early planning content gets pushed out of context.
171+
172+
**Recovery**
173+
```
174+
# After each implementation step, checkpoint against the plan
175+
/ask Compare the current implementation to the Architect plan.
176+
Where has it drifted?
177+
```
178+
179+
**Prevention**
180+
- Immediately write the Architect plan to a file: `Save this plan to docs/arch.md. We'll implement from that file.`
181+
- At implementation time, re-reference: `/add docs/arch.md Implement the next step per this file.`
182+
- For complex tasks, **one session per sub-module** — avoid long-session drift
183+
184+
---
185+
186+
## Pitfall 7: `--amend` Goes Sideways After Aider Commits
187+
188+
**Symptom**
189+
- You ask Aider to adjust something (auto-committed)
190+
- It makes another commit
191+
- You want to "fold these together," so you `--amend`
192+
- But amend sucks in your **previously stashed content**, or Aider's two changes into one — history ends up messier
193+
194+
**Cause**
195+
Aider commits "after each change," not atomically per logical unit. Manual amend pulls in all currently-staged content. Aider itself doesn't support fine-grained commit control.
196+
197+
**Recovery**
198+
```bash
199+
git reflog # Find pre-amend state
200+
git reset --hard HEAD@{N} # Roll back
201+
# Rewrite history cleanly
202+
git rebase -i HEAD~5
203+
```
204+
205+
**Prevention**
206+
- Squash at end of session:
207+
```bash
208+
git reset --soft HEAD~N # N = number of Aider commits
209+
git commit -m "feat: add notifications"
210+
```
211+
- Don't `--amend` during an Aider session
212+
- Tag key checkpoints yourself: `git tag wip-before-aider` — rollback is cheap
213+
214+
---
215+
216+
## Contribute a Pitfall
217+
218+
Template: see [claude-code.en.md end](./claude-code.en.md#found-a-new-pitfall).
219+
220+
---
221+
222+
## Related
223+
224+
- [Aider Full Guide](../aider/README.en.md)
225+
- [common/task-decomposition.en.md](../common/task-decomposition.en.md) — Task decomposition (Aider relies on this heavily)
226+
- [common/debugging.en.md](../common/debugging.en.md) — Systematic debugging

0 commit comments

Comments
 (0)