promptgarten ๐ŸŒฑ
๐ŸŒ ES
Prompt patternโ—โ—‹โ—‹4 min ยท +20 XP

Prompt Structures: Layout That Improves Results

Good prompts have visible structure: a clear task, separated context sections, examples, and a specified output format.

Clear and direct

The most important rule from Anthropic's prompting docs: be precise about what you want. The test: show your prompt to a colleague with no prior context. If they would be confused, the model will be too. Numbered steps help when order or completeness matters.

Separate sections โ€” with XML tags

As soon as a prompt mixes several content types (instructions, context, examples, input data), Anthropic recommends XML tags: <instructions>, <context>, <example>. Each content type gets its own tag โ€” so the model can tell unambiguously what is an instruction and what is just an example. Consistent, descriptive tag names matter.

Assign a role

Even a single sentence in the system prompt ("You are an experienced Python developer") noticeably focuses behavior and tone.

Show examples (few-shot)

Per the docs, examples are one of the most reliable ways to steer format and style. Recommended: 3 to 5 examples, relevant to your real use case and varied enough, each wrapped in <example> tags.

Specify the output format

Say what the model should do โ€” not what it should avoid: "Respond in flowing prose" works better than "No markdown". For fixed structures, a format example or a dedicated tag for the answer helps.

EXAMPLE

<instructions> Summarize the text in 3 bullet points. Respond in English. </instructions> <context> Audience: beginners with no prior knowledge. </context> <text> [the text goes here] </text>

๐Ÿ› ๏ธ EXERCISE โ€” TRY IT YOURSELF

Take one of your own unstructured prompts and rebuild it with structure.

  1. Pick a prompt you used recently that mixes instructions, context, and data.
  2. Split it into sections with tags: <instructions>, <context>, and a tag for the input data. State the desired output format at the end.
  3. Send both versions to your model and compare the answers for accuracy and format adherence.

โœ… SELF-CHECK

  • โ˜ Can you clearly show in your prompt where the instruction ends and the data begins?
  • โ˜ Did you state the output format positively ('do X') instead of negatively ('no Y')?
  • โ˜ Would a colleague with no prior context understand your prompt on first read?

QUICK QUIZ

Why does Anthropic recommend XML tags like <instructions> and <context> in prompts?

SOURCES

RELATED TOPICS

What Is a Prompt? โ—โ—‹โ—‹System Prompt vs. User Prompt โ—โ—โ—‹Pattern: Feed Context Instead of Asking Vaguely โ—โ—‹โ—‹Pattern: Plan First, Then Code โ—โ—โ—‹