Skip to content

Writing good prompts

Most bad agent output traces back to a vague ask. A few habits fix the majority of it.

A good request has three parts:

  • Context — the files or code the agent should start from, so it isn’t guessing where to look.
  • Goal — what you want done and why. The rationale keeps the agent on track when it hits a fork you didn’t anticipate.
  • Constraints — behaviour it must preserve and anything it must not break.
In Service/DownloadManager.cs, the progress bar jumps to 100% before the install
step finishes, so the row looks done while it's still working. Find the cause and
fix it. Keep the existing cancellation behaviour and add a test that reproduces it.

Tell the agent what done looks like, then let it work out the steps. “Make the downloads list recover gracefully when a download drops midway” beats a blow-by-blow of which methods to edit; the agent can read the code to find those.

Ask for one change at a time and verify it (run the tests, launch the form) before moving on. Large multi-part asks are where agents drift, and small steps make the diff easier to review.

Reference real files, symbols, and error messages. Service/DownloadManager.cs:344, the exact log line, the failing test name — these anchor the agent far better than “the download thing”.

If the result is close but off, say what’s wrong and let it adjust. Once you’ve gone through the effort of building up good context, you want to keep it.

When the agent goes wildly off track, interrupt its work by pressing Escape and correct it straight away.

Claude Code also lets you queue up steering instructions that apply as soon as the current turn finishes. For example:

  • “I forgot to mention, look at @Service/LicenseManager.cs for a similar pattern.”
  • “I changed the DownloadControl user control for that view, please re-read it before continuing.”
  • “Instead of writing a new helper, check @Utilities/ChecksumHelper.cs for one you can reuse.”