<claudexml/>

<examples> — when and how to use it in Claude prompts

Groups few-shot examples together so they are clearly demarcated from the live question.

Wrapper around multiple <example> tags. Tells Claude "the next block is demonstrations, not the actual task."

When to use <examples>

  • Any time you have two or more examples — wrap them.
  • When you want a single, scannable section the model treats as one logical unit.

When not to use it

  • Not needed for a single example, though it doesn't hurt.

Minimal example

<examples>
  <example>...</example>
  <example>...</example>
</examples>

Full example

<instructions>
Convert questions into SQL against the schema in <schema>.
</instructions>

<schema>
users(id, email, signup_date)
orders(id, user_id, total_cents, created_at)
</schema>

<examples>
  <example>
    <q>How many users signed up in March 2026?</q>
    <sql>SELECT COUNT(*) FROM users WHERE signup_date >= '2026-03-01' AND signup_date < '2026-04-01';</sql>
  </example>
  <example>
    <q>Total revenue from each user, descending.</q>
    <sql>SELECT user_id, SUM(total_cents) AS revenue FROM orders GROUP BY user_id ORDER BY revenue DESC;</sql>
  </example>
</examples>

<q>{{ user_question }}</q>

Common mistakes

  • Mixing <example> tags with unrelated content inside the wrapper. Keep it clean.
Cite this page
<examples> — When and How to Use in Claude Prompts. claudexml.com. https://claudexml.com/tags/examples/