Debug mantra

From ksmaster03/claude-canfly-skill · View interactive version

Debug mantra is an AI agent skill from the GitHub repository ksmaster03/claude-canfly-skill. Four-mantra debugging discipline — reproduce, trace the fail path, falsify the hypothesis, cross-reference every breadcrumb. Recite the mantra block verbatim at the start of any debugging session, then apply the four steps in order before proposing any fix. Trigger on /debug-mantra and proactively w

How to use this skill

Skill file

Debug Mantra

Four-step discipline for any debug session. Recite verbatim, then apply in order.

Recite this — verbatim, as the first thing in your first response

Mantra:

1. First is reproducibility. Can the issue be reproduced reliably?

2. Know the fail path. Debugger first; then source trace + knob enumeration; then in-code instrumentation.

3. Question your hypothesis. What would disprove it?

4. Every run is a breadcrumb. Cross-reference all of them.

Then begin work.


1. Reproduce reliably

Build a runnable repro before anything else.

Target: a fast (1–5 s), deterministic pass/fail signal. Pin time, seed the RNG, freeze network, isolate filesystem.

2. Know the fail path

Once reproducible, find where the code breaks and what stops it from breaking. The differential narrows the search. Try in this order — escalate only when the prior tactic fails.

  1. Attach a debugger. If the env supports it, attach and step to the failure site. One breakpoint beats ten logs. Do this before turning any knobs.
  2. Source trace + knob enumeration. If no debugger (or it can't reach the bug), trace the code path end-to-end and list every knob that can influence the outcome:

Each knob is a candidate axis to flip in the differential. Flip one at a time.

  1. In-code instrumentation. If outside knobs can't move the failure, go inside: printf / log statements at the suspected fail site, dump the relevant internal state. Tag every probe with a unique prefix (e.g. [DBG-a4f2]) so cleanup is a single grep. Let the trace show where reality diverges from your model.

3. Falsify the hypothesis

When a candidate root cause surfaces, scrutinise it before testing it.

4. Every run is a breadcrumb

Maintain a running ledger of every experiment in this session. Each entry: what changed, what happened, what it ruled in or out.


Operating rules

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.