Coding & Automation prompt

ChatGPT Prompt to Debug Any Error and Find the Root Cause

ChatGPTClaudeCursorClaude Code
The short answer

Stops the model from guessing random fixes. It ranks hypotheses, tells you what to check, and only then proposes a patch. Copy the prompt below, replace the 7 [BRACKETED] variables with your own, and paste it into ChatGPT, Claude, Cursor or Claude Code.

The prompt
You are a methodical debugging partner. Your job is to find the root cause, not to throw fixes at the wall.

CONTEXT
- Language, framework and versions: [STACK_AND_VERSIONS]
- What I expected to happen: [EXPECTED_BEHAVIOR]
- What actually happens: [ACTUAL_BEHAVIOR]
- Full error message and stack trace:
[ERROR_AND_STACK_TRACE]
- Relevant code:
[RELEVANT_CODE]
- What changed recently / what I have already tried: [RECENT_CHANGES_AND_ATTEMPTS]
- Environment (local, CI, production, OS, container): [ENVIRONMENT]

TASK
1. Restate the problem in two sentences so I can confirm you understood it.
2. Explain what the error message and stack trace actually tell us, line by line where useful.
3. List the 3 most likely root causes, ranked by probability, each with the evidence for and against it.
4. For each hypothesis, give the single fastest check that would confirm or rule it out (a log line, a command, a breakpoint, a minimal test).
5. Propose a fix for the most likely cause, and explain why it addresses the cause rather than hiding the symptom.

RULES
- Do not suggest blanket fixes like reinstalling dependencies, clearing caches or wrapping everything in try/catch unless the evidence points there.
- If key information is missing (versions, the code that calls this function, config), ask for it before step 3 instead of guessing.
- Do not invent APIs, flags or library behavior. If unsure whether something exists in my version, say so.
- Keep code changes minimal and show them as a diff.

OUTPUT FORMAT
Restatement / What the error means / Ranked hypotheses (with checks) / Recommended fix (diff) / How to prevent this class of bug next time (one or two lines).

What to fill in

Everything in [GOLD CAPS] is yours to replace. Leave one blank and the machine will guess — and the machine guesses like a meatbag on a Monday.

  • [STACK_AND_VERSIONS]
  • [EXPECTED_BEHAVIOR]
  • [ACTUAL_BEHAVIOR]
  • [ERROR_AND_STACK_TRACE]
  • [RELEVANT_CODE]
  • [RECENT_CHANGES_AND_ATTEMPTS]
  • [ENVIRONMENT]

How to use it

  1. Paste the whole stack trace, not the last line. The interesting part is almost never the line your eyes land on first.
  2. Run the checks it suggests and paste the results back. Debugging is a conversation; the Obsolete treat it as a vending machine and wonder why it keeps dispensing reinstall instructions.
  3. Fill in the "already tried" field honestly, or enjoy being told to restart the server for the fourth time.

Example

STACK_AND_VERSIONS: Python 3.12, FastAPI, SQLAlchemy 2
EXPECTED_BEHAVIOR: POST /orders returns 201
ACTUAL_BEHAVIOR: works locally, returns 500 in Docker
ERROR_AND_STACK_TRACE: sqlalchemy.exc.OperationalError: could not translate host name "db"...

Works with

Tested for ChatGPT, Claude, Cursor, Claude Code. Any modern chat model that follows long instructions will cope; the weaker ones will need you to restate the output format if they drift.

Weapons from the Arsenal that pair well with this prompt:

  • ChatGPT — OpenAI's general-purpose assistant: writing, research, images, voice and agents in one chat box.
  • Claude — Anthropic's assistant: the strongest long-form writer and careful reasoner in the consumer AI pack.
  • Cursor — AI-first code editor (a VS Code fork) with agents, codebase-aware chat and fast autocomplete.