evidence-first-agent-rules/.claude/rules/evidence-debug-by-diffing.md
SHA-256 ad8bda48a88e41f4353c850a31396f20d64a9bc8462922fc82a21eee5678c2d7 · 1,385 bytes
Rule: loaded automatically into every session once installed.
# Debug regressions by diffing, not guessing
When something used to work and now doesn't, the answer is almost always in what changed. Theorizing first wastes
attempts: one location bug in a mobile app survived more than fifteen guessed fixes, and the cause was visible in the
diff against the last working version the whole time.
**Rule.** Before writing any fix for a regression:
1. Find the last known-good state: `git log --oneline` for the file or feature, a tag, or a deploy record.
2. Read the change: `git show <good>`, then `git diff <good> HEAD -- <relevant paths>`.
3. If the range is large, bisect (`git bisect start`, mark good and bad, test each step) instead of reading
everything.
4. State which change you believe caused the regression and why, then fix that change.
Only fall back to open-ended investigation when there is no known-good version to compare against. If you do, say so.
**Protect the user's work.** Reading history (`git log`, `git show`, `git diff`) changes nothing. Anything that changes
the checked-out files (`git bisect`, `git checkout`, `git switch`, `git stash`) needs a clean working tree: run
`git status` first, and if there are uncommitted or untracked changes, ask the user before going further. Finish a
bisect with `git bisect reset`. This rule never authorizes `git reset --hard`, `git clean`, rewriting history or
force-pushing.
Shown as plain text. Invisible or direction-changing characters are displayed as <U+XXXX>.