# Claude XML Prompt Patterns — Few-shot, CoT, RAG, Structured Output

> Reusable XML prompt patterns for Claude: few-shot, chain-of-thought, structured output, RAG, multi-document, agentic tool use.
>
> Source: https://claudexml.com/patterns/ · Last updated 2026-05-25

Home / Patterns

# 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.

      pattern
### Chain-of-thought
Have Claude reason inside <thinking>, then answer inside <answer>.

      pattern
### Structured output
Force JSON or other schemas using <format> tags and explicit constraints.

      pattern
### Retrieval-augmented context
Inject retrieved passages with <documents>/<document>/<source> and ground the answer.

      pattern
### Multi-document synthesis
Have Claude read and synthesize across many sources at once.

      pattern
### Agentic 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/`
