Debug Like a Detective — Systematic Bug Hunter
Turn vague 'it doesn't work' into a systematic debugging process that finds the root cause fast.
Don't just fix the bug. Understand why it happened, how to prevent it, and what else might break.
You are a senior software engineer doing a root cause analysis. Here's my bug: Error: [PASTE ERROR MESSAGE] Code: [PASTE RELEVANT CODE] Expected: [WHAT SHOULD HAPPEN] Actual: [WHAT ACTUALLY HAPPENS] Analyze this in 5 layers: 1. IMMEDIATE FIX — patch that works now 2. ROOT CAUSE — why this actually happened 3. SIMILAR BUGS — where else in this pattern could the same issue occur? 4. PREVENTION — what rule/pattern/test would have caught this before production? 5. ARCHITECTURE — does this reveal a design flaw? Should something be refactored? Show code for each fix. Be specific.
Input: "TypeError: Cannot read property 'map' of undefined"
1. IMMEDIATE FIX: data?.items?.map() // optional chaining
2. ROOT CAUSE: API returns { items: null } on empty results instead of { items: [] }
3. SIMILAR BUGS: Check getUserOrders(), getNotifications() — same API pattern
4. PREVENTION: Add Zod schema validation on all API responses; Default empty arrays in API response types
5. ARCHITECTURE: Create a typed API client wrapper that normalizes all responsesThis prompt leverages systematic root-cause analysis methodology, forcing the AI to trace execution paths rather than guess at symptoms. By structuring the debugging process like a senior engineer's mental model, it produces actionable insights instead of generic suggestions.
Use when you've spent more than 30 minutes on a bug and need fresh eyes, when you're dealing with intermittent failures or race conditions, or when you need to understand why a fix works—not just what to change.
You'll get a structured diagnosis identifying the root cause, a clear explanation of the failure mechanism, specific code fixes with before/after examples, and preventive measures to stop similar bugs from recurring.
Turn vague 'it doesn't work' into a systematic debugging process that finds the root cause fast.
Paste any error message and get a clear, jargon-free explanation plus actionable fix suggestions.
Design a complete error handling system for your app. Custom error classes, proper logging, user-friendly messages, retr…
From chaos to clarity — find the real "why."
Generate comprehensive unit, integration, and edge case tests for your code — with 90%+ coverage.