When to use it

Use this prompt when a bug is not obvious: it appears only in some environments, the error message points to the wrong place, or the first two fixes you tried did not work. It is especially useful when you are tempted to paste an error and accept the first suggested change. That approach often fixes the symptom while leaving the cause in place.

How to customize it

  • [EXPECTED / ACTUAL BEHAVIOUR] should be concrete: inputs, outputs and observed values.
  • [ERROR MESSAGE OR STACK TRACE] must be pasted exactly. Paraphrased errors lose the details that matter.
  • [WHAT CHANGED RECENTLY] is often the fastest route to the cause: a dependency upgrade, a config change or a new data source.
  • [ENVIRONMENT] matters because library behaviour differs between versions.
  • [WHAT I HAVE ALREADY TRIED] stops the assistant from repeating suggestions you have ruled out.
  • [CODE] should be the smallest snippet that shows the problem. Trimming it often reveals the bug on its own.

Why it works

The prompt imposes the scientific method on debugging: reproduce, form hypotheses, test, then fix. Splitting the work into labelled steps is a form of chain-of-thought prompting that keeps the reasoning visible, so you can spot a wrong assumption early.

Ranking hypotheses with evidence for and against each forces the model to weigh alternatives instead of committing to the first plausible story. Asking for the smallest test per hypothesis keeps you in control: you run the experiment and report real results, which grounds the next step in facts rather than guesses. Delaying the fix until after the tests is the key constraint of the whole prompt.

Tips and variations

  • Paste real outputs of each test back into the same conversation; the assistant can then narrow the list.
  • If the assistant can run code in your tool, ask it to write and run the reproduction itself, but still read what it ran.
  • For intermittent bugs, add: “Consider concurrency, timing, caching and environment differences explicitly.”
  • Remove credentials and personal data from logs before pasting them.
  • When the bug is fixed, ask: “Write a regression test that would have caught this.”