Help us improve
Share bugs, ideas, or general feedback.
From grimoire
Isolates root cause of bugs through systematic hypothesis-and-test cycles. Active before any fix is written — use when behavior diverges from specification.
npx claudepluginhub jeffreytse/grimoire --plugin grimoireHow this skill is triggered — by the user, by Claude, or both
Slash command
/grimoire:diagnose-bugThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Isolate the root cause of a bug through systematic hypothesis-and-test cycles before writing any fix.
Hypothesis-driven debugging methodology with ranked hypotheses, git bisect strategies, instrumentation planning, and minimal reproduction design. For intermittent failures, unclear stacktraces, performance regressions, and non-obvious bugs requiring systematic investigation.
Disciplined methodology to isolate bugs through hypothesis-driven testing. Form hypotheses, test them with minimal changes, narrow scope systematically. Use when bugs are unclear or reproduce intermittently.
Applies Zeller's scientific method to debugging: reproduce, hypothesize, binary search to isolate, fix root cause, add regression test. Activates on bug/error/crash/stack trace.
Share bugs, ideas, or general feedback.
Isolate the root cause of a bug through systematic hypothesis-and-test cycles before writing any fix.
Adopted by: Mozilla (engineering blog documents bisect-driven debugging as standard practice), Google SRE (Site Reliability Engineering book, O'Reilly 2016 — "debugging is hypothesis testing"), Linux kernel development (git bisect used as primary regression isolation tool since 2005).
Impact: Hunt (2019, "The Pragmatic Programmer" 20th anniversary) estimates that developers spend 35–50% of time debugging. Studies at Microsoft Research (Begel & Simon, 2008) found that programmers who skip reproduction steps and jump to fixes re-open the same bug 2.4× more often than those who first establish a minimal reproduction. git bisect can isolate a regression among 1,000 commits in 10 binary search steps.
Why best: "Fix first, understand later" leads to patches that mask symptoms rather than causes — the bug resurfaces under different conditions. Systematic isolation — reproduce, shrink, hypothesize, test — is the only approach that guarantees the fix targets the actual cause. It is strictly superior to random trial-and-error or reading code top-down hoping to spot the issue.
Sources: Pragmatic Programmer (Hunt & Thomas), Google SRE Book (Beyer et al., O'Reilly 2016), Mozilla Engineering Blog, Zeller "Why Programs Fail" (2009)
Before touching code, establish a reproducible test case:
If you cannot reproduce it, do not proceed to fixing. Ask for more information.
Shrink the reproduction to the minimum that still triggers the bug:
Answer these questions before hypothesizing:
If the bug is a regression (worked before, broken now):
git bisect start
git bisect bad # current commit is broken
git bisect good <known-good> # last known-good commit or tag
# git bisect runs binary search; test each commit, then:
git bisect good # or: git bisect bad
# Repeat until bisect identifies the introducing commit
git bisect reset
If git bisect is not applicable, apply the binary search principle manually: comment out half the code path, confirm which half contains the bug, repeat.
State a falsifiable hypothesis: "The bug occurs because X when Y."
Example: "The pagination breaks because offset is computed before the filter is applied, so it counts unfiltered rows."
Do not form multiple hypotheses at once — test one at a time.
Add targeted logging, assertions, or a unit test that would fail if your hypothesis is correct:
Before fixing, distinguish:
Fix the root cause. Fixing only symptoms leaves the system brittle.
For bugs that do not reproduce deterministically:
go test -race, ThreadSanitizer, Valgrind/Helgrind)Good hypothesis: "The session expires prematurely because the token TTL is read from config at startup rather than per-request, so config reloads do not take effect."
Bad hypothesis: "Something is wrong with the auth code."
Bisect finding root cause:
git bisect identified commit a3f9c12 as the first bad commit.
Commit message: "refactor: centralize config loading"
Root cause: Config is now cached at startup; per-request refresh was silently removed.