Your first stack trace feels like it’s written in another language, because in a way it is. This bug explainer prompt turns a confusing error message into plain English: what the error is saying, which line probably caused it, a small fix with a before and after, how to check that it worked, and the concept worth learning so the same bug doesn’t come back.
It’s written for students and new developers using ChatGPT, Claude or Gemini, and it’s deliberately patient. No scolding, and every bit of jargon gets a one-line definition.
Table of Contents
What this bug explainer prompt does
The prompt makes the AI a patient programming tutor and asks for six specific outputs, from plain-language meaning to a message you could send a teammate.

Explanation before fix. Step one is understanding what the error message says. Beginners who copy a fix without understanding hit the same wall next week.
Ranked causes. If several causes are possible, the model ranks them and explains what evidence would confirm each one, instead of guessing confidently.
Small, testable changes. A short before/after and “how to test that the fix worked” keep you from rewriting half the file.
A concept to learn. Section five names the idea behind the bug (scope, null values, off-by-one errors), which is where real learning happens.
Secrets safety. If your snippet seems to contain a key or password, the model tells you to rotate and redact it.
How to use it
- Click Copy Prompt above.
- Paste the full error message, not just the last line.
- Add the relevant code, your environment and what you already tried.
- Send it, then ask follow-up questions about anything unclear.
OpenAI’s prompting guide advises sharing the context that could change the result and pointing out the area that matters. For debugging, that means the full error, the exact code and your versions.
What to include
| Field | Tip |
|---|---|
| {error_message} | Copy the entire stack trace; the useful line is often in the middle. |
| {code_snippet} | Include the function that failed and anything it calls. |
| {environment} | Language version, framework and OS often explain “works on my machine” bugs. |
| {what_you_tried_to_do} | One sentence on what the code should do. |
| {what_you_already_tried} | Saves time and avoids repeated suggestions. |
Remove passwords, API keys and personal data before pasting.
Follow-ups when you’re still stuck

| Situation | Follow-up |
|---|---|
| Fix didn’t work | “Here’s the new error after your change. What does that tell us?” |
| Explanation went over your head | “Explain it again with an everyday analogy.” |
| Want to understand deeper | “Show me a tiny example that reproduces this bug on purpose.” |
| Need to ask a mentor | “Turn this into a short, clear question for my team lead.” |
| Several bugs at once | “Which one should I fix first, and why?” |
Variations to try
- Homework mode: add “give hints only; don’t write the fix for me” if you’re learning for a class.
- Compare two approaches: ask “show two ways to fix it and the tradeoffs of each.”
- Learn the debugger: ask “what breakpoints should I set to watch this happen?”
- Read a log file: paste server logs instead of a stack trace and ask what the first real error is.
Good habits around AI debugging
Treat suggested fixes as hypotheses. Test them, read the code you’re pasting, and make sure you can explain why the change works. If the model mentions a library function you haven’t seen, check the official docs before trusting it.
Related prompts
When your code is ready for review, run the pull request code review prompt. Learning with a tutor instead? Try the Socratic tutoring prompt. Browse more coding templates in writing prompts.
Questions about this bug explainer prompt
What should I paste into the prompt?
The full error message, the code around the failing line, your environment and what you’ve already tried. Remove any secrets first.
Will it just give me the answer?
It explains the error and suggests a small fix. For homework, add “hints only” so it guides you instead.
Can it be wrong?
Yes. AI can misread code or suggest functions that don’t exist. Test every fix and check unfamiliar functions in the official documentation.




