XML-Structured Prompts
Use XML tags to create highly organized prompts that AI models parse with precision.
Why XML Tags Work
XML tags give your prompts clear structure that AI models (especially Claude) parse extremely well. Instead of relying on the model to figure out which part of your prompt is context vs instruction vs examples, you label each section explicitly.
```
<role>You are a senior data analyst</role>
<context>
I have a dataset of 50,000 customer transactions from Q1 2026.
Columns: customer_id, date, amount, category, region.
</context>
<task>Identify the top 3 spending patterns and explain their business implications</task>
<format>Use a numbered list with a bold heading for each pattern, followed by 2-3 sentences of explanation</format>
```
This is dramatically clearer than putting all of this in a single paragraph.
Common XML Tag Patterns
<instructions>: What the AI should do
<context>: Background information
<examples>: Few-shot examples
<constraints>: Rules and limitations
<format>: Output structure requirements
<input>: The specific data or text to process
<output>: Where to put the response (useful in complex prompts)
<thinking>: Ask the model to show reasoning before the final answer
Rewrite your most complex prompt using XML tags. Compare the output to the unstructured version. Particularly effective with Claude, but works well with all major models.
- ✓XML tags create clear structure that AI models parse precisely
- ✓Label each section: role, context, task, format, constraints
- ✓Especially effective with Claude but works with all major models
- ✓Dramatically improves output quality for complex, multi-part prompts