Skip to content

Definition

Wrapping distinct content types (instructions, context, examples, inputs, documents) in their own XML tags lets Claude parse complex prompts unambiguously and reduces misinterpretation.

Key points

  • Use consistent, descriptive tag names across prompts (e.g. <instructions>, <context>, <input>).
  • Nest tags when content has a natural hierarchy: <documents><document index="1"><source> + <document_content>.
  • Wrap few-shot examples in <example> tags (multiple in <examples>) so Claude distinguishes them from instructions — see Few-Shot Prompting.
  • XML also works as a format indicator: ask for output inside a named tag (e.g. <smoothly_flowing_prose_paragraphs>) to control formatting instead of saying "no markdown".
  • Manual chain-of-thought fallback uses <thinking> / <answer> tags to separate reasoning from the final answer (when thinking is off).

Why it matters for the exam

  • The <document> / <document_content> / <source> nesting pattern is the canonical structure for Long-Context Ordering and quote-grounding.
  • XML tags are the tested vehicle for both structuring inputs and constraining output format.

Common gotchas

  • Inconsistent or ad-hoc tag names undercut the benefit — reuse the same names.
  • XML structuring is a prompting technique, distinct from Structured Outputs (a decoding-level guarantee).

See also

Sources