Root Cause Bug Investigator
Guides a systematic investigation of a bug from symptom to root cause, avoiding quick patches that mask the real problem, and produces a targeted fix.
Developers debugging tricky issues who want a structured diagnostic process instead of guessing-and-checking, especially for bugs that have resisted a first attempted fix.
You are a senior engineer known for finding the actual root cause of bugs instead of patching symptoms.
Bug description (what's happening vs. what should happen): {{bug_description}}
Relevant code: {{code_snippet_or_file}}
Error message/logs (if any): {{error_logs}}
What I've already tried: {{attempted_fixes}}
Do the following:
1. List the most likely root causes ranked by probability, based on the symptom, code, and logs (not just the first plausible guess).
2. For the top-ranked cause, trace through the exact execution path that leads to the bug, referencing specific lines or logic in the provided code.
3. Propose a fix that addresses the root cause, not just the symptom, and explain why it's more durable than a surface-level patch (e.g., adding a null check versus fixing why the null occurs in the first place).
4. Suggest one test case that would have caught this bug before it reached this point, so it doesn't resurface elsewhere.How to use
- Describe the bug clearly: what's happening versus what should happen.
- Paste the relevant code and any error logs or console output.
- Mention what you've already tried so the investigation doesn't repeat dead ends.
- Apply the root-cause fix rather than any quick patches suggested along the way, and add the recommended test case.
Example input
Bug: A form submits successfully sometimes but silently fails other times with no error shown. Code: [React form component with an async submit handler]. Error logs: Console shows an unhandled promise rejection intermittently. Attempted fixes: Added a try/catch around the submit call, didn't help.
Example output
A ranked list of likely causes (race condition in state updates ranked highest, followed by an unawaited async call), a traced execution path showing the submit handler doesn't await a nested API call before checking success state, a fix adding a proper await and moving the try/catch to wrap the actual async operation rather than the outer function, and a suggested test case simulating a slow network response to catch the race condition.
Customization tips
- — For intermittent/flaky bugs, mention that explicitly so the investigation prioritizes race conditions and timing issues over deterministic logic errors.
- — If you suspect a specific cause but aren't sure, state your hypothesis so it can be confirmed or ruled out explicitly.
- — For production bugs, ask for the fix to include a rollback-safe version if the root cause requires a larger refactor.
Tags
FAQ
What is this prompt for?
How should I customize it?
Are there any limitations?
How is it different from a basic prompt?
Related Prompts
All Coding & Debugging prompts →Code Review Simulator
Simulates a thorough senior engineer code review, flagging bugs, edge cases, readability issues, and security concerns with specific, actionable comments.
Legacy Code Explainer & Refactor Planner
Explains what an unfamiliar or legacy piece of code actually does, then proposes a safe, incremental refactor plan instead of a risky full rewrite.
Flaky Test Root Cause Analyzer
Investigate nondeterministic tests by classifying failure patterns, controlling hidden inputs, and designing a reproducible fix.
Related Skills
Code Refactor Advisor
Reviews a code snippet and returns a prioritized refactor plan — readability, structure, and performance issues, each with a concrete fix.
Debugging and Root Cause Analyst
Investigate software defects systematically using evidence, hypotheses, reproduction, instrumentation, isolation, and verification.
Code Review & Refactor Assistant
Reviews a pasted code snippet for bugs, readability, and performance issues, then delivers a prioritized refactor with explanations for each change.
Related Articles
How to Test AI-Generated Code Before You Trust It
Learn how to review and test AI-generated code before using it in production, including functionality, security, edge cases, permissions, and regression checks.