AI Codex
Prompt Engineering ClaudeDevelopers

XML Tags in Prompts

Using labels like <document>...</document> or <instructions>...</instructions> to clearly separate different sections of a prompt. Claude is trained to respond well to this structure — it helps Claude understand what is context versus instructions versus the actual task. Particularly useful for long prompts with multiple components: system instructions, user context, a document to analyze, and the specific question, all clearly delimited.

In practice

You're giving Claude a complex prompt with a document to analyze, specific instructions, and an output format. You wrap each section in XML tags: <document>, <instructions>, <format>. Claude can clearly tell where each piece starts and ends, which reduces confusion and improves output consistency — especially in complex, multi-part prompts.

Related concepts