Use when something is broken, a test fails unexpectedly, an error appears, or the user reports a bug or says something "doesn't work". Finds the root cause before changing code, instead of guessing at fixes.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Is that skill safe to install?
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
Are you the author of Investigate Bug?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/spar-ai-app-investigate-bug)
---
name: investigate-bug
description: Use when something is broken, a test fails unexpectedly, an error appears, or the user reports a bug or says something "doesn't work". Finds the root cause before changing code, instead of guessing at fixes.
---
# Find the root cause, then fix it once
Guess-and-check fixes pile up junk and hide the real bug. Don't change code until you can explain why it fails.
1. **Reproduce it.** Get the exact error, steps, input and environment. If the user gave a transcript or screenshot, read it fully. If you can't reproduce it, say so and gather more evidence (logs, a debug print, a minimal script) rather than guessing.
2. **Write a failing test** that captures the bug, when it's testable. It must fail before the fix.
3. **Trace to the cause.** Follow the data from input to the wrong output. Read the actual code paths; check recent changes with `git log -p` on the files involved. State the root cause in one or two sentences.
4. **Three-strike rule.** If two fixes haven't worked, stop. Re-read the evidence, list what you've assumed, and test those assumptions before a third attempt. Revert failed attempts so they don't linger.
5. **Fix the cause, not the symptom.** No special cases that hide the error, no swallowing exceptions, no retry loops around a deterministic bug.
6. **Verify.** The new test passes, the full checks pass, and the original steps no longer reproduce it.
7. **Look for siblings.** Search for the same mistake elsewhere and fix those too.
8. **Record it.** Add one line to `docs/LESSONS.md` if the cause was a wrong assumption another agent could repeat.
Tell the user in plain words: what was wrong, why, and what you changed.