补丁摞补丁
Fix on top of fix on top of fix
智能体一层层叠加未经验证的修复,每次都在修上一次修复带来的症状,从不回头找根因。
适用于: Claude Code · Cursor · Codex · Copilot agent
症状
五轮“再试试这个”,diff 里塞满特殊处理,原来的 bug 还在,或者冒出了新 bug。
为什么会这样
每次尝试都从最新的报错出发,而不是重新审视原因,第一个猜测也很少被推翻。agent-failure-modes 称之为 AFM-4 补丁螺旋,相关的还有 AFM-9 首个假设锚定。
示例
示意。
texttry 1: add null check -> new error: undefined.map
try 2: default to [] -> list renders empty
try 3: special-case id 0 -> test passes, prod still broken
root cause: API returns { data: [...] }, code expects [...]
复制即用的修复
按你用的智能体挑选文件。规则片段用英文写,放进任何仓库都能用。
规则
Claude Code:加入 CLAUDE.md
CLAUDE.md## Two failed fixes means stop and diagnose
- Before fixing, reproduce the bug and write down a hypothesis plus the evidence for it.
- Verify each fix by re-running the reproduction. If two fixes in a row fail, stop patching:
revert to the last known-good state, list at least two alternative causes, and test them.
- Never stack a fix on an unverified fix.
规则
Codex、Copilot 编码智能体等:加入 AGENTS.md
AGENTS.md## Two failed fixes means stop and diagnose
- Before fixing, reproduce the bug and write down a hypothesis plus the evidence for it.
- Verify each fix by re-running the reproduction. If two fixes in a row fail, stop patching:
revert to the last known-good state, list at least two alternative causes, and test them.
- Never stack a fix on an unverified fix.
Cursor 规则
Cursor:项目规则
.cursor/rules/patch-spiral.mdc---
description: "AgentFails: Fix on top of fix on top of fix"
alwaysApply: true
---
## Two failed fixes means stop and diagnose
- Before fixing, reproduce the bug and write down a hypothesis plus the evidence for it.
- Verify each fix by re-running the reproduction. If two fixes in a row fail, stop patching:
revert to the last known-good state, list at least two alternative causes, and test them.
- Never stack a fix on an unverified fix.
技能
/debug 技能:复现、假设、验证
.claude/skills/debug/SKILL.md---
name: debug
description: Use when fixing a bug or a failing test, before editing code.
---
1. Reproduce: write the exact command that shows the bug. Run it and paste the output.
2. Hypotheses: list 2-3 possible causes, each with the evidence for and against it.
3. Test the most likely one with a read-only check (log, print, debugger) before editing.
4. Fix the cause, re-run the reproduction, and show it now passes.
5. If two fixes fail, `git stash` the attempts and return to step 2 with new hypotheses.