Claude XML prompt patterns
The reusable shapes of prompts that combine XML tags effectively.
pattern
Few-shot prompting
Show Claude 1–5 worked examples before the live input.
patternChain-of-thought
Have Claude reason inside <thinking>, then answer inside <answer>.
patternStructured output
Force JSON or other schemas using <format> tags and explicit constraints.
patternRetrieval-augmented context
Inject retrieved passages with <documents>/<document>/<source> and ground the answer.
patternMulti-document synthesis
Have Claude read and synthesize across many sources at once.
patternAgentic tool use
Combine XML scaffolding with the API's tool-use feature.
Cite this page
Claude XML Prompt Patterns. claudexml.com. https://claudexml.com/patterns/