Back to prompts
Coding & Developmentintermediate
4.9
The Prompt That Turns AI Into a Senior Debugger
Don't just fix the bug. Understand why it happened, how to prevent it, and what else might break.
Copy & Paste this prompt
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.
#debugging#root-cause-analysis#code-quality#best-practices
Works with
chatgptclaudecopilot
💡 Pro Tips
- •Works with any language: JavaScript, Python, React, SQL, Rust, Go...
- •Include the full function — context matters for root cause analysis
- •Follow up with 'can you write tests that would have caught this?'
✨ Example Output
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 responses