Prompting Claude: XML tags, context and other best practices
Updated:
Claude, Anthropic’s assistant, responds well to clear, direct prompts like any AI. But a few practices that Anthropic itself recommends make a noticeable difference once a request gets long or has several parts.
Use XML tags to separate parts
Claude handles XML-style tags very well: words in < > that open and close a block. The names aren’t special; they just need to be clear and consistent.
<role>
You are an editor who tightens website copy for small businesses.
</role>
<context>
I run a kids' swim school. Our "About us" page is long and nobody
reads it.
</context>
<current_text>
[paste the text here]
</current_text>
<task>
Rewrite it in under 100 words, keeping the key facts.
</task>
Tags keep Claude from confusing your material with your instructions. If the pasted text says “write in all caps,” Claude knows that’s part of the content, not an order.
Long documents first, question last
When you include a contract, a report or several pages, put them at the top of the prompt and your question at the bottom. With long inputs, this order tends to improve answer quality. For multiple documents, give each its own tag (<document_1>, <document_2>).
Label your examples
Examples work even better inside <example> tags, with a note about what to take from them: tone, format or just inspiration. If you include several, make them different from one another.
Give it room to think
For tasks that require reasoning (comparing options, spotting errors, making a call), ask Claude to work through it before answering:
Before answering, reason through the options inside <analysis>.
Then give your final recommendation inside <recommendation>.
You can then check the reasoning, not just the conclusion.
Let it say “I don’t know”
If you’re asking for information it might not have, say explicitly that “I’m not sure” beats a made-up answer. Asking it to quote the part of a document it relied on also cuts down on errors.
Explain why
Claude follows instructions better when it understands the reason. “Short sentences, because this will be read on a phone” works better than “short sentences.” It’s the same principle as in context in prompts.
Template
<role>...</role>
<context>...</context>
<task>...</task>
<instructions>...</instructions>
<examples><example>...</example></examples>
<constraints>...</constraints>
<output_format>...</output_format>
<success_criteria>...</success_criteria>
If you are missing important information, ask me up to three questions before you start.
Pick “Claude” as the target in the coach and your prompt comes out in this structure. If you’ll be working with code on your computer, also read Claude Code prompts.