Systematic Debugging Analysis
The review date covers the prompt content, not testing against specific AI models or versions.
Description
A structured prompt for investigating bugs, separating evidence from hypotheses, and proposing a small fix you can verify.
The Prompt
Task
Help me investigate the programming issue below. Base your analysis on the evidence I provide, and distinguish a likely cause from a confirmed cause.
Issue Report
Problem
- Observed behavior: [What happens, including a minimal reproduction]
- Expected behavior: [What should happen]
- Impact: [Who or what is affected]
- When it started: [Relevant change, intermittent pattern, or unknown]
Environment
Use the versions actually installed in this project, not assumed current releases.
- Language/runtime and exact version: [From the runtime or project configuration]
- Framework/libraries and installed versions: [Relevant dependencies only]
- Browser/OS/device: [Relevant platform and version]
- Package manager/build tool: [Name and installed version]
- Environment: [Local development, test, or production]
Minimal Code and Error
[Smallest relevant code sample and redacted error/stack trace]
Include file paths or line numbers only if they are useful and safe to share. Replace credentials, access tokens, personal data, private URLs, and customer information with placeholders. For configuration, share variable names and whether a value is set; do not paste secret values or an entire .env file.
What I Have Tried
- [Action and observed result]
- [Reproduction steps or a small failing test, if available]
Analysis
1. What the Evidence Shows
Summarize the observed failure. Identify missing information that could change the diagnosis. Ask a focused question if the supplied code cannot support a useful next step.
2. Likely Causes
Rank plausible causes and explain the evidence for each. Say what would confirm or rule them out. Do not call a hypothesis a confirmed root cause.
3. Smallest Useful Fix
Show a focused before/after change using the supplied code. Explain why it should help. Do not invent files, line numbers, APIs, or dependencies. If a version-specific API is needed, check the official documentation for the installed version or state that it needs verification.
4. Verification
Provide a reproduction check and relevant edge cases. Separate suggested commands from commands actually run, and predicted results from observed results. Explain any command that changes files, data, or dependencies before suggesting it.
5. Prevention
Suggest one or two relevant tests, checks, or logging improvements. Keep logs free of sensitive data. Link to official documentation when it supports the diagnosis; do not fabricate citations.
Output Constraints
- Explain why the proposed change addresses the supplied evidence.
- Prefer a small, testable change over unrelated refactoring.
- State remaining uncertainty and what to inspect next if the fix does not work.
- Do not claim the issue is resolved until verification supports that conclusion.
How to Use
How to Customize
Expected Outcome
Pro Tips
Illustrative Worked Example
This fictional input and suggested response illustrate how to use the prompt. They are not recorded model test results.
Input:
Issue: total([]) throws, but an empty cart should total 0.
Language: JavaScript. This example has no framework dependency.
Code:
function total(prices) {
return prices.reduce((sum, price) => sum + price);
}
Reproduction: call total([]).
Error: TypeError from reduce on an empty array.
Inputs are arrays of numbers. No other failures have been reported.Suggested response:
Evidence: reduce has no initial value. An empty array has no first value to use as the accumulator, so this call throws.
Proposed fix:
function total(prices) {
return prices.reduce((sum, price) => sum + price, 0);
}
Checks to run:
- total([]) should return 0.
- total([12]) should return 12.
- total([12, 8]) should return 20.
These are expected results, not a report of tests run in your project. This fix addresses the supplied numeric-array example; it does not validate other input types.