How to Write Prompts for Claude (Anthropic Style)
Claude rewards structure. Tag your inputs, split instructions from data, show examples and let it think out loud, and you will get cleaner, more reliable output.
Claude is unusually responsive to how you organize a prompt. The same request, written as a wall of text or as a tagged, sectioned brief, can produce very different results. This guide covers the moves that pay off most: XML tags, a clean split between the system prompt and the user turn, structured thinking, and concrete examples.
Use XML tags to mark up your prompt
Claude was trained on a lot of tagged text, so it follows <tags> well. Wrap each distinct part of your prompt in a named tag so the model knows where the instructions end and the data begins. This is the single highest-leverage habit when prompting Claude.
<instructions>
Summarize the support ticket below in two sentences.
Then classify its urgency as low, medium, or high.
</instructions>
<ticket>
Hi, our checkout page has been returning a 500 error
for the last hour. We are losing sales. Please help.
</ticket>
<output_format>
Return a JSON object: { "summary": "...", "urgency": "..." }
</output_format>System prompt vs user turn
Put durable role and behavior rules in the system prompt, and put the actual task and data in the user turn. The system prompt is who Claude is across the whole conversation. The user turn is what you want right now. Mixing them makes both harder to maintain.
| Goes in the system prompt | Goes in the user turn |
|---|---|
| Role, tone, hard constraints | The specific question or task |
| Output format defaults | The document or data to act on |
| Domain rules that never change | One-off instructions for this request |
from anthropic import Anthropic
client = Anthropic()
resp = client.messages.create(
model="claude-opus-4-8",
max_tokens=1024,
system=(
"You are a precise support triage assistant. "
"Always answer in the requested format and never invent ticket fields."
),
messages=[{"role": "user", "content": tagged_prompt}],
)Let Claude think before it answers
For anything that needs reasoning, ask Claude to work through the problem first. The simplest version is a prompting technique: tell it to reason inside a <thinking> block, then give the final answer in an <answer> block so you can parse just the result. On current models you can also turn on adaptive thinking through the API, which lets Claude decide how much to reason on its own.
Show, do not just tell
A couple of worked examples beat a paragraph of description. Wrap each example in a tag and show the exact input and the exact output you want. Claude will match the shape closely.
A checklist for Claude prompts
- Tag every distinct input section with a clear name.
- Put role and constraints in the system prompt, task and data in the user turn.
- Ask for reasoning before the answer when the task is non-trivial.
- Give one or two tagged examples of the input and output you want.
- State the output format explicitly, ideally with a tag of its own.
1:42:18Structure is the prompt. With Claude, the tags you choose do half the work of the instruction.
0 Comments
Loading discussion...