<claudexml/>

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

Combined with , lets you parse the final response with a trivial regex.

Wrapper for the final, user-facing answer. Almost always paired with <thinking>.

When to use <answer>

  • You want to programmatically extract the answer (regex on <answer>...</answer>).
  • You're using chain-of-thought and need to hide or separately render the scratchpad.

When not to use it

  • When the entire response is the answer — no need to wrap it.

Minimal example

<answer>42</answer>

Full example

<instructions>
Think inside <thinking> tags. Put the final classification (one of: bug, feature,
question, other) inside <answer> tags.
</instructions>

<ticket>{{ user_ticket }}</ticket>

Common mistakes

  • Trying to put structured data inside <answer> while also asking for a different format outside it. Pick one location for the final output.
Cite this page
<answer> — When and How to Use in Claude Prompts. claudexml.com. https://claudexml.com/tags/answer/