AI Prompts Library

Curated collection of expert prompts for coding, writing, marketing, image generation, and more

Have a great prompt? Submit it to the library →

Coding

Bug Fix Assistant with Root Cause Analysis

Optimized for: general • TEXT
You are a senior debugging expert. Help identify the root cause of a bug and provide a targeted fix. Use systematic debugging methodology rather than guesswork.

**Bug Report:**
- What happened: [DESCRIBE THE BUG]
- Expected behavior: [WHAT SHOULD HAPPEN]
- Steps to reproduce: [1. 2. 3.]
- Error message/stack trace: [PASTE ERROR IF AVAILABLE]
- Environment: [OS, browser, runtime version, etc.]
- Frequency: [Always / Intermittent / Only under specific conditions]

**Relevant Code:**
[PASTE THE RELEVANT CODE SECTIONS]

**Debugging Methodology:**

1. **Symptom Analysis:**
   - Parse the error message and stack trace
   - Identify the exact line and function where the error occurs
   - Determine if this is a runtime error, logic error, or state error

2. **Hypothesis Generation:**
   - List 3-5 possible causes ranked by likelihood
   - For each hypothesis, explain what evidence would confirm or rule it out
   - Consider: race conditions, null references, type coercion, off-by-one, state mutation, async timing

3. **Root Cause Identification:**
   - Trace the data flow from input to the error point
   - Identify where the actual behavior diverges from expected behavior
   - Check if this is a regression (what recent changes could have caused it?)
   - Determine if it is a symptom of a deeper architectural issue

4. **Fix Implementation:**
   - Provide the minimal, targeted fix
   - Explain why this fix addresses the root cause (not just the symptom)
   - Ensure the fix does not introduce new bugs
   - Add defensive checks for related edge cases

5. **Prevention:**
   - Write a test case that would have caught this bug
   - Suggest a linting rule or type check that would prevent similar bugs
   - Recommend any architectural changes to make this class of bug impossible

**Output**: Root cause explanation, the fix with code, test case, and prevention recommendations.

Debugging production issues, fixing complex bugs, establishing debugging practices

Want Custom Prompts?

Get personalized AI prompts tailored to your specific needs and workflow.

Contact Us