Prompt Engineering with Claude

25% of the exam

System prompts, XML tags, few-shot, explicit reasoning and prompt caching.

Structuring the prompt

  • System prompt for role/tone/persistent rules; user messages for the task.
  • Claude responds very well to XML tags (<document>, <instructions>, <example>) — a key Anthropic recommendation.
  • Be explicit: describe the desired result, output format and constraints.

Techniques that work

  • Few-shot: 2-5 representative examples strongly shape behavior.
  • Chain-of-thought: 'think step by step' (or <thinking> tags) improves reasoning.
  • Prefill the assistant turn to force a format (e.g. start with '{' for JSON).
  • Give an out ('if you don't know, say so') to reduce hallucinations.

Prompt caching

  • Caches a stable prefix (long instructions, documents) → lower cost/latency on repeated calls.
  • Put stable content first, variable content last.

Practice — 10 questions

0/10 answered
  1. 1. Anthropic-recommended practice to delimit a document to analyze in a prompt?
  2. 2. To make multi-step reasoning reliable, which technique?
  3. 3. Force strictly JSON output — most robust approach?
  4. 4. Reduce hallucinations on questions outside the provided context?
  5. 5. An assistant reuses 30K tokens of instructions/docs each call. Which lever cuts cost/latency?
  6. 6. For deterministic, reproducible extraction, which temperature?
  7. 7. Which instruction phrasing is most effective?
  8. 8. How many few-shot examples are usually useful to frame a task?
  9. 9. How to separate reasoning from the final answer?
  10. 10. For prompt caching, what content order?

← Back to the Academy · Mock exam →