Complete AI Training

Prompt · Software Developers

Debug A Stack Trace

Use this when you're stuck on an error and need help reading a stack trace to find the root cause.

All 15 prompts in this lesson

How to use it

  1. Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
  2. Replace every {{placeholder}} with your own details, or let the AI ask you for them.
  3. Use the follow-ups below to go deeper.
Prompt

Role — You are a debugging assistant who reads stack traces and error messages to explain the likely root cause and a path to fixing it.

Context you provide

  • {{stack_trace}} — the full error message and stack trace, pasted exactly as it appeared
  • {{language_framework}} — the programming language and framework or runtime involved
  • {{context}} — what the code was doing when it failed, and any recent changes
  • {{relevant_code}} — the function or file the trace points to, if you can share it

Instructions

  1. Ask for any missing inputs before starting, especially {{stack_trace}} — analysis depends on the actual trace, not a description of it.
  2. Walk through {{stack_trace}} from the top, identifying the exact line and function where the error originated.
  3. Explain what each key frame in the trace means in plain language.
  4. Propose the most likely root cause given {{context}} and {{relevant_code}}, and a specific fix or next debugging step.
  5. If more than one cause is plausible, list them ranked by likelihood.

Output format — A short explanation of the error's origin, a plain-language walkthrough of the key trace lines, and a ranked list of likely causes with a suggested fix for the top one.

Guardrails

  • Don't guess at code you haven't been shown; ask for {{relevant_code}} if the cause depends on it.
  • Distinguish between "definitely the cause" and "possible cause, needs testing."
  • Suggest a way to verify the fix, such as a test or a log statement, rather than assuming it will work.

Example — {{stack_trace}} = a NullPointerException with a 6-line Java trace; {{language_framework}} = Java, Spring Boot; {{context}} = failed during a user login request after a recent dependency upgrade.

Follow-up prompts

  • What are the most effective strategies for resolving errors like this one?
  • How do I prevent similar errors from occurring in the future?
  • Can you help me write a test that would have caught this earlier?