The Prompting Format Anthropic Built Into Claude on Purpose
There is a way to write prompts that Anthropic's own internal testing shows produces 20–40% more consistent outputs than the same instructions in plain prose. It is not a new model, a paid feature, or a hidden setting. It is XML tags, and Claude was deliberately trained to recognise them as structural anchors.
Most Claude users have never used them. They write a long paragraph of instructions, hit send, and accept whatever comes back. This article shows the exact tags Anthropic recommends, the standard five-part prompt structure, and a copy-paste template you can adapt to any work task in the next ten minutes.
What Are Claude XML Tags?
Claude XML tags are simple delimiter pairs like <task> and </task> that you wrap around parts of your prompt to label what each section is. Claude treats anything inside <task> as the request, anything inside <context> as background, and anything inside <examples> as patterns to imitate.
According to Anthropic's official documentation, XML tags help Claude parse complex prompts unambiguously when your prompt mixes instructions, context, examples, and variable inputs. Anthropic used XML-style delimiters in Claude's training data, so the model has internalised them as a structural language.
The tag names are not magic. You could write <the_thing_you_want> and it would still work. What matters is that you label each section so Claude knows exactly which part is instruction vs background vs example.
Why Do XML Tags Actually Improve Output Quality?
The improvement comes from three mechanical effects, all of which compound when you use tags consistently.
1. Disambiguation. When you paste a customer email plus your instructions for handling it into one block of prose, Claude has to guess where the email ends and your instructions start. With <email> and <instructions> tags, no guessing is required.
2. Attention weighting. Claude's attention mechanism weights the start and end of a prompt more heavily than the middle. Tags create explicit boundaries that make the middle just as parsable as the edges.
3. Reusable scaffolding. Once you have a tag structure, you can swap the content inside <task> for a different request and keep everything else identical. The model sees the same shape and produces consistently shaped outputs.
According to Anthropic's published prompt-engineering guidance, structured XML prompts reduce ambiguity-driven errors substantially. Internal testing referenced in their developer documentation shows the consistency lift falls in the 20–40% range, with the larger gains coming on multi-section prompts.
What Is the Standard Five-Part Prompt Structure?
Anthropic's recommended structure uses five tags in a fixed order. You do not need every tag for every prompt, but this is the reliable backbone for any non-trivial task.
--- <role> — who Claude should be (e.g., "You are a senior B2B copywriter with 10 years in SaaS marketing.")
--- <context> — the background Claude needs (audience, brand voice, business situation, prior steps)
--- <task> — what specifically you want done, written as an action
--- <examples> — one or more illustrations of the kind of output you want (this is where multishot prompting lives)
--- <output_format> — the exact shape of the answer (bullet list, JSON, table headers, word count)
The order matters because Claude builds its mental model of the task from top to bottom. Role and context set the frame. Task gives the specific ask. Examples calibrate quality. Output format locks the shape.
Try This Prompt: A Copy-Paste Template for Any Business Task
Here is a complete XML-tagged template you can use as the starting point for any work request to Claude. Paste it into a new conversation, fill in the brackets, and you are running at a higher consistency tier immediately.
Copy this:
<role>
You are a [SPECIFIC ROLE, e.g., senior marketing analyst] with [X] years of experience in [INDUSTRY]. You are precise, evidence-driven, and write in [TONE: e.g., a direct peer-to-peer voice].
</role>
<context>
--- Audience: [WHO will read the output]
--- Goal: [WHAT the output should achieve]
--- Constraints: [ANY hard limits, e.g., must avoid jargon, must reference 2026 data]
</context>
<task>
[ONE clear instruction, written as an action. E.g., Draft a 250-word LinkedIn post explaining [TOPIC] to [AUDIENCE].]
</task>
<examples>
--- Good example: [PASTE one short sample of what good looks like]
--- Bad example: [PASTE one short sample showing what to avoid]
</examples>
<output_format>
--- Length: [SPECIFY]
--- Structure: [SPECIFY, e.g., 1 hook sentence, 3 bullet points, 1 CTA line]
--- Style: [SPECIFY, e.g., no emoji, no hashtags, sentence case]
</output_format>
The first time you use this template you will spend an extra minute filling in the brackets. From the second use onwards, you save more time than that on revision.
What Are the Most Common XML Tag Mistakes?
The technique is forgiving but four mistakes consistently break it.
Mistake 1: Inconsistent tag names. Using <task> in one prompt and <instruction> in the next, or even worse, mixing both inside the same prompt. Pick one name per concept and reuse it.
Mistake 2: Tagging too aggressively. If your prompt is one sentence, do not wrap it in five tags. Tags pay off when the prompt has at least three distinct parts.
Mistake 3: Leaving tags unclosed. Every opening tag needs a closing tag. Unclosed tags confuse Claude and can cause it to treat the rest of the prompt as if it were inside the unclosed section.
Mistake 4: Using markdown formatting instead. Bold headings and numbered lists are not the same as tags. Claude treats them as visual emphasis, not as structural boundaries. Use tags when the model needs to know where one thing ends and the next begins.
How Do XML Tags Combine With Other Prompting Techniques?
XML tags are scaffolding. Inside that scaffolding you can layer the other prompting techniques Anthropic documents publicly.
--- Multishot prompting lives inside <examples>. Put 2 to 5 short illustrations of the output you want.
--- Chain-of-thought reasoning uses <thinking> and <answer> tags. Ask Claude to "think step by step inside <thinking> tags, then give the final answer inside <answer> tags." This separates reasoning from output.
--- Document grounding uses <document> or <documents> with nested entries. Wrap each source in its own tag so Claude can quote from them precisely.
--- Constraint enforcement uses <constraints> or <must_not> tags to surface hard rules at the end. Claude is more likely to respect a rule that lives in its own labelled section than one buried in the middle of prose.
The combinations are the point. A single technique on its own gives a modest lift. Stack four techniques inside a clean XML structure and you reach the upper end of the consistency range Anthropic documents.
When You Should Not Bother With XML Tags
The technique has limits. Three situations where the overhead is not worth it.
One-line requests. "Summarise this article" does not need tags. The instruction and the input are obvious.
Casual brainstorming. When you are exploring ideas and do not yet know the output shape, tags can over-constrain you. Stay loose until the question sharpens.
Other models. XML tags work well with Claude. They also work well with GPT-4o and Gemini, but the gain is smaller because those models were not trained with XML as heavily. With Claude the structure is native; with others it is helpful but not foundational.
The Bottom Line
XML tags are not a hack. They are the format Anthropic engineered Claude to expect. Using them is closer to using the tool as designed than skipping them is.
Spend ten minutes today rewriting one prompt you use repeatedly into the five-part XML structure. Compare three runs of the new version against three runs of the old. The consistency difference is visible after the first comparison.
We know AI's cold edges. We know your real challenges. 28 years with UD, turning technology into a partnership with warmth.
Ready to Run Reliable AI Workflows in Your Business?
XML-tagged prompts are step one. The next step is turning your best prompts into reusable workflows your whole team can run. Explore the UD AI Employee Hub to see how Hong Kong teams build dependable, repeatable AI processes. We'll walk you through every step.