Debug · Claude Prompt

Bug Detective

Systematically debugs issues by asking the right questions and tracing root causes.

What it does

The Bug Detective prompt refuses to guess. It runs a four-step methodology — restate the bug, list ranked hypotheses, name the first high-information check, then narrow with evidence — until the root cause is identified. When the cause is clear, it proposes the minimal fix, a regression test that would have caught this class of bug, and flags related bugs likely to exist elsewhere in the code. No 'try this random thing' responses. No 'probably a cache issue' guesses.

What the prompt generates

After Step 1 (restatement) and any clarifying questions, Claude outputs a ranked list of 3–5 specific hypotheses: H1 (most likely), H2, H3, etc. Each hypothesis comes with one-sentence reasoning and one concrete check that would confirm or eliminate it. Step 3 picks the single highest-information, fastest, least-destructive check and tells you exactly what evidence to collect. You share the evidence; Claude re-ranks, eliminates what the evidence killed, and proposes the next check. Loop until the cause is clear. Step 5 delivers the minimal fix (smallest change addressing root cause), a specific test that would have caught it, and a list of other places in the codebase likely to have the same class of bug.

Who should use it

Engineers stuck on intermittent bugs they cannot reproduce. On-call engineers investigating production incidents who need a structured triage. Solo developers without a debugging partner. Senior engineers mentoring juniors — the prompt teaches the scientific method through use. Works for any stack: frontend, backend, mobile, infrastructure, distributed systems.

What it solves

Most AI-assisted debugging spirals into try-this-try-that. The fix that works is rarely the fix that was understood. This prompt forces the conversation into hypothesis → check → evidence → fix, so you end up with an actual root cause understanding and a regression test — not a random change that made the symptom go away until it reappears in production six weeks later.

How to install

Which tool are you using?

Not sure? Claude.ai is the website. Claude Code is the command-line tool you install separately. Cursor is a code editor that reads .cursorrules.

  1. 01

    Open Claude.ai

    Go to claude.ai and start a new conversation.

  2. 02

    Copy the prompt

    Click the Copy button on the prompt file below.

  3. 03

    Paste the prompt

    Paste into the chat input with Cmd+V / Ctrl+V. Do not send yet.

  4. 04

    Describe your bug

    Replace [DESCRIBE YOUR BUG HERE] with your actual bug report. Include: what you did, what you expected, what happened, platform, and any error messages. Be specific — vague descriptions get slower hypothesis convergence.

    If the bug is intermittent, say so. If you have recent changes that might be related, mention them.

  5. 05

    Send and run Step 3

    Claude will produce hypotheses and name the single first check to run. Execute that check and paste the evidence back into the chat. Claude narrows the list, proposes the next check, and repeats until the root cause is identified.

    Do not ask Claude to skip straight to the fix. The method only works if you stay in the loop.

The claude prompt file

Copy the full contents below, or download the file directly.

bug-detective.txt
bug-detective.txt
You are a debugging specialist with deep experience in distributed systems, mobile apps, and frontend bugs. You do not guess. You form hypotheses and eliminate them with evidence. Follow this exact methodology. Do not skip steps. Do not propose a fix before you have evidence. # Step 1 — Restate the bug In one sentence, restate the bug as I described it. If my description is ambiguous or missing critical details, ask up to 3 clarifying questions BEFORE proceeding. Typical clarifications:- Exact reproduction steps- Platform, environment, version- Frequency (always / intermittent / one-time)- What was the last known working state- Any recent changes around the time the bug appeared Wait for my response before moving to Step 2. # Step 2 — Hypotheses List 3 to 5 specific hypotheses for the root cause. Rank them by likelihood and explain the reasoning briefly for each. Format: **H1 (most likely)** — <hypothesis in one sentence>**Why**: <one sentence on why this is most likely>**Check**: <one concrete, minimal check that would confirm or eliminate this> Repeat for H2, H3, H4, H5. Do not list vague hypotheses like "something wrong with state". # Step 3 — First check Suggest the single check we should run first. It should be:- Fast (takes less than 5 minutes)- High information (narrows the hypothesis space significantly regardless of outcome)- Non-destructive (does not alter production state) Tell me exactly what to collect:- Which log line, which variable, which network response- Exact format (timestamp + value, not just "check the log") Wait for my evidence. # Step 4 — Narrow and iterate After I share evidence:1. Update the hypothesis ranking. Remove the eliminated ones and explain why.2. Propose the next check.3. Repeat until the root cause is identified. # Step 5 — Root cause + fix Once the root cause is clear, propose:1. **The minimal fix** — the smallest code change that addresses the root cause without introducing new risk2. **A test that would have caught this** — specific, with setup and assertions3. **Related bugs** — other places in the codebase likely to have the same class of bug, with file hints # Rules- Never propose "try changing X" without a hypothesis and a check- Never suggest "rewrite the component" as a fix — always the minimal change- If you get stuck, admit it and propose a new class of hypothesis rather than guessing- Stay in the method. Do not skip to the fix. Bug to investigate:[DESCRIBE YOUR BUG HERE]

Example output

What Claude does before and after you install this claude prompt.

Without this claude prompt

Claude suggests five random things to try. None work. You waste an hour.

With this claude prompt

Claude lists 4 hypotheses ranked by likelihood. The first check (log timestamp) takes 30 seconds and eliminates 3 of them. Root cause found in 5 minutes.

Customization tips

For production incidents, add a section requiring Claude to include rollback options alongside the fix. For intermittent bugs, ask the prompt to propose a reproduction harness after Step 4. Teams with structured postmortem formats can extend the Step 5 output to match their RCA template.

Related resources

Frequently asked questions

Does it work for any programming language?

Yes. The hypothesis-driven method is language-agnostic. It works for frontend, backend, mobile, infrastructure, and distributed systems.

Does it replace a debugger?

No. It guides the investigation — which check to run, what evidence means, which hypothesis to eliminate. You still run the debugger, tests, or production queries.

Will it just guess a fix?

No — that is the entire point. The prompt explicitly forbids proposing a fix without a confirmed hypothesis. If Claude tries, remind it of the method and it will step back.

Can it handle distributed system bugs?

Yes, but share the logs, traces, and topology. Distributed bugs need cross-service evidence — without it, hypotheses are shallow.

Does it write a postmortem?

It outputs the root cause, fix, and regression test, which is most of a postmortem. Pair with the README Writer prompt for a full RCA document.

Want more like this?

Browse the full RohanKit library — free resources for Claude and Cursor.

Back to RohanKit