Coding & Technical
Bug Investigation Framework
Systematically investigate and debug issues using the scientific method applied to software.
When to use this prompt
When investigating bugs that aren't immediately obvious, especially production issues or intermittent failures.
The Prompt
You are a senior engineer with expertise in systematic debugging. Help me investigate this bug using the scientific method.
BUG REPORT:
- Symptom: {{symptom}}
- Steps to reproduce: {{steps}}
- Expected behavior: {{expected}}
- Actual behavior: {{actual}}
- Environment: {{environment}}
- Frequency: {{frequency}}
- First occurred: {{first_occurred}}
- Error messages/logs: {{logs}}
---
## BUG INVESTIGATION REPORT
### 1. Problem Statement
[Restate the bug clearly and specifically]
**Severity assessment:**
- User impact: [Low/Medium/High/Critical]
- Frequency: [Rare/Occasional/Frequent/Always]
- Workaround exists: [Yes/No]
→ Priority: [P0/P1/P2/P3]
---
### 2. Information Gathering
**What we know:**
1. [Fact 1 - verified]
2. [Fact 2 - verified]
**What we don't know yet:**
1. [Question 1]
2. [Question 2]
**Reproduce reliability:**
- [ ] Can reproduce consistently
- [ ] Intermittent (X% of attempts)
- [ ] Cannot reproduce yet
---
### 3. Hypotheses
**Hypothesis 1: [Theory]**
- Evidence for: [What supports this]
- Evidence against: [What contradicts this]
- Test to confirm/reject: [Specific experiment]
**Hypothesis 2: [Theory]**
- Evidence for:
- Evidence against:
- Test to confirm/reject:
**Hypothesis 3: [Theory]**
- Evidence for:
- Evidence against:
- Test to confirm/reject:
**Most likely hypothesis:** [Which and why]
---
### 4. Investigation Plan
**Step 1:** [Action to narrow down]
- Expected result if Hypothesis 1 is correct: [X]
- Expected result if Hypothesis 2 is correct: [Y]
**Step 2:** [Next action based on Step 1 results]
**Step 3:** [Continue narrowing]
---
### 5. Debugging Checklist
**Basic checks:**
- [ ] Reproduce in clean environment
- [ ] Check recent changes (git blame/history)
- [ ] Review related logs
- [ ] Test with minimal reproduction case
**Common culprits to check:**
- [ ] Race condition / timing issue
- [ ] Null/undefined handling
- [ ] State management
- [ ] Cache issues (stale data)
- [ ] Environment differences
- [ ] External dependency changes
- [ ] Data format/encoding issues
- [ ] Permission/authentication issues
---
### 6. Logging & Debugging Strategy
**Add logging at:**
1. [Location] — To verify: [What we're checking]
2. [Location] — To verify: [What we're checking]
**Breakpoints to set:**
1. [Location] — Watch: [Variables/state to inspect]
---
### 7. Similar Past Issues
[Search codebase/tickets for similar bugs]
- [Similar issue 1] — Resolution: [How it was fixed]
- [Similar issue 2] — Resolution: [How it was fixed]
---
### 8. Root Cause (once found)
**The bug:**
[Clear explanation of what's actually wrong]
**Why it wasn't caught:**
[How this slipped through - for future prevention]
**The fix:**
```{{language}}
[Code fix]
```
**Verification:**
- [ ] Bug no longer reproduces
- [ ] Related functionality still works
- [ ] Added test to prevent regression
---
### 9. Prevention
**Test to add:**
```{{language}}
[Test case that would have caught this]
```
**Process improvement:**
[What could prevent similar bugs?]Try it in:
Variables to customize
| Variable | Description | Example |
|---|---|---|
{{symptom}} | What's going wrong | Users report being logged out randomly |
{{steps}} | Steps to reproduce | 1. Log in 2. Wait 5+ minutes 3. Try to access protected page |
{{expected}} | Expected behavior | User should remain logged in for 24 hours |
{{actual}} | What actually happens | User is redirected to login after ~5 minutes |
{{environment}} | Environment details | Production, Chrome 120, macOS |
{{frequency}} | How often it occurs | Affects ~30% of users |
{{first_occurred}} | When it started | After deploy on Jan 15 |
{{logs}} | Relevant logs or errors | [Paste error messages or log snippets] |
Expected output
Systematic investigation report with hypotheses, test plan, and root cause analysis.
Variations
Production incident
Production incident: {{incident}}. Help me triage: 1) Immediate mitigation options (buy time), 2) Quick investigation steps (5 min), 3) Likely root causes based on symptoms, 4) Rollback considerations. Time is critical—prioritize actionable steps.