Structure complex Claude prompts with XML tags
Wrap instructions, documents and examples in descriptive XML tags so Claude never confuses your data with your instructions.
Anthropic recommends XML-style tags to separate the parts of a complex prompt.
<instructions>Summarize each contract's termination terms.</instructions>
<documents>
<document index="1">
<source>acme_msa.pdf</source>
<document_content>...</document_content>
</document>
</documents>
<format>One bullet per document.</format>
Tips
- No magic tag names; just be descriptive and consistent.
- Nest tags for hierarchy; give each document its own
<document>with source metadata. - Ask for tagged output (e.g.
<quotes>) so it’s easy to parse in code.