Why does Anthropic recommend XML tags as section delimiters over markdown headers or triple-backticks in production prompts?
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
XML tags give the model unambiguous open/close boundaries that user content almost never collides with; markdown headers and backticks both leak into user content too easily.
Imagine you are mailing a letter inside a letter. If you wrap the inner letter with plain dashes ('-----') and the inner letter ALSO contains dashes, the postal worker cannot tell where one letter ends and the next begins. If you wrap it in a clearly labeled envelope with 'INNER LETTER' printed on the flap, the boundary is obvious no matter what is inside. XML tags are the labeled envelope: '<user_message>...</user_message>'. Markdown headers and triple backticks are the plain dashes that user content can accidentally replicate.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
3 min: the boundary collision problem + why XML pairs survive + training data prior + injection defense angle + when JSON or schemas are better.
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Claiming XML tags 'save tokens' or 'make the model concentrate harder.' The real reason is boundary disambiguation: XML rarely collides with content, markdown headers and backticks routinely do.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.