Debug an error from its message
Professional structure: role, context, objective, details, steps, format, criteria and self-check. Designed for better results, not guaranteed ones: always review the answer.
Never use real personal data. If you need to, run it through the data cleaner.
## Role Act as a developer skilled in methodical debugging. ## Context My program fails and I have the error message, but I do not know why. ## Objective Find the most likely cause and a verified fix. ## Details (fill in what is in square brackets) - [full error message] - [related code snippet] - [environment: language, versions, system] - [what changed before it failed] ## Step-by-step instructions 1. Explain in plain language what the error says. 2. Put forward three to five hypotheses ranked by likelihood. 3. For each one, propose a quick test to confirm or rule it out. 4. Give the fix for the most likely hypothesis. ## Output format Explanation, hypotheses table (cause, test, expected result) and the fix in a code block. ## Quality criteria - It does not treat a cause as certain without evidence. - The tests are quick to run. - The fix does not hide the error with an empty try/catch. ## Self-check Before answering, check every quality criterion. If information is missing, ask me instead of making it up, and at the end state what you have assumed.
Objective
Find the most likely cause and a verified fix.
When to use it
This prompt is brilliant when you are staring at a cryptic stack trace and feel stuck in a loop of trial and error. It is most useful for logic bugs, dependency issues, or environment mismatches where the error message provides a starting point but not the solution. Avoid using this for architectural design problems or when the error message is completely missing, as the AI needs concrete data to work effectively. It helps you stay methodical rather than guessing blindly.
Worked example: input (fictional data)
Worked example: full response
Variants
Quick triage version
Simplify your response to focus only on the most probable cause. Skip the full ranking and multiple hypotheses. Just explain the error, provide one quick diagnostic test I can run immediately to verify the root cause, and then give the direct code fix. Keep the response concise and actionable for a busy developer.
Junior developer mentor
Adopt a patient, teaching-focused tone for a junior developer. Explain the underlying computer science concept behind why this error is happening rather than just fixing it. Break down the logic step-by-step so I can learn how to debug similar issues independently next time. Focus on best practices for preventing this specific error in the future.
Production outage focus
Treat this as a critical production outage. Prioritise stability and immediate mitigation over long-term structural changes. Provide the quickest 'hotfix' to get the system running again safely, then suggest a proper refactoring task for later. Ensure the fix does not introduce side effects or data corruption while under pressure.
Common mistakes
- Pasting only the last line of the error.
- Applying fixes without understanding them.
- Ignoring the specific file path or line number provided in the error trace. How to avoid it: Always verify the exact file path mentioned, as errors often hide in unexpected or mislinked files.
- Assuming the error is caused by a syntax mistake rather than a logic flaw. How to avoid it: Use print statements or debuggers to inspect variable states before assuming the syntax itself is broken.
- Restarting the entire application server repeatedly without clearing the local cache first. How to avoid it: Clear your browser cache or temporary build folders to ensure you are testing the current code.
- Copying AI suggestions without verifying they match your project's specific coding style. How to avoid it: Review suggested code snippets to ensure they align with your project's architecture and naming conventions.
Related guide
General and assistant-specific tips
Tips by assistant
- Claude: separate your data with tags such as <document>…</document>; Anthropic recommends this so it can tell instructions from content.
- ChatGPT: open the result in Canvas to edit specific paragraphs without regenerating the whole text.
Getting the most out of it
- Paste the prompt as is and only replace what is in [brackets].
- If the answer does not fit, do not start over: ask for “shorter”, “more formal” or “as a table”.
- Always review the result before using it: AI can get facts, dates or names wrong.
Before you paste it: quick checklist
- Remove client names, amounts and internal data before pasting.
- Say who the text is for and which tone you want.
- Ask for a specific length: “120 words max” or “three bullet points”.
- Read the result aloud and fix anything you wouldn’t say yourself.
How to adapt it to your assistant
The template works the same in ChatGPT, Gemini, Copilot or Claude because it only uses plain language. If your assistant supports fixed instructions (custom instructions, Gems or projects), you can store your preferred tone and format there and paste only the variable part. On a free plan, split long requests into two or three shorter messages.