agentleFS
imMamdouhaboammarimMamdouhaboammar/matts-skills-into-chatgpt/skills/diagnosing-bugs/SKILL.md

diagnosing-bugs

Skill8 starsChanged 2 months agoMITView on GitHub

Diagnose hard bugs, intermittent flakes, and performance regressions using a tight feedback loop. Use when the user reports broken behavior, runtime exceptions, failing tests, flaky CI, or says \"debug this\" / \"diagnose this\" — even if no error message is provided. Do NOT use for routine test-driven feature development.

We split this skill into the rules it gives an agent

4 rules. 0 are common, 4 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 177 edited versions we read keep these.

  • 4

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Action: Run the loop to confirm reproduction, then systematically remove non-essential config, data, and steps.

    line 55
  2. Distinctive:

    Key Point: Every remaining line in the repro must be load-bearing (removing it turns the loop green).

    line 56
  3. Distinctive:

    Key Point: Use format: *"If X is the cause, then changing Y will make the symptom disappear."*

    line 61
  4. Distinctive:

    Action: Write the regression test, apply the minimal fix, verify the full suite, and purge all debug instrumentation.

    line 70

“Common” is measured: kept by at least 6 in 10 of the 177 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Diagnosing Bugs

A disciplined feedback-loop methodology for diagnosing and resolving hard bugs, intermittent flakes, and performance regressions.

Core Principle

Never guess or hypothesize before establishing a fast, deterministic, automated feedback loop that reliably reproduces the red failure.


Core Invariants

  1. Mandatory Red Loop Before Theory: Construct a fast, automated repro command and see it fail before formulating or testing any hypotheses.
  2. Credential Redaction First: Redact all keys, authorization headers, tokens, and secrets with <REDACTED> before displaying outputs or logs.
  3. Single Variable Instrumentation: Change only one variable at a time when probing hypothesis boundaries.
  4. Unique Debug Tagging: Tag all temporary diagnostic logs with a unique searchable prefix (e.g. [DEBUG-trace]) for complete cleanup before commit.
  5. Regression Test at Public Seam: Lock down the fix with a permanent test at a genuine architectural seam before declaring victory.

Architecture & Map of Content (MOC)

[ Build Tight Loop ] ──► [ Reproduce & Minimise ] ──► [ 3–5 Ranked Hypotheses ] ──► [ Targeted Probe ] ──► [ Fix & Regression Test ] ──► [ Clean ]
PhaseCore ObjectiveKey Deliverable
Phase 1: Build LoopConstruct automated pass/fail signalSingle executable command that goes red on this bug
Phase 2: MinimiseShrink failure to essential variablesMinimal load-bearing repro payload
Phase 3: HypothesiseFormulate 3–5 falsifiable predictionsRanked hypothesis table with testable predictions
Phase 4: InstrumentTest predictions with minimal probesTagged [DEBUG-...] logs or debugger inspection
Phase 5: Fix & TestLock down behavior at public seamPermanent automated regression test
Phase 6: CleanupRemove diagnostic scaffoldingVerified clean git status & passing test suite

Step-by-Step Procedure (TWI)

Step 1: Construct a Tight Feedback Loop (Phase 1)

  • Action: Build an automated runner (failing test, CLI fixture, curl script, or trace replay) that drives the bug path.
  • Key Point: The loop must be fast (< 5s), deterministic, and assert the user's exact symptom.
  • Inline Checklist:
    • Automated command exists and has been executed
    • Command goes red specifically on this bug symptom
    • Execution completes in seconds without manual intervention
  • Why: Staring at code without a feedback loop leads to guessing and confirmation bias.

Step 2: Reproduce and Minimise (Phase 2)

  • Action: Run the loop to confirm reproduction, then systematically remove non-essential config, data, and steps.
  • Key Point: Every remaining line in the repro must be load-bearing (removing it turns the loop green).
  • Why: Minimal repros shrink the hypothesis space and convert cleanly into permanent regression tests.

Step 3: Formulate Falsifiable Hypotheses (Phase 3)

  • Action: Generate 3–5 ranked hypotheses stating the explicit prediction each makes.
  • Key Point: Use format: "If X is the cause, then changing Y will make the symptom disappear."
  • Why: Single-hypothesis debugging anchors on first impressions and wastes turns.

Step 4: Instrument and Isolate (Phase 4)

  • Action: Insert tagged probes ([DEBUG-xxx]) or inspect values at key boundaries.
  • Key Point: Change only one variable at a time; measure baselines before tuning performance bugs.
  • Why: Changing multiple variables simultaneously confounds cause and effect.

Step 5: Fix, Verify, and Clean (Phases 5 & 6)

  • Action: Write the regression test, apply the minimal fix, verify the full suite, and purge all debug instrumentation.
  • Inline Checklist:
    • Regression test fails without fix and passes with fix
    • Original un-minimised repro confirmed green
    • All [DEBUG-...] tags purged from codebase
    • Root cause documented clearly in commit message

Anti-Rationalization Guardrails

Tempting RationalizationBinding RuleEngineering Rationale
"I think I see the bug in the code, let me fix it now."No edits without an automated red feedback loop.Fixing code based on inspection often addresses symptoms while missing root causes.
"The bug is non-deterministic so we cannot automate a test."Increase reproduction rate (stress, loops, pinned clocks).A 50% flake rate is debuggable; raise reproduction frequency until testable.
"I'll add logs everywhere and inspect all outputs."Targeted, tagged probes only.Untargeted logging floods context and creates cleanup debt.
"The fix works in manual testing, skip the regression test."Mandatory automated regression test at public seam.Without a regression test, the bug will silently return in future refactors.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.