Intermediate · Shaping the Output
Separating data from instructions
When instructions and data are mixed together in a single block of text, Claude has to guess where the instructions end and the data begins. That guess is sometimes wrong. The fix takes thirty seconds and eliminates an entire class of prompt failures.
The problem in concrete terms
Imagine you paste a customer email into a prompt like this:
"Summarize the key requests in this email and classify each as urgent or not. Dear Support Team, I am writing to ask about my subscription which was supposed to renew on March 1st but I have not received a confirmation email yet. Also I wanted to check whether the API rate limits have changed recently as I am seeing more 429 errors than usual. Please let me know as soon as possible."
Claude has to figure out that "Dear Support Team" is the beginning of the email and not part of the instruction. It usually gets this right. But "usually" is not good enough in a production prompt that runs on thousands of inputs.
The solution: delimiters
Delimiters are markers that explicitly separate instructions from data. The most common options are XML tags, triple backticks, and section headers in all caps.
XML tags:
Summarize the key requests in this email and classify each as urgent or not.
<email>
Dear Support Team, I am writing to ask about my subscription...
</email>
Triple backticks:
Summarize the key requests in the following email and classify each as urgent or not.
Dear Support Team, I am writing to ask about my subscription...
Both work. XML tags are preferred when you have multiple sections to separate (instructions, examples, data, format specification) because they are labeled.
Rules for using delimiters
Place instructions before the data. Claude reads the prompt in order. Instructions at the top mean Claude knows what to do before it reads the data. Instructions at the bottom mean Claude reads the data first, then discovers what to do with it, and sometimes has to re-interpret what it already processed.
Use consistent delimiters throughout a prompt. If you open with <email> tags, do not switch to triple backticks partway through. Inconsistent delimiters create ambiguity.
Label every section. If your prompt has instructions, examples, and data, give each its own labeled section. <instructions>, <examples>, <data>. Claude processes labeled sections correctly even when they are long.
If you get stuck
If the output is treating part of your data as an instruction, the delimiter is either missing or inconsistent. Check that the tag opens exactly where the data begins and closes exactly where it ends.
If you are using backticks and the data itself contains backticks (code, for example), switch to XML tags. They are more robust when the data contains the delimiter character.
Cross-reference
L9 (Format a JSON output) builds on this technique — the data goes inside tags, the schema goes in the instructions.
Deliverable
Take a prompt where you paste in a block of text (an email, a document excerpt, a code snippet). Add XML tags around the data. Run both versions. If the outputs are identical, that is fine — the delimiter is insurance, not a magic ingredient. If the output changes, note which version is more accurate.
Try these prompts
- Summarize the following article using triple backticks to wrap the text: \`\`\`[paste article here]\`\`\`
- Extract the action items from this meeting transcript wrapped in <meeting> tags.
Sign in to keep your place and tick off lessons. Reading stays open either way.