Prompt engineering for coding: how to brief an AI coding tool
Updated Oct 26, 2026 · Sources listed at the end
Prompting a coding tool well comes down to four things: say exactly what you want, give concrete examples, structure long instructions, and tell the tool how to check its own work (which tests to run, what “done” looks like).
Techniques from Anthropic’s guide
Anthropic’s prompt-engineering overview lists the core techniques: clarity, examples, XML-style structuring, role prompting, letting the model think, and chaining prompts.1
Applied to code
- State the goal and constraints: “Add rate limiting to the /login endpoint: 5 attempts per minute per IP, using the existing Redis client.”
- Point to examples: “Follow the pattern in
src/middleware/auth.ts.” - Define done: Claude Code’s best-practices guide suggests telling the agent which tests to run and to keep going until they pass.2
- Move stable rules out of the prompt into CLAUDE.md, AGENTS.md or Cursor rules, so every session gets them.3
Beyond the prompt
Anthropic describes context engineering as the natural progression of prompt engineering: managing everything in the model’s context, not only the instruction.4
Footnotes
Tools mentioned
- Claude Code: paid from $20/mo
- Cursor: free plan, paid from $8/mo