Debugging prompt for error messages and stack traces
Paste an error and the code around it to get the likely causes ranked, a quick way to confirm each one, and the smallest fix that makes it go away.
- Category
- Coding
- Tags
- Debugging
- Added
- Added
Fill in the prompt
The prompt below changes as you type, and Copy prompt copies it filled in. What you type stays in this browser. Leave a box empty to fill it in after you paste.
The prompt
Help me find the cause of this error. Don't suggest a fix until the cause is clear.
The error, with the full stack trace:
{{error}}
The code where it happens:
{{code}}
What I expected, and what I've already tried:
{{tried}}
Work through it like this:
1. Say in one sentence what the error means.
2. List up to three likely causes, most likely first. For each, point at the line or value that makes you suspect it.
3. For each cause, give a quick way to confirm or rule it out: a log line, a breakpoint, a command, or a one-line test.
4. Give the smallest fix for the most likely cause, as a diff or a code snippet.
5. Say in one or two lines how to stop it coming back, such as a test or a guard.
If the stack trace points at code I haven't shared, ask me for that file instead of assuming what it does.
Replace each {{highlighted part}} with your own text before you send it.
How to use it
Put the whole error in {{error}}, stack trace included. The top line says what failed, but the frames underneath say where, and the real cause is often a few frames down in your own code.
In {{code}}, paste the function named in the innermost frame that belongs to you, plus anything it calls that you changed recently. Use {{tried}} for what you expected to happen and what you've already ruled out, so the model doesn't send you back to a restart or a cache clear you did an hour ago.
Example for {{tried}}: "Expected a 200. Works locally, fails in Docker. Already checked the env vars are set."
The prompt asks for a way to confirm each cause before any fix. That step saves you from a change that hides the symptom while the bug stays. If the model asks for another file, paste it rather than letting it guess what that file does.