brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: wrap each part of a long Claude prompt in its own XML tag

Claude
~/tips/tip-claude-prompt-xml-tags

Summarize the email below in two sentences and list any deadlines.

Separates instructions from pasted content in a Claude prompt so the two are not confused.

A prompt that mixes instructions, a pasted email and some examples in one blob invites misreading. Tags fix that cheaply.

Anthropic’s prompting guide says XML tags help Claude parse complex prompts unambiguously, especially when instructions, context, examples and variable input are mixed. Wrapping each kind of content in its own tag reduces misinterpretation.

<instructions>
Summarize the email below in two sentences and list any deadlines.
</instructions>

<email>
...paste it here...
</email>

You pick the tag names. The guide uses <instructions>, <context> and <input> as examples. This works in the Claude app as well as in the API, because it is only text.

I would use it whenever a prompt contains something pasted: an email, a log, an article. The tag tells the model where your text ends and the instructions begin, which also helps when the pasted text itself contains something that looks like an instruction.

The caveat: keep the names consistent, and use the same name when you refer back to the content (“using the text in the email tag”). Tags do not replace clear writing either: a messy instruction inside a neat tag is still messy.

Further reading: Prompting best practices – Claude docs, On this site: put the long document first and your question last in Claude, On this site: explain why you want something and Claude aims better

More Claude tips /recap /focus /skill-doctor /autocompact 500k claude purge ~/work/my-repo --dry-run All Claude tips (83) All topics

Link