Prompt

Bug Debugging Helper

debuggingtroubleshootingerrors

Debugging Helper: Find and Fix Bugs Faster

Debugging can consume 50% of development time. This AI-powered debugging assistant helps you identify root causes and implement solutions faster by systematically analyzing error context.

Full Prompt
Systematically diagnose a software bug by analyzing the gap between expected and actual behavior, then provide ranked solutions with root-cause explanations.

DEBUGGING PROCESS:

1. Problem Characterization
   - Restate the bug in precise terms: what happens vs. what should happen
   - Classify the bug type (logic error, runtime exception, race condition, state management, integration issue, environment mismatch, etc.)
   - Identify whether the bug is deterministic or intermittent

2. Root Cause Analysis
   - Trace the execution path through the provided code, narrating what happens at each step
   - Identify the exact point where behavior diverges from expectation
   - Consider multiple hypotheses and evaluate each against the evidence (error message, observed behavior, code context)
   - Check for common culprits: off-by-one errors, null/undefined references, type coercion, async timing, scope issues, mutation of shared state

3. Solution Development
   - Provide the primary fix with a clear code change
   - Explain WHY this fix resolves the root cause (not just what to change)
   - If multiple root causes are plausible, provide a ranked list of solutions with diagnostic steps to confirm which applies
   - Include any necessary guard clauses, error handling, or defensive checks

4. Prevention Guidance
   - Suggest tests that would have caught this bug
   - Recommend patterns or practices to prevent similar bugs in the future
   - Note any related areas in the code that may have the same vulnerability

OUTPUT CONSTRAINTS:
- Always explain the reasoning chain, not just the answer
- If the information provided is insufficient to diagnose with confidence, state exactly what additional information is needed and why
- Provide copy-paste-ready code fixes, not just descriptions
- If "What I've Already Tried" is provided, explain why those attempts did not work before giving new solutions
- Never suggest "just restart it" or "clear cache" without a causal explanation

FORMAT:
## Diagnosis
[Root cause explanation in plain language]

## Why This Happens
[Technical trace through the code showing the failure point]

## Solution
[Primary fix with code]

## Alternative Hypotheses (if applicable)
[Other possible causes if diagnosis is uncertain]

## Prevention
[Tests and practices to avoid recurrence]

---

MY INFO:

Expected Behavior: (required)

Actual Behavior: (required)

Error Message (if any): (optional - include full stack trace when available)

Code Context: (required)

Programming Language / Framework: (optional)

What I've Already Tried: (optional)

Environment Details (OS, runtime version, browser): (optional)

Is the bug deterministic or intermittent?: (optional)

How It Works

Provide:

  • Expected behavior: What should happen
  • Actual behavior: What's actually happening
  • Error message: The exact error text
  • Code context: Relevant code snippets
  • What you've tried: Previous debugging attempts

Common Bug Categories

Logic Errors: Code runs but produces wrong results Runtime Errors: Crashes during execution Syntax Errors: Code won't compile/parse Type Errors: Wrong data types Async Errors: Race conditions, timing issues

Debugging Best Practices

  1. Reproduce consistently: Ensure you can trigger the bug reliably
  2. Isolate the problem: Narrow down the failing code
  3. Check assumptions: Verify inputs and state
  4. Read error messages carefully: They often point to the issue
  5. Use debugger tools: Step through code execution

Stop guessing and start systematically solving bugs.