KatInterview

Writing an Effective Prompt to Get Help Debugging Code

BehavioralModel answer
EasyModel answerBehavioralprompt-engineeringai-assisted-debuggingbug-reports

Last updated

Decide which way of asking an AI assistant for debugging help gets the most reliable diagnosis, and justify the choice with trade-offs, edge cases and a worked example.

You are stuck on a bug and decide to ask an AI chat assistant for help. You can phrase your request in one of four ways:

  • A. Paste all of your code and ask, "What is wrong with this?"
  • B. Share the error message or stack trace, the code snippets that are relevant to the failure, and a side-by-side description of what you expected versus what actually happened.
  • C. Describe the symptoms in plain language only, with no code attached.
  • D. Tell the assistant to throw away the faulty module and write a new one from scratch.

Task:

  1. Choose the approach that is generally the most effective for finding and fixing the bug.
  2. Explain why it works better than each of the other three.
  3. Discuss situations where the choice needs adjusting, for example when no error is thrown, when the bug spans several files, or when the code is confidential.
  4. Show how you would verify whatever the assistant suggests before trusting it.

A short code example illustrating your reasoning is welcome but not required.

Hints

Hint 1

Think about what a colleague would ask you before they could help with a bug: what did you run, what did you expect, what happened, and where is the code?

Hint 2

Consider what each option leaves out. Which ones fail to define what 'correct' means, and which ones remove the code or the diagnostic output the assistant would need?

Hint 3

Many bugs throw no exception at all. Ask yourself which part of a good prompt still lets the assistant find a silent logic error, and why a full rewrite does not teach you the root cause.