Structure Your Instructions
Introduction
Section titled “Introduction”🎯 Learning goals
- Understand why structured instructions give more consistent results
- Be able to use different structuring techniques (sections, XML tags, hierarchies)
- Identify common structural mistakes and how to avoid them
- Apply structural principles to your own system prompt
In section 2 you learned the five pillars — WHAT, WHY, HOW, WHO, and TONE. Now we take it a step further, because even if you have all the right components in place, they can easily become messy if they’re not organized correctly. Structure is not an aesthetic choice — it’s a fundamental part of making AI work reliably and consistently.
In this section you’ll learn three concrete structuring techniques, the most common mistakes to avoid, and a checklist you can apply directly to your own prompts.
Start by understanding what structure actually does for a prompt — and why it matters.
Why does structure matter for prompting?
Think of it like the difference between a well-packed suitcase and one where everything was just thrown in. The contents are the same, but the structure determines whether you can quickly find what you need — or have to dig through everything.
The exact same principle applies to AI models: a well-structured prompt helps the model quickly identify what’s important, which rules apply, and how different parts connect. An unstructured prompt leaves the model guessing — and guessing leads to inconsistent results.
There are three concrete reasons why structure makes a difference in practice — and they directly affect how the AI interprets and follows your instructions.
Three reasons why structure is critical
1. The model knows where to look
Section titled “1. The model knows where to look”When information is divided into clear sections, the model doesn’t have to guess what’s an instruction, an example, or background information. This drastically reduces the risk of misinterpretation.
2. You get consistent results
Section titled “2. You get consistent results”A chaotic prompt can give different answers every time — even with the same input. Structure creates predictability and reliability, which is critical when you’re building something that will be used in practice.
3. Easier to maintain and develop
Section titled “3. Easier to maintain and develop”When you or someone else on the team needs to update the prompt later, it’s enormously easier if everything has its place. You know immediately where to adjust the rules, add examples, or change the tone.
Now that you understand why structure matters, let’s look at three concrete techniques you can start using right away — regardless of how simple or complex your prompt is.
Structuring techniques you can use right away
Technique 1: Clear sections with headings
Section titled “Technique 1: Clear sections with headings”The simplest structuring method is to divide your prompt into named sections. This works great for most use cases and directly answers the five pillars from section 2.
## ROLEYou are an experienced and educational IT support specialist working ata mid-sized company.
## TASKYour primary task is to answer employees' IT questions and guidethem step-by-step through solutions.
## PURPOSEThe goal is to reduce the load on IT support and give employeesquick help with recurring problems.
## RULES- Always answer in English- Use max 150 words per response- If you don't know the answer, write: "I don't have information about this. Contact IT support at support@company.com"- Always include a source reference when citing internal guides
## TONEBe friendly, professional, and encouraging. Avoid technical jargonunless necessary.Each section has a clear purpose and the model can easily distinguish between what it should do (TASK) and how it should do it (RULES + TONE).
Technique 2: XML tags for complex structuring
Section titled “Technique 2: XML tags for complex structuring”When your instructions become more advanced — especially if you have many examples, long lists, or hierarchical information — XML tags can make a big difference. Anthropic particularly recommends this for Claude models.
Think of XML tags as labels on boxes. Just as you write “KITCHEN GLASS – FRAGILE” on a box when packing, XML tags name things so both humans and models know what’s inside:
<cookbook> <recipe> <name>Pancakes</name> <ingredients> <ingredient>Flour</ingredient> <ingredient>Eggs</ingredient> </ingredients> </recipe></cookbook>Each <tag> opens a box and </tag> closes it — you can build hierarchies of boxes within boxes, just like a family tree.
Benefits of XML
Section titled “Benefits of XML”- Clearer boundaries between different parts
- Easier for the model to distinguish instructions from content
- Better for longer context and complex tasks
Example system prompt with XML tags
Section titled “Example system prompt with XML tags”<role>You are an experienced HR specialist with expertise in employment law.</role>
<task>Answer questions about the company's HR policies and provide guidanceon employment-related questions.</task>
<constraints>- Never give legal advice — refer to trade unions or lawyers in complex cases- Always cite the correct policy document with page number- Answer within 200 words- If information is missing: "Contact the HR department directly for this question"</constraints>
<examples><example>User: "How many vacation days am I entitled to?"Assistant: "According to the company's vacation policy (p. 3), full-time employeesare entitled to 25 vacation days per year. Contact HR at hr@company.com for yourexact vacation entitlement."</example></examples>
<tone>Professional, friendly, and supportive. Use accessible languagethat makes employment questions understandable.</tone>When should you use XML tags?
Section titled “When should you use XML tags?”- When you have more than 3 examples
- When handling long context (documents, data tables, etc.)
- When building complex assistants with multiple tools
- When you want to be especially clear about what is instructions vs. data
Technique 3: Hierarchical organization for complex assistants
Section titled “Technique 3: Hierarchical organization for complex assistants”For more advanced use cases, you may need to build hierarchies where some instructions are more important than others.
The prioritization principle (Google and Anthropic)
Section titled “The prioritization principle (Google and Anthropic)”- Place the most critical instructions last in the prompt
- Negative constraints (“do NOT X”) should come at the end
- Important formatting rules should be repeated near the end
## OVERALL ROLEYou are an AI assistant for customer service at an e-commerce platform.
## PRIMARY TASKS1. Answer questions about order status, deliveries, and returns2. Help customers with account information3. Escalate complex issues to human support
## SECONDARY TASKS- Give product recommendations upon request- Inform about ongoing promotions
## CRITICAL SAFETY RULES (always follow these)❌ NEVER share complete card numbers or passwords❌ NEVER change delivery addresses without verification via email❌ NEVER process refunds over $500 without approval✅ In case of suspected fraud → stop immediately and escalate
## IMPORTANT: Priority order in case of conflictIf in doubt, always prioritize safety rules over fast service.The safety rules are marked as critical, placed late in the prompt, and visual symbols (❌ ✅) make the constraints extra clear.
Knowing the right techniques is one thing — avoiding the most common pitfalls is another. Here are the three mistakes that occur most frequently.
Common structural mistakes – and how to avoid them
Mistake 1: Everything in one block of text
Section titled “Mistake 1: Everything in one block of text”❌ Avoid:
You are a customer support assistant who should help users with questions aboutproducts and you should be friendly and answer briefly and if you don't know theanswer you should say so and you should always ask if the user needs more help...✅ Better: Divide into clear sections (ROLE, TASK, RULES, TONE) according to Technique 1 above.
Mistake 2: Instructions mixed with examples
Section titled “Mistake 2: Instructions mixed with examples”❌ Avoid:
You should categorize customer emails. For example "I want to return myorder" should be categorized as Return and you should be concise and if it'sabout delivery it should be categorized as Delivery and always answer withjust the category.✅ Better:
## TASKCategorize incoming customer emails into the correct category.
## CATEGORIES- Return- Delivery- Product questions- Technical support- Other
## EXAMPLESEmail: "I want to return my order"Category: Return
Email: "When will my package arrive?"Category: Delivery
## FORMATAnswer only with the category name, nothing else.Mistake 3: Important constraints early in the prompt
Section titled “Mistake 3: Important constraints early in the prompt”Models can “forget” important constraints if they’re placed too early — especially negative instructions.
❌ Avoid (bad placement):
NEVER change user data without approval.
[... 300 words of other instructions ...]
Now help the user with their request.✅ Better (critical rules last):
[... other instructions ...]
## CRITICAL: Safety rules (always follow)- NEVER change user data without explicit approval- NEVER share sensitive information with unauthorized partiesAlways run your system prompt through this checklist before putting it into production — it helps you determine whether the structure actually holds.
Checklist: Does your prompt have good structure?
Use this checklist as you build and improve your system prompt:
✅ Do I have clear sections? (Role, Task, Rules, etc.)
✅ Are examples separated from instructions?
✅ Are my most important constraints placed late in the prompt?
✅ Can someone else read and understand my prompt within 30 seconds?
✅ Are negative instructions (“do NOT”) clearly marked?
✅ Am I using XML tags if I have complex context or many examples?
If you can answer yes to at least 4 out of 6 points, you’re on the right track!
Key takeaways
Section titled “Key takeaways”Structure isn’t just “nice formatting” — it’s a fundamental part of making AI work reliably. Here are the four most important insights to take away.
- Clear sections make it easy for the model to find the right information and drastically reduce the risk of misinterpretation.
- XML tags help with complex context and many examples — they create clear boundaries the model can navigate safely.
- Hierarchical prioritization ensures important rules are followed and primary tasks don’t drown out critical constraints.
- Critical instructions last prevents the model from “forgetting” them — always place negative constraints and safety rules late in the prompt.
Test your knowledge
5 questions · 100% correct to pass · Review your answers when done