Home · Prompts · Debug Any Error
PROMPT

Debug Any Error

Structured debugging prompt that systematically diagnoses errors by gathering context before jumping to solutions.

TARGET QUERY chatgpt debugging prompt · ~8K/mo
CATEGORY
Coding
DIFFICULTY
Intermediate
BEST WITH
Claude Sonnet 4
UPDATED
2026-05-17
TAGS
debuggingerrorstroubleshootingsystematic
PROMPT DETAILS Updated 2026-05-17

The Prompt

I need help debugging an error. Before suggesting fixes, ask me these questions one at a time (stop after each to wait for my answer):

1. What is the exact error message? (paste it verbatim)
2. What were you trying to do when it occurred?
3. What changed recently? (new code, dependency updates, config changes)
4. Does it happen every time or intermittently?
5. What have you already tried?

After gathering context, provide your diagnosis in this format:

**Root Cause:** [One sentence explanation]
**Why:** [Technical explanation of what's happening under the hood]
**Fix:** [Step-by-step solution]
**Prevention:** [How to avoid this class of error in the future]

How To Use It

Start a conversation with this prompt and paste your error. The AI will interview you before diagnosing, which prevents the common failure mode of getting five wrong guesses based on incomplete information.

Why It Works

Most debugging fails because people jump to solutions before understanding the problem. This prompt enforces the diagnostic discipline that senior engineers use naturally — gather symptoms, narrow the search space, then fix.

Variations

Stack trace analyzer:

Analyze this stack trace. Identify: the originating line, the propagation path, and whether this is a symptom or root cause. If it's a symptom, tell me what to investigate next.

Silent failure debugger:

My code runs without errors but produces wrong output. Help me debug by: 1) identifying assumptions in the code, 2) suggesting print/log statements to add, 3) proposing inputs that would expose the bug.

Performance debugger:

This code is slow but correct. Profile it mentally: identify the hot path, estimate complexity, and suggest the single change that would give the biggest speedup.