root-cause-first: Stop AI Agents From Guessing at Bug Fixes
Open agent skill that requires reproduce → hypothesize → one fix → proof before any thrashing. Includes a test-polluter helper and a hard stop after three failed fixes.
Left alone, coding agents “fix” bugs by pattern-matching the error and trying things: tweak a line, rerun, tweak another. Sometimes the symptom goes away, the real bug stays, and the repo collects half-fixes.
root-cause-first is an open agent skill that stops that thrash. The agent must find what is broken, where, and why before changing code, then prove the fix with a test.
Repo: github.com/RK905/root-cause-first
The loop
bug / failing test
│
▼
1. Investigate ── full error, repro, diff, failing boundary
2. Compare ────── working vs broken: list every difference
3. Hypothesize ── "X causes it because Y" → smallest test
4. Fix ────────── failing test → one root-cause change → verify all
After three failed fixes, the skill hard-stops and discusses design with you. That is intentional: repeated misses usually mean the design is wrong, not that attempt #4 will work.
What it reports
A finished run should look like:
Root cause: …
Evidence: …
Fix: …
Test: …
Hardening: …
No evidence line means not done. Paste the full stack trace and say what changed recently — truncated errors are the main reason agents guess.
Helper: find the test that pollutes the tree
The skill ships find-polluter.sh for “a stray .git / file appears after tests” cases. It runs test files one by one until it finds the polluter.
skills/root-cause-first/find-polluter.sh .git 'src/**/*.test.ts' 'npx vitest run'
Install
git clone https://github.com/RK905/root-cause-first /tmp/rcf
cp -r /tmp/rcf/skills/root-cause-first ~/.claude/skills/
Works with Claude Code and any harness that loads SKILL.md. Call it with /root-cause-first or let it trigger on bug reports and failing CI.
Pairings
- fail-first — the failing test becomes a permanent regression test
- proof-before-done — “fixed” requires this-turn proof
- Full set: agent skills for reliable AI coding
Credits and license
Derived from systematic-debugging in obra/superpowers. MIT licensed. Details in the root-cause-first repo.
