<claudexml/>

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

Separates static, descriptive background from active instructions and from the user's question.

Wraps descriptive background information that the model should be aware of but not treat as a command.

When to use <context>

  • Telling Claude about the user, the domain, or the broader conversation state.
  • Providing situational details that affect tone or depth but aren't instructions.

When not to use it

  • Don't put retrieved documents here — use <document>/<documents> instead, which Claude is more strongly trained to treat as evidence.
  • Don't put few-shot examples here — use <example>.

Minimal example

<context>
The user is a kindergarten teacher and unfamiliar with software development jargon.
</context>

Full example

<instructions>
Answer the user's question. Calibrate vocabulary to the context.
</instructions>

<context>
The user is a senior backend engineer with 15 years of experience.
They are deeply familiar with relational databases but new to vector search.
The product is an internal RAG tool over Confluence pages.
</context>

<question>
Should we re-rank results before sending them to the LLM?
</question>

Common mistakes

  • Stuffing the entire conversation history into <context> when it would be clearer as turns in the messages array.
  • Mixing instructions and context — Claude will sometimes follow context as instructions if no <instructions> block is present.
Cite this page
<context> — When and How to Use in Claude Prompts. claudexml.com. https://claudexml.com/tags/context/