Skip to content

diagnose-before-fix

diagnose-before-fix

Builds a tight red/green feedback loop before changing code for hard bugs, regressions, or "it fails sometimes." Use when the user says diagnose, debug, reproduce, or root-cause; when failures are flaky or unclear; or before applying minimal-fix so the fix targets cause not symptom.

Category
Category: testing
  • debug
  • diagnose
  • reproduce
  • regression
  • bisect
  • flaky

Install this skill

npx github:yingkitw/skillsheet --remote --tool claude-code --only diagnose-before-fix

Fetches the latest published version from skillsheet.dev — the first run installs the package from GitHub, after that npx caches it.

Or use the standard CLI

npx skills add yingkitw/skillsheet --skill diagnose-before-fix

Works with any of the ~79 agents the skills CLI supports — add -a <agent> to pick one.

Related on the ecosystem

Peer skills on skills.sh and upstream repos (inspiration only — not shipped in this library).


name: diagnose-before-fix description: Builds a tight red/green feedback loop before changing code for hard bugs, regressions, or "it fails sometimes." Use when the user says diagnose, debug, reproduce, or root-cause; when failures are flaky or unclear; or before applying minimal-fix so the fix targets cause not symptom. category: testing keywords: debug, diagnose, reproduce, regression, bisect, flaky

Diagnose Before Fix

When to apply

Use when behavior is wrong, slow, or intermittent and the cause is not yet proven. Pair with minimal-fix only after a loop exists that can go red on the bug and green when fixed. Distilled from common diagnose/debug skills on skills.sh and agent playbooks; scoped for general codebases.

Core rule

No code changes for the root fix until one command reproduces the failure reliably (or you have explicitly stopped and listed what blocks a loop).

Phase 1 — Build the loop

Try seams in roughly this order:

  1. Failing test — unit, integration, or e2e that reaches the bug path.
  2. Scripted invocation — CLI with fixture input, curl against dev server, small replay file.
  3. Narrow harness — minimal subset of services/mocks that still hits the bug.
  4. Bisection — automated check across commits/versions when the bug appeared between known states.

Tighten the loop: faster, sharper assertion (symptom-specific), deterministic (seed time/RNG/network).

Flaky bugs

Raise reproduction rate (parallel runs, stress, logging) until the failure is debuggable, not necessarily 100%.

Cannot build a loop

Stop. Report what you tried. Ask for: environment access, captured logs/HAR/trace, or permission for temporary instrumentation. Do not guess-and-patch.

Done when: you can name one agent-runnable command that has been executed at least once and is red-capable for the reported symptom.

Phase 2 — Narrow

  • Bisect scope (file, commit, config flag) using the loop as judge.
  • One hypothesis at a time; change one variable per run.
  • Prefer evidence (logs, stack, diffs) over reading unrelated code.

Phase 3 — Hand off to fix

When the cause is identified:

  1. State cause + evidence in one short paragraph.
  2. Invoke minimal-fix or lean-implementation as appropriate.
  3. Invoke test-to-completion — lock the bug with a regression test using the same loop where possible.

Anti-patterns

  • Editing production paths "to see if it helps" before a repro exists.
  • Fixing only the assertion so the test passes without fixing behavior.
  • Absorbing unrelated cleanup into the same change as the bugfix.

Related skills

  • minimal-fix — Smallest correct change once cause is known.
  • test-to-completion — Definition of done includes green, relevant tests.
  • loop-triage — When many failures compete for attention first.