How to Write Prompts for Claude: 8 Techniques That Work in 2026

11 min read · Updated 2026-10-21

To write a good prompt for Claude, state the task and the finished output precisely, explain why each constraint matters, wrap different kinds of content in XML tags such as <instructions> and <document>, put long documents at the top with your question at the end, and include three to five varied examples when format or tone matters. Anthropic’s own guidance recommends all of these; it also notes that prefilling Claude’s reply is no longer supported on its newest models.

Why Claude rewards a different style of prompt

Every major assistant benefits from clear instructions, but Claude has a few habits worth designing for. Anthropic describes the right mental model as briefing "a brilliant but new employee who lacks context on your norms and workflows": highly capable, but unable to guess what you left out. Its current models follow instructions closely, so a vague request produces a careful answer to the vague request rather than the one you meant.

That cuts both ways. A precise prompt gets a precise result, and a rule written without its reason gets applied literally, including in places you did not intend. Most of the techniques below are ways of giving Claude the context a human colleague would ask for before starting.

Everything here applies whether you use Claude in the app, through the API, or inside a tool built on it. Where something only applies to the API (system prompts, prefill), it is labelled.

1. Say exactly what "done" looks like

Anthropic’s "golden rule" is a good test: show your prompt to a colleague who knows nothing about the task. If they would need to ask questions, Claude needs the answers too. Name the audience, the length, the format and the one thing the answer must achieve.

If you want more than the minimum, ask for it. Claude’s guidance says to request "above and beyond" behaviour explicitly rather than hoping the model infers it.

  • Weak: "Write a product update email."
  • Strong: "Write a product update email to existing customers announcing [FEATURE]. Audience: small-business owners who use the product weekly. Length: under 150 words. Lead with what they can now do, not with the feature name. End with one link to [URL]. Plain text, no emojis."

2. Explain the why behind each rule

This is the technique most people skip and the one that most often fixes odd behaviour. Anthropic’s example contrasts "NEVER use ellipses" with "Your response will be read aloud by a text-to-speech engine, so never use ellipses since the text-to-speech engine will not know how to pronounce them." The second version works better because Claude can generalise from the reason — it will also avoid other things a speech engine would stumble over.

In practice: for every constraint in your prompt, add a short "because". "Keep it under 150 words because it is read on a phone between meetings." "Avoid jargon because half the readers are new customers." The reasons also make your prompt easier to maintain, because you will remember why each rule is there.

3. Separate instructions from material with XML tags

When a prompt mixes instructions, background, examples and the text to work on, Claude can mistake one for another — for example, following an instruction that appears inside a pasted email. Anthropic recommends wrapping each kind of content in its own descriptive tag. There is no special list of tag names; consistency matters more than the words.

  • <instructions>What to do, step by step.</instructions>
  • <context>Who it is for, why it matters, constraints.</context>
  • <document>The material to work on — pasted text, a transcript, data.</document>
  • <examples><example>…</example><example>…</example></examples>
  • You can then refer to tags by name: "Summarise the text in <document> using the format shown in <examples>."

4. Put long documents first and the question last

For long inputs — reports, contracts, transcripts, several files — place the material at the top of the prompt and your instructions and question at the end. Anthropic says this improves performance across its models and reports that queries at the end can improve response quality by up to 30 percent in its tests, especially with complex, multi-document inputs.

With several documents, wrap each one in its own tag with its source, for example <document index="1"><source>Q3 board deck</source><document_content>…</document_content></document>. For long documents, asking Claude to first pull out the quotes relevant to your question, and then answer from those quotes, keeps the answer anchored to the text instead of to a general impression of it.

5. Use three to five examples — and make them different

Examples are one of the most reliable ways to control format, tone and structure. Anthropic suggests three to five, and the important word in its guidance is diverse: if every example has the same length or opening, Claude will copy that too. Vary them on the dimensions you do not care about and keep them identical on the ones you do.

Wrap each in <example> tags so it is clearly an example and not an instruction. If you only have one good example, say which parts of it should be copied ("match the structure and tone, not the topic").

6. Give Claude a role (in the system prompt if you have one)

A single sentence of role — "You are a senior support lead for a B2B software company" — focuses tone and judgement. On the API, Anthropic recommends putting it in the system prompt. In the Claude app, the equivalent is a Project’s custom instructions, or simply the first line of your message.

A role is not a substitute for context. "You are an expert marketer" adds little; "You are writing for a two-person bakery that cannot afford paid ads" changes the answer.

7. Tell it what to do, not only what to avoid

Formatting instructions phrased as prohibitions tend to work less well than positive ones. Anthropic’s example: instead of "Do not use markdown in your response", try "Your response should be composed of smoothly flowing prose paragraphs." The style of your own prompt also leaks into the answer — a prompt full of bullet points tends to get bullet points back.

Length works the same way. "Be concise" is vague; "three sentences, then a bulleted list of at most five actions" is a target Claude can hit.

8. Drop the prefill trick on new models

Older guides recommend "prefilling" — writing the first words of Claude’s reply yourself (for example an opening "{") to force a format. Anthropic’s documentation now states that starting with its 4.6 models, prefilled responses on the last assistant turn are no longer supported and return an error. This only affects API users; in the app you never had that option.

The replacements are simple: ask directly ("Respond with only valid JSON matching this schema"), ask for the output inside XML tags you can extract, or use the API’s structured-output or tool features when the format must be guaranteed. To skip preambles, say "Respond directly without preamble."

A reusable Claude prompt template

This combines the techniques above. Copy it, replace the brackets, and delete any block you do not need.

<context>I am [WHO YOU ARE]. This is for [AUDIENCE], who [WHAT THEY NEED/KNOW]. It matters because [WHY].</context> <document>[PASTE MATERIAL, IF ANY]</document> <examples><example>[A GOOD EXAMPLE]</example></examples> <instructions>[TASK, AS NUMBERED STEPS]. Constraints: [LENGTH, TONE, FORMAT — each with a short reason]. If information is missing, list the questions you need answered instead of guessing.</instructions>

If you would rather not assemble this by hand, PromptVibe’s free Claude prompt generator builds the same structure from a one-line goal.

Common mistakes

  • Rules without reasons, applied more literally than you meant.
  • Pasting a long document after the question instead of before it.
  • One example, copied too faithfully — including its length and topic.
  • Asking for "no markdown" while writing the prompt in heavy markdown.
  • Relying on prefill in API code written for older models.
  • Asking Claude to "be accurate" instead of giving it the facts and telling it to say when something is missing.
  • Writing in one language and expecting the answer in another without naming it — state the output language and variety.

Limits worth knowing

Good prompting improves structure, relevance and consistency; it does not make Claude a source of truth. For facts that matter — prices, dates, legal or medical details — supply them in the prompt or verify the answer. Model behaviour also changes between versions, which is why Anthropic itself says to re-check techniques against your own tests when you switch models. Keep a few test inputs for the prompts you rely on and re-run them after an upgrade.

Frequently Asked Questions

Does Claude really work better with XML tags?

Anthropic recommends XML tags for prompts that mix instructions, context, examples and inputs, because they make it unambiguous which part is which. There are no magic tag names; use descriptive ones consistently. For a one-line question they add nothing.

Where should I put a long document in a Claude prompt?

At the top, above your instructions and question. Anthropic reports that putting the query at the end can improve response quality by up to 30 percent in its tests with complex, multi-document inputs.

Can I still prefill Claude’s response?

Not on Anthropic’s newest models: its documentation says prefilled responses on the last assistant turn are unsupported starting with the 4.6 models and return an error. Ask for the format directly, request output in XML tags, or use structured outputs instead. Older models still accept prefill.

How many examples should I give Claude?

Anthropic suggests three to five well-chosen, varied examples, wrapped in <example> tags. Vary them on details you do not care about so Claude copies the pattern, not the incidentals.

Is a Claude prompt different from a ChatGPT prompt?

The fundamentals are the same: a clear task, context, constraints and a defined output. Claude-specific habits are mostly about structure — XML tags, long documents first, explaining the reason for rules — and avoiding prefill on new models. A well-structured prompt usually transfers between assistants with small edits.

Put this into practice

Generate a structured prompt or turn your workflow into a reusable Agent Skill — both free.

Prompt Generator →Skill Generator →Free Claude prompt generator →

Related articles

→ ChatGPT vs Claude vs Gemini: How to Choose for Your Task→ System Prompt Examples That Actually Work→ Few-Shot Prompting: Teaching AI by Example→ How to Write Gemini Prompts: Google’s Own Advice, Made Practical→ How to Prompt AI in Your Own Language (Not Just English)