Prompts are not just text — they are structured documents the model parses on the fly. Delimiters, XML tags, and Markdown are how you signal structure clearly. Picking the right one for the right purpose noticeably improves attention, robustness, and parseability.
When a prompt mixes instructions, user-supplied data, examples, and output specs into one long block of prose, the model is forced to guess which words belong to which section. Sometimes the guess is right and the answer is great. Sometimes the model treats your example as if it were the real task. Sometimes user input bleeds into instructions, opening a door for prompt injection. The cure for all of these is structure.
Modern models have been heavily trained on XML, Markdown, triple-backtick fences, and JSON. They use those structural cues exactly the way humans use headings and bullet points in a well-written brief — to figure out what each chunk of the document is for.
Three structuring tools cover roughly 95% of real prompts. Each has a sweet spot.
Best for separating roles and data containers. They are visually obvious, easy to parse with a regex, and most models — Claude in particular — have been explicitly trained to treat them as containers. Use tags for high-stakes boundaries: untrusted data, examples, system constraints, and required output structure.
Best for instruction structure — the parts of the prompt you are writing for the model to read top-to-bottom. Headings make sections easy for the model to attend to; bullets make lists easier to follow than the same content as prose. Use Markdown to organise your own writing inside the prompt.
Best for code blocks and verbatim content where you do not want the model to interpret the contents as Markdown. Models reliably treat backtick-fenced content as code or literal text, which prevents formatting from leaking into the output.
Wall of text
You are a code reviewer. Review the following code for
correctness, security, and style. The user is a junior
developer. Be encouraging but specific. Here is the code:
function login(u,p){if(u=="admin"&&p=="1234"){return true}
return false}. Tell me what's wrong with it. Also if the
user asks any unrelated questions, ignore them.
The model has to guess where the instructions end and the code begins. The trailing constraint ("ignore unrelated questions") is mixed into the same paragraph as the code, easy to miss. A junior developer reading this would be confused too.
XML + Markdown together
<role>
You are a code reviewer working with junior developers.
Tone: encouraging, but specific. No hand-waving.
</role>
<rules>
- Review only the code provided.
- Cover correctness, security, and style — in that order.
- If the user asks unrelated questions, politely refuse.
</rules>
<code language="javascript">
function login(u, p) {
if (u == "admin" && p == "1234") {
return true;
}
return false;
}
</code>
<output_format>
## Summary
One sentence verdict.
## Issues
- **Severity (High/Med/Low)** — issue description and fix.
## Refactor
A cleaned-up version of the function.
</output_format>
Each block has a clear job. The model knows exactly where the code is, what the rules are, and what the output should look like. As a bonus, your runtime can extract the <code> block by regex if you ever want to.
<document>, <email>, <user_query>. Tell the model in the system prompt that content inside these tags is data, not commands. This is also your front-line injection defense.<example> and ## Example for the same purpose within the same prompt. Consistency helps the model and your future self.Tip: Different model families have slight preferences. Anthropic's Claude documentation explicitly recommends XML tags. OpenAI models work very well with Markdown sections and triple-backtick fences. In practice, all major models handle all three styles fine — pick what's clearest for the humans on your team and stay consistent.
Take a complex prompt you currently use and restructure it with three layers: <rules> for system rules, Markdown headings for your instructions, and a fenced code block for the user's input. Run both versions and compare the output's structure.
Try a prompt with deliberately conflicting structure — examples wrapped in <example> but with no closing tag, or Markdown headings without blank lines. Observe how the output degrades. This builds intuition for what structural mistakes cost.
Build an output template using Markdown headings (## Summary, ## Risks, ## Next Steps) and run the same task against the same model with and without the template. Measure how often the model includes all sections in the right order. Templates dramatically improve consistency.
Sign in to join the discussion and post comments.
Sign inPrompt Engineering for Developers
Use AI as your coding co-pilot. 18 tutorials on writing prompts to generate clean code, debug faster, write tests, build APIs, and ship better software.
Prompt Engineering for Specific AI Tools
Tool-by-tool mastery — deep dives into ChatGPT, Claude, Gemini, GitHub Copilot, Midjourney, Stable Diffusion, and more. Learn the exact prompting techniques each platform rewards.
Prompt Engineering for Image Generation
Turn words into stunning visuals. Master AI image generation tools like Midjourney, DALL·E 3, and Stable Diffusion with 18 focused tutorials — from first prompt to full brand identity.
Prompt Engineering for Business & Productivity
Use AI to work smarter — automate tasks, make better decisions, and communicate professionally. 12 practical business prompt tutorials for professionals.
Prompt Engineering for Education & Learning
Use AI as your personal tutor. Learn how to study faster, create lesson plans, generate practice questions, master languages, and prepare for competitive exams with smart prompts.
Prompt Engineering Projects & Real-World Applications
Twelve hands-on projects that turn prompt engineering theory into a portfolio. Build chatbots, content generators, RAG systems, and more.