debug

A set of rules for finding the root cause of software problems using reproduction, evidence, and controlled changes.

In plain words
What is it for?
Use it for bug reports, stack traces, failing tests, regressions, crashes, hangs, memory leaks, incorrect output, and environment-specific failures.
Why use it?
It reduces guesswork and helps prevent fixes that only hide symptoms or create new bugs. The rules require proving that the fix removes the original failure.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/ujjwal502/debugduck/debug
Clone the repo
git clone --depth 1 https://github.com/ujjwal502/debugduck

Made for: Cursor.

Per session 57 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,186 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00057 $0.01186
Opus 5 $0.00028 $0.00593
Sonnet 5 $0.00011 $0.00237
Haiku 4.5 $0.00006 $0.00119

Measured yesterday against content hash d9e1d17bce4b, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

debug scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/debug.mdc · 88 lines

How it starts

The opening of the file, as written. The whole thing — 88 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Debug — systematic root-cause debugging

Full procedure and stack-specific playbooks live in skills/debug/. Read skills/debug/SKILL.md first, then load only the reference files relevant to this bug.

Prime directives

  1. Reproduce before you diagnose. Diagnose before you fix.
  2. The bug is where the evidence points, not where it would be convenient. Intuition generates hypotheses; it never concludes.
  3. One variable at a time. Simultaneous changes destroy causality.
  4. Binary search beats reading — code path, git history, input, config, timeline.
  5. A root cause explains 100% of the observed evidence. Unexplained details mean you're not done.
  6. Prove the fix by toggling it: revert → bug returns; reapply → bug gone.
  7. Never suppress a symptom you don't understand — no empty catch blocks, blind ?., retries, timeout bumps, or # type: ignore as a "fix".
  8. Label claims [observed] / [inferred] / [assumed].

The six phases

  1. Reproduce — deterministic, minimal, fast command. If it only fails in CI/prod, that environment difference is the primary lead. If you truly can't reproduce, say so and switch to evidence-mining; do not fix on spec.
  2. Observe — read the entire error, stack traces bottom-up to the deepest frame you own. Logs, network, exit codes, DB state. No theorizing before looking.
  3. Localizedefault: trace the whole path in one pass (skills/debug/references/trace-first.md). Instrument every checkpoint from entry to symptom at once, numbered CP01…CPnn, write down what each should print, run once, and find the first checkpoint where actual ≠ expected; everything upstream is then ruled out. After instrumenting, stop and hand over the run command — do not guess a fix while waiting for the output. Fall back to bisection (midpoint probes, git bisect run <repro>, halving the input, working-vs-broken diff) when you can't re-run, the path is enormous, or logging perturbs the bug.
  4. Explain — write the causal chain root → symptom. Ask "why" until you reach something worth fixing (the null check isn't the cause; why it was null is).
  5. Fix — at the root, at the right layer, minimal. No opportunistic refactors in a bug fix.
  6. Prove — original repro passes; toggle test; regression test verified to fail on the old code; broader suite green; grep for the same bug elsewhere; remove all instrumentation.

Read the full file on GitHub · 88 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 88 lines · 57 tokens per session scan A d9e1d17bce4b

Subscribe to this mod's changes

debug is a cursor rule published in the GitHub repository ujjwal502/debugduck (4 stars, last pushed 24d ago), licensed MIT. It adds 57 tokens to every session and 1,186 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.