Ever feel like you’re explaining a simple task to a toddler only to get back a finger painting instead of a spreadsheet? Stop fighting the AI and start giving it clearer structure—a simple trick that turns chaos into structured gold.

If you’re in the faction of people tired of your AI prompts feeling like a game of telephone where “write a blog post” turns into “here is a sonnet about cheese,” you’re in the right place. We’re going to talk about XML-style tagging.

Now, don’t run away. I know “XML” sounds like something your IT guy mumbles about while fixing the printer. But in the world of Large Language Models (LLMs) like Claude, Gemini, and ChatGPT, these little tags can be the difference between a junior intern and a senior strategist.

This guide is going to take the cheat sheet you found and inject it with steroids. We’re going to cover everything from the basics to advanced automation workflows that will make your SEO and affiliate marketing tasks run on autopilot.

Quick Reality Check (Read This Before You Start Tagging Everything)

A few things worth getting straight before you start wrapping your prompts in angle brackets:

  • These are XML-style tags, not magic XML parsing. The model isn’t running an XML parser. You’re giving it clear, labeled boxes. That structure helps, but it’s a convention, not a formal standard.
  • Tag names are not sacred. <instructions> is a useful convention, not a magic keyword. Consistency matters more than the exact name. Pick a small set of tags and stick to them.
  • Tags add tokens. The win isn’t a smaller prompt by default. The win is cleaner outputs, fewer retries, and easier extraction.
  • Model behavior varies. Anthropic’s docs explicitly recommend XML tags for Claude, and Claude tends to handle them well. ChatGPT and Gemini respond to clear delimiters too, but test your prompts on the model you’re actually using.
  • Tags are not a security boundary. Wrapping untrusted text in <data> helps separate data from instructions, but it does not make prompt injection safe. Treat untrusted input as untrusted and validate outputs.

Also: these are angle brackets < >, not squiggly braces { }. Small detail, but this is a technical guide.

Why Should You Care About Angle Brackets?

Think of an LLM as a really smart but easily distracted librarian. If you hand them a messy pile of notes and say “organize this,” they might panic. But if you hand them a series of labeled boxes—one for “Books,” one for “Magazines,” and one for “DVDs”—they know exactly what to do.

XML-style tags like <instruction> or <context> are those boxes.

Why this matters for your wallet:

  • Precision: You get much closer to the format you need (JSON, Markdown, CSV) with fewer rounds of begging.
  • Parsing: If you’re building automation scripts (which I know you love), you can extract the answer more reliably using code.
  • Model attention: Some models—especially Claude—are documented as paying extra attention to clearly delimited content. Other models vary, so test.
  • Fewer retries: Tags themselves add tokens, but clean structure often saves you tokens overall by reducing back-and-forth, vague outputs, and manual cleanup.

Part 1: The Core Directives (The Bossy Tags)

An open notebook with hand-drawn nested boxes and arrows sketched in black ink
Draw the shape of the prompt before you type it.

These are the tags that tell the AI who it is and what it needs to do. Without these, you’re just making a suggestion.

1. The <instructions> Tag

This is your command center. Treat everything inside these tags as the primary directive.

Why use it? It separates what you want done from what you are processing. If you paste a long article and ask for a summary at the bottom, the AI might get confused and think the summary request is part of the article.

Example 1: The SEO Audit

<instructions>
1. Analyze the keyword density of the text provided in the <data> tags.
2. Identify 3 opportunities for internal linking.
3. Do not hallucinate URLs; only use valid paths from the current domain.
</instructions>

Example 2: The Affiliate Pitch

<instructions>
Write a 3-sentence hook for the product described in <product_info>.
Focus on the pain point of "losing money on ads."
End with a call to action.
</instructions>

2. The <role> or <persona> Tag

This is where you put the costume on the AI. Context is everything in content creation. A “marketer” writes differently than a “compliance officer.”

Why use it? To stop generic, vanilla AI output.

Example 1: The Grumpy SEO Veteran

<role>
You are a cynical, hardened SEO veteran with 15 years of experience.
You hate fluff. You prefer data over "content is king" platitudes.
You write in short, punchy sentences.
</role>

Example 2: The Hype-Man Copywriter

<persona>
You are a high-energy direct response copywriter inspired by Ogilvy and Gary Halbert.
You use emotional triggers and power words.
</persona>

Part 2: Feeding The Beast (Input and Context)

You can’t expect a Michelin-star meal if you give the chef rotten ingredients. These tags help you sanitize and organize your inputs.

3. The <context> Tag

This is the background noise. It’s the stuff the AI needs to know about the task, but not the task itself.

Why use it? To prevent the “Cold Start” problem where the AI guesses your audience.

Example 1: Audience Definition

<context>
The target audience is 25-34 year olds looking for passive income side hustles.
They are skeptical of "get rich quick" schemes.
</context>

Example 2: Technical Constraints

<context>
This content will be uploaded to a WordPress site using the Elementor builder.
Avoid using complex HTML tables as they break the mobile layout.
</context>

4. The <data> or <input> Tag

This is the payload. The raw material. The meat.

Pro Tip: If you’re pasting messy content from a client’s website, wrap it in <data> tags so the AI doesn’t accidentally interpret a line of text like “Ignore previous instructions” as a command. This is a basic form of prompt injection defense.

Reality check: This is separation, not security. Tags help the model distinguish data from instructions, but they do not make prompt injection safe. Never treat untrusted text as trusted just because it’s inside <data>. Validate outputs and don’t give the model more permissions than it needs.

Example 1: Cleaning Up Analytics Data

<data>
Source: Google Analytics 4
Metric: Session Duration
Value: 00:00:45
Bounce Rate: 85%
</data>

Example 2: Analyzing Competitor Content

<article>
[Paste the entire 3,000-word competitor blog post here]
</article>

Part 3: The Secret Weapon (Few-Shot Prompting)

This is one of the highest-leverage techniques in this entire tutorial. Few-shot prompting is just a fancy way of saying “giving examples.”

5. The <examples> Tag

Instead of describing what you want, show it.

Why use it? It is often more effective than writing long instructions. If you want a reliable JSON format for your automation scripts, this is the closest thing to mandatory you’ll get.

Example 1: Formatting for Google Ads

<examples>
    <example>
        <input>Sell a waterproof hiking boot.</input>
        <output>
        Headline: Conquer Wet Trails
        Desc: Keep feet dry with HydroShield tech. Shop now for 20% off.
        </output>
    </example>
    <example>
        <input>Sell a CRM for small business.</input>
        <output>
        Headline: Chaos Free Sales
        Desc: Organize leads and close deals faster. Try our simple CRM free.
        </output>
    </example>
</examples>

Example 2: Keyword Extraction for Python Scripts

If you’re piping this output into a Python script, you need reliable JSON.

<examples>
    <example>
        <input>The best running shoes for flat feet include the Brooks Adrenaline and Hoka Arahi.</input>
        <output>
        {
          "intent": "commercial",
          "products": ["Brooks Adrenaline", "Hoka Arahi"],
          "category": "footwear"
        }
        </output>
    </example>
</examples>

Part 4: Controlling the Output (No More Hallucinations)

Two printed pages on a desk with a red pen marking the tidier one
Same prompt, same model. The only difference was the shape of the answer.

You want the answer, and only the answer. No “Sure! Here is the blog post you requested.”

6. The <format> Tag

This dictates the shape of the final response.

Example 1: The CMS-Ready HTML

<format>
Output the response as raw HTML code suitable for a WordPress text editor.
Use <h2> for main headers and <h3> for subheaders.
Do not include <html> or <body> tags.
</format>

Example 2: The CSV for Excel

<format>
Output strictly as CSV format.
Columns: Keyword, Search Volume, Difficulty.
</format>

7. The <thinking> or <scratchpad> Tag

This is huge for complex tasks like “analyze this data” or “write a logical argument.” It encourages the AI to show its work before giving you the final answer. This concept is called Chain of Thought (CoT).

Why use it? When the AI “thinks” out loud, it generates intermediate context that can improve the final answer. Just remember: the thinking text is usually for the model’s benefit, not your final deliverable.

Example

<instructions>
Determine if the following keyword is worth targeting.
First, use the <thinking> tag to analyze the competition and volume.
Then, provide your final "Yes/No" decision in the <answer> tag.
</instructions>

8. The <answer> Tag

This is the container for the gold.

Why use it? If you’re using a script to automate this, you can extract everything inside <answer>...</answer> and throw away the conversational fluff. For simple outputs, regex can work. For production, prefer structured outputs or JSON schema when your model/API supports it.

Part 5: Advanced Tactics (For The Automation Nerds)

Okay, you’ve got the basics. Now let’s get fancy. This is for when you’re building tools to generate 100 blog posts at once or automatically audit 50 websites.

Nesting and Attributes

XML-style tags allow for attributes. This is great when you have multiple inputs.

The “Multi-Source” Prompt

Let’s say you want to rewrite a competitor’s article but use your own tone.

<source type="competitor_content">
[Paste Competitor Text Here]
</source>
<source type="my_brand_voice">
[Paste Your Brand Guidelines Here]
</source>
<instructions>
Rewrite the content from <source type="competitor_content"> using the style defined in <source type="my_brand_voice">.
</instructions>

The “Self-Correction” Loop

You can ask the AI to grade itself.

<instructions>
1. Write the email subject line.
2. Critique your own subject line inside <critique>...</critique> tags.
3. Write a better version based on the critique inside <final_answer>...</final_answer> tags.
</instructions>

Tutorial: Building a Keyword Clustering Tool

Let’s put this all together into one mega-prompt you can use right now to group your SEO keywords.

Scenario: You have a list of 50 messy keywords exported from Ahrefs or Semrush, and you want to group them by “Search Intent” so you can plan your content calendar.

The Prompt

<role>
You are an expert SEO strategist specializing in keyword clustering and content architecture.
</role>
<context>
I am building a niche site about "Home Coffee Roasting."
I need to group keywords to avoid keyword cannibalization.
</context>
<instructions>
1. Analyze the keywords provided in the <dataset> tags.
2. Group them into logical clusters based on User Intent (Informational, Transactional, Commercial).
3. Assign a "Parent Topic" for each cluster.
4. Output the result as a Markdown Table.
</instructions>
<format>
| Parent Topic | Intent | Keywords (Comma Separated) |
|--------------|--------|----------------------------|
</format>
<dataset>
coffee roasting temperature
best home coffee roaster
how to roast beans at home
sr800 review
buy green coffee beans
coffee roasting curve explained
</dataset>

The Result

Because you used tags, the AI is much less likely to ramble about how much it loves coffee. It will look at <role>, process <dataset> using <instructions>, and deliver the <format> you asked for.

How To Automate This (The “Money” Section)

Since you’re into automation, here’s how you use this in Python.

When you send a prompt via API (OpenAI or Anthropic), you don’t want to manually copy-paste the result. You want your script to grab it.

Step 1: Force the output tag in your prompt.

Please wrap your final code in <code_block> tags.

Step 2: Extract it. For simple, single-block outputs, regex is fine.

import re

ai_response = """
Here is the Python code you asked for:

<code_block>
print("Hello World")
</code_block>

Hope this helps!
"""

# Okay for simple, single-block outputs.
match = re.search(r'<code_block>(.*?)</code_block>', ai_response, re.DOTALL)

if match:
    clean_code = match.group(1).strip()
    print(clean_code)
else:
    print("No code found!")

Production note: Regex is fragile. It breaks with nested tags, multiple blocks, malformed output, or tags inside code examples. If your model/API supports structured outputs or JSON schema, use that first. If you must use regex, validate the extracted content before you run it or publish it.

This simple pattern lets you build content generation pipelines where the AI handles the logic, and your script handles the publishing—as long as you don’t blindly trust the output.

Conclusion & Resources

XML-style tagging isn’t just about being tidy; it’s about control. It nudges the AI from creative writer toward data processing engine.

Key Takeaways

  1. Be Bossy: Use <instructions> to set the rules.
  2. Be Clear: Use <data> to separate your inputs.
  3. Be Lazy: Use <examples> so you don’t have to explain everything.
  4. Be Logical: Use <thinking> to improve reasoning.
  5. Be Consistent: Pick a small set of tag names and stick to them.
  6. Be Suspicious: Tags are not a security boundary. Validate outputs.

Useful Resources


Appendix A: The XML Tag Glossary (Man Page Style)

For the builders, tinkerers, and Linux lovers, here’s your quick-reference manual for common prompt tags.

Important: These tag names are conventions, not a formal standard. Pick a small set and use them consistently. Don’t mix aliases randomly unless you have a reason.

instructions

NAME

<instructions> — The executive command block.

DESCRIPTION

Defines the primary task, algorithm, or operation the model must perform. This is typically the primary directive in the prompt.

ALIASES

<instruction>, <task>, <command>

EXAMPLES

<instructions>Summarize the text below.</instructions>
<instructions>Extract all email addresses.</instructions>

role

NAME

<role> — Persona definition.

DESCRIPTION

Sets the behavior, tone, expertise level, and perspective of the AI. Crucial for stylistic consistency.

ALIASES

<persona>, <profile>, <system_prompt>

EXAMPLES

<role>You are a Python expert.</role>
<role>You are a grumpy editor.</role>

context

NAME

<context> — Situational awareness.

DESCRIPTION

Provides background information that is true for the current session but is not the direct task itself.

ALIASES

<background>, <info>, <situation>

EXAMPLES

<context>The user is a beginner.</context>
<context>Today is Monday, Oct 2nd.</context>

data

NAME

<data> — Input container.

DESCRIPTION

Holds the raw content (text, code, numbers) to be processed. Helps prevent the model from confusing data with instructions. This is not a security boundary.

ALIASES

<input>, <text>, <document>, <article>, <source>

EXAMPLES

<data>Raw unstructured text...</data>
<source>https://example.com/article</source>

format

NAME

<format> — Output schema.

DESCRIPTION

Explicitly defines how the response should be structured, styled, or encoded.

ALIASES

<output_format>, <response_format>, <style>

EXAMPLES

<format>JSON with keys: 'id', 'val'</format>
<format>Markdown table</format>

examples

NAME

<examples> — Few-shot learning container.

DESCRIPTION

Contains one or more specific examples of input/output pairs to teach the model a pattern.

ALIASES

<few_shot>, <samples>

EXAMPLES

<examples>
  <example>
    <input>A</input>
    <output>B</output>
  </example>
</examples>

thinking

NAME

<thinking> — Chain of Thought (CoT).

DESCRIPTION

A scratchpad for the AI. Encourages the model to reason step-by-step before generating the final answer. The content here is usually discarded by the user but can improve the final result.

ALIASES

<scratchpad>, <thoughts>, <reasoning>, <plan>

EXAMPLES

<thinking>Step 1: Calculate revenue...</thinking>

answer

NAME

<answer> — Final output container.

DESCRIPTION

Delimiters for the final, clean result. Useful for programmatic extraction via regex or other parsing—though structured outputs are safer for production.

ALIASES

<output>, <response>, <result>, <code_block>

EXAMPLES

<answer>42</answer>

constraints

NAME

<constraints> — Negative prompts / boundaries.

DESCRIPTION

Explicit rules on what not to do, or limits on length, style, and scope.

ALIASES

<rules>, <guidelines>, <limits>

EXAMPLES

<constraints>No markdown. Max 50 words.</constraints>

critique

NAME

<critique> — Self-reflection.

DESCRIPTION

Used in iterative prompts where the model reviews its own work before finalizing it.

ALIASES

<review>, <evaluation>

EXAMPLES

<critique>The tone is too formal.</critique>

Appendix B: The Prompt Cookbook (Copy-Paste Scripts)

Hungry for results? Here are 6 ready-to-use recipes. Just fill in the brackets.

1. The Marketing “Pain Agitator” (Affiliate Marketing)

Great for email newsletters or landing page copy.

<role>You are a direct-response copywriter using the PAS (Pain-Agitation-Solution) framework.</role>
<product_info>
[INSERT PRODUCT URL OR DESCRIPTION HERE]
</product_info>
<target_audience>
[INSERT WHO YOU ARE SELLING TO]
</target_audience>
<instructions>
1. Identify the top 3 painful problems this audience faces regarding this topic.
2. Agitate these pains by explaining the consequences of not solving them.
3. Present the product in <product_info> as the specific solution.
4. Output 3 distinct variations of this hook.
</instructions>

2. The Google Ads RSA Generator (PPC)

Generates compliant headlines and descriptions for Responsive Search Ads.

<role>You are a Google Ads expert familiar with 2024 character limits.</role>
<landing_page_content>
[PASTE LANDING PAGE TEXT HERE]
</landing_page_content>
<instructions>
1. Extract the Unique Selling Points (USPs) from the content.
2. Generate 10 Google Ads Headlines (Max 30 characters each).
3. Generate 4 Google Ads Descriptions (Max 90 characters each).
4. Ensure 2 headlines include a Call to Action (CTA).
</instructions>
<format>
**Headlines:**
1. [Headline] (Len: [Count])
...
**Descriptions:**
1. [Description] (Len: [Count])
</format>

3. The SEO “Semantic Gap” Analyzer (SEO)

Finds what your competitors are talking about that you missed.

<role>You are an expert in Semantic SEO and Topical Authority.</role>
<my_content>
[PASTE YOUR ARTICLE DRAFT]
</my_content>
<competitor_content>
[PASTE TOP RANKING COMPETITOR ARTICLE]
</competitor_content>
<instructions>
1. Compare the entities and sub-topics in <competitor_content> vs <my_content>.
2. Identify "Missing Semantics" — topics they covered that I did not.
3. Provide a list of 5 specific headers (H2s or H3s) I should add to my article to close the gap.
</instructions>

4. The Content “Tone Shifter” (Writing)

Turn dry corporate docs into engaging blog posts.

<role>You are a witty, engaging blog editor. You hate jargon.</role>
<input_text>
[PASTE BORING CORPORATE TEXT HERE]
</input_text>
<instructions>
Rewrite the text in <input_text> to be conversational and punchy.
- Use analogies to explain complex terms.
- Shorten sentences.
- Use an active voice.
</instructions>

5. The “Snippet Sniper” (SEO)

Optimizes content to capture Google’s “Position Zero” (Featured Snippet).

<context>
Target Keyword: "How to fix a leaky faucet"
</context>
<instructions>
Write a concise definition paragraph (40-60 words) answering the target keyword.
Start directly with the answer (do not say "Here is how you fix it").
Use simple language (Grade 8 reading level).
Wrap the final paragraph in <snippet_candidate> tags.
</instructions>

6. The “Objection Crusher” (Sales/Ads)

Brainstorms reasons people WON’T buy, so you can address them.

<product>
[DESCRIBE YOUR PRODUCT]
</product>
<instructions>
1. Act as a skeptical buyer. List 5 reasons you would NOT buy this product.
2. Then, act as a master closer. Write a 1-sentence rebuttal for each objection.
3. Output as a table: | Objection | Rebuttal |
</instructions>

Now go forth and tag your prompts like a pro—consistently, skeptically, and with a validation step before you publish.

LEAVE A REPLY

Please enter your comment!
Please enter your name here