# <role> tag — Claude XML prompting reference

> How to use the <role> XML tag in Claude prompts: when to use it, when not to, minimal and full examples, common mistakes.
>
> Source: https://claudexml.com/tags/role/ · Last updated 2026-05-25

Home / Tags / <role>

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

    An alternative to using the API system prompt when you want the persona inline.

    An inline persona declaration. An alternative to the API `system` field for persona-only setup.


## When to use `<role>`


- Quick experiments in chat where you don't have a system prompt.
- When the persona is the entire instruction.


## When not to use it


- In production code, prefer the API `system` parameter — it's clearer and slightly stronger.
- When the persona conflicts with the system prompt — Claude will struggle to reconcile.


## Minimal example


```xml
<role>
You are a Linux kernel maintainer reviewing a patch.
</role>
```


## Full example


```xml
<role>
You are a copy editor at a prestigious literary magazine. You favor brevity,
strong verbs, and Anglo-Saxon over Latinate vocabulary. You preserve the
author's voice but cut filler ruthlessly.
</role>

<text>
{{ user_draft }}
</text>

<task>Edit the text above. Return only the edited version.</task>
```


## Common mistakes


- Using `<role>` and a system prompt that say different things. Pick one source of truth.


Cite this page

`<role> — When and How to Use in Claude Prompts. claudexml.com. https://claudexml.com/tags/role/`
