Fix on top of fix on top of fix
补丁摞补丁
The agent stacks unverified fixes, each aimed at the symptom the previous fix caused, and never goes back to the root cause.
Applies to: Claude Code · Cursor · Codex · Copilot agent
Symptom
Five rounds of "now try this", a diff full of special cases, and the original bug still there, or a new one.
Why it happens
Each attempt starts from the latest error message, not from a fresh look at the cause, and the first guess is rarely revisited. agent-failure-modes names AFM-4 Patch Spiral and the related AFM-9 First-Hypothesis Anchoring.
Example
Illustrative.
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 [...]
Copy-paste fixes
Pick the files for the agents you use. Snippets are in English so they work in any repo.
Rules
Claude Code: add to 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.
Rules
Codex, Copilot coding agent and others: add to 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 rule
Cursor: project rule
.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.
Skill
/debug skill: reproduce, hypothesize, verify
.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.