[ ABORT TO HUD ]
SEQ. 1
SEQ. 2

XML Tag Boundaries

🏗️ Prompt Engineering Mastery15 min200 BASE XP

The Precision of XML

Claude is uniquely fine-tuned to respect XML hierarchies. Unlike other models that may get confused by complex paragraph breaks, Claude treats content inside <tags> as distinct logical blocks. This is particularly powerful for RAG (Retrieval Augmented Generation) where you might pass dozens of documents; wrapping each in a <document> tag allows Claude to differentiate their contents without cross-contamination.

Document Indexing

When passing multiple data sources, using indexed tags like <doc id="1"> is scientifically proven to improve Claude's "Needle In A Haystack" performance. It allows the model's attention mechanism to 'anchor' its reasoning to specific structural markers, leading to much higher retrieval accuracy in large contexts (200k+ tokens).

SYNAPSE VERIFICATION
QUERY 1 // 2
Why does Anthropic recommend surrounding distinct elements in XML tags?
It converts to JSON faster
Claude is fine-tuned to recognize XML as a structural boundary, separating instructions from user data
It is an HTTP requirement
It lowers token counts
Watch: 139x Rust Speedup
XML Tag Boundaries | Prompt Engineering Mastery — Claude Academy