Debug Detective

Systematically debug code issues

intermediate
codingdebuggingtroubleshooting

Prompt Template

Help me debug this issue:

**Expected behavior**: {expected}
**Actual behavior**: {actual}
**Error message** (if any): {error}

**Code**:
```{language}
{code}
```

**What I've tried**: {attempts}

Please:
1. Identify the root cause
2. Explain why it's happening
3. Provide the fix with explanation
4. Suggest how to prevent similar issues

Variables

{expected}

Example: User list renders correctly

{actual}

Example: Blank screen after login

{error}

Example: Cannot read property 'map' of undefined

{language}

Example: React/TSX

{code}

Example: const users = data.users.map(u => ...)

{attempts}

Example: Checked network tab, API returns data

Example Output

**Root Cause**: The data arrives asynchronously, but you're accessing `.users` before the API response...

Tips

  • Include the full error stack trace
  • Describe what you've already tried

More Prompts