ChatGPT Prompt for Debugging: 12 Prompts to Find Root Cause
12 ChatGPT prompts for debugging in any language: reading stack traces, ranked hypotheses, minimal repros, race conditions, flaky tests, and regression tests.

A good ChatGPT prompt for debugging gives the model evidence, not just "it doesn't work": the symptom, what you expected, exact repro steps, the raw error output, the relevant code, and what you already tried. Then ask it to rank hypotheses and suggest one small experiment at a time before it writes a fix. The 12 prompts below work in any language and cover reading errors, narrowing the cause, tricky bug types, and locking in the fix with a test.
Before you paste, remove API keys, passwords, and customer data from logs and code. Treat every suggested fix as a hypothesis: run it, test it, and check any library behavior against the docs for your version.
Prompts for understanding the error
1. Explain this stack trace
Here is a stack trace from [language and framework]: [paste]. Explain it from the bottom up, point to the first frame in my own code, and say what that frame was trying to do. Do not suggest fixes yet.
2. Error message in plain words
What does this error mean in [language or tool, version]: [error]? List the three most common causes and the quickest check for each.
3. Restate the bug
Here is my bug report: [report]. Restate it in two sentences: observed behavior, expected behavior, and the conditions that trigger it. List any facts missing from the report.
Prompts for narrowing the cause
4. Ranked hypotheses
Symptom: [symptom]. Code: [code]. Logs: [logs]. Already tried: [list]. Give 3 to 5 hypotheses ranked by likelihood with evidence for and against each, and drop anything my attempts already rule out.
5. One experiment at a time
For hypothesis "[hypothesis]", suggest the smallest experiment to test it: a log line, breakpoint, or failing test. Tell me the result that confirms it and the result that rules it out.
6. Minimal reproduction
Help me cut this down to a minimal reproduction: [code and steps]. Remove everything that is not needed to trigger the bug, step by step, and tell me what to check after each removal.
7. What changed
The bug started after this change: [diff or commit message]. Which lines in the diff could cause [symptom]? Rank them and explain how each could do it.
Prompts for tricky bug types
8. Race conditions and async bugs
This bug only happens sometimes, [when], in this async code: [code]. Look for requests or tasks that can finish out of order, missing cancellation or cleanup, and shared state. Suggest a test that forces the bad order.
9. Flaky tests
This test passes locally and fails in CI about [how often]: [test code and failure output]. List likely causes such as timing, test order, shared state, time zones, or network, with a check for each.
10. Works on my machine
It works on [my setup] but fails on [other setup] with [error]. Compare the two environments I list here, [details], and rank the differences most likely to matter.
Prompts for fixing it for good
11. Smallest fix as a diff
The root cause is [cause] in [file and lines]. Write the smallest fix as a diff against this code: [code]. Explain why it fixes the cause and what else it could affect.
12. Regression test
Write a test in [test framework] that fails on the old code and passes with this fix: [fix]. Name the test after the behavior, not the bug ticket.
Run the whole process with the flagship prompt
The Debugging Prompt: Bug Report to Root Cause and Tested Fix combines prompts 3, 4, 5, 11, and 12 in one pass. In its example, a React search box shows stale results on a slow network. The prompt rules out cache and API problems from what was already tried, traces the cause to a fetch with no cleanup that lets an older response arrive last, fixes it with an AbortController in the effect cleanup, and adds a test that resolves the requests out of order.
Related prompts
For Python errors, the Python traceback debugger goes deeper on tracebacks, and the JavaScript bug hunter focuses on JS code. To write the tests around a fix, see ChatGPT Prompt for Test Cases, and to catch bugs before they ship, see Claude Code Prompts for Code Review.
Find more prompts in the Coding category, look through Browse, or post your own on Share.