Model guides

Claude prompting: a practical guide

How to prompt Claude. XML tags, where to place long documents, examples, extended thinking, explicit instructions, and the mistakes that are specific to Claude.

Claude, Anthropic’s family of models, responds to the same fundamentals as any model: a clear task, relevant context, and a stated format. This guide covers the habits that matter specifically for Claude, based on Anthropic’s published prompting guidance.

Model names and limits change, so the advice here is about stable behavior. Check Anthropic’s documentation for current models.

Be clear, direct, and specific

Anthropic’s first recommendation is to treat Claude like a capable new colleague who has no context on your project. State what the output is for, who will read it, and what a good result looks like.

Recent Claude models follow instructions precisely. That has two effects worth planning for:

  • Ask for what you want. If you want Claude to go beyond the literal request, for example to implement a change instead of only suggesting one, say so.
  • Drop the emphasis. Capitals and “CRITICAL” are unnecessary and can cause a rule to be applied too broadly. A plain sentence works.

Explain why

Claude generalizes well from a reason. Compare:

  • Never use ellipses.
  • Your response will be read aloud by a text-to-speech engine, so never use ellipses, because the engine cannot pronounce them.

The second lets Claude handle related cases you did not list.

Structure prompts with XML tags

Claude works particularly well with XML-style tags that separate the parts of a prompt. There are no special tag names; choose ones that describe the content and use them consistently.

Review the contract in <contract> tags against the checklist in
<checklist> tags. Put your findings in <findings> tags.

<contract>
{{contract_text}}
</contract>

<checklist>
{{checklist}}
</checklist>

Tags help in three ways: Claude does not confuse instructions with data, you can refer to a section by name, and you can ask for output in tags that your code extracts easily.

Put long documents at the top

With long inputs, place the documents near the beginning of the prompt and the question or instructions at the end. Anthropic reports that a query placed after long documents can noticeably improve response quality.

For several documents, wrap each in its own tags with source metadata:

<documents>
  <document index="1">
    <source>q3-report.pdf</source>
    <document_content>{{report}}</document_content>
  </document>
</documents>

Using the documents above, list the three largest risks.

For tasks over long material, ask Claude to quote the relevant passages first and then answer from the quotes. See RAG prompting.

Use examples

Examples are one of the most reliable ways to steer format, tone, and structure. Wrap them in <example> tags so Claude treats them as illustrations, and make them varied: Claude pays close attention to examples and will reproduce a pattern they all share, including ones you did not intend.

Give Claude a role in the system prompt

Set the role and standing rules in the system prompt, and put the task in the user turn. Even one sentence of role focuses tone and depth. See system prompts and role prompting.

Extended thinking

Claude models can reason before answering, a feature called extended thinking. When it is on:

  • Give high-level guidance (“think carefully about the edge cases”) instead of prescribing each step. Claude’s own approach is often better than a scripted one.
  • Do not also ask for step-by-step reasoning in the answer unless you need it shown.
  • Ask Claude to verify its work before finishing on tasks where errors are costly.

When thinking is off, asking Claude to reason inside <thinking> tags before answering in <answer> tags gives a similar benefit. See chain-of-thought prompting.

Control the format

  • Say what to do, not what to avoid. “Write in flowing paragraphs” works better than “do not use markdown”.
  • Match the style. The formatting of your prompt influences the formatting of the response. A prompt in plain prose tends to get prose back.
  • Request tags for parts you will parse.
  • For strict JSON, use tool use with an input schema or the structured outputs feature, and validate the result. See structured output prompting.

Tools and agents

Claude is widely used in agent settings, including through the Model Context Protocol, which Anthropic introduced.

  • Describe each tool thoroughly: what it does, when to use it, and what it returns.
  • State whether Claude should act or only propose. It follows that instruction closely.
  • For long tasks, have Claude keep notes in a file so progress survives a context reset.
  • Independent tool calls can run in parallel; say so if you want speed.

See prompts for AI agents. The PromptFlowEngine MCP server can be added to Claude Desktop or Claude Code so Claude can analyze, restructure, and sanitize prompts as tools.

Token counting and caching

Anthropic does not publish an offline tokenizer for current models, so offline counts are approximations. PromptFlowEngine labels its Claude counts approximate for that reason. For an exact figure, use Anthropic’s token-counting endpoint.

Prompt caching is opt-in: you mark the end of the stable part of the prompt, and repeated requests read it at a reduced rate. Keep the stable content first. See token optimization.

Common mistakes with Claude

Mistake What happens Fix
Shouting rules in capitals Over-application Plain statements with the reason
Question before a long document Weaker use of the document Documents first, question last
Unmarked pasted content Instructions and data blur Wrap in XML tags
Only uniform examples Unintended pattern copied Vary the examples
Vague request, expecting initiative A literal, minimal answer Ask explicitly for the extra work
Negative format rules Inconsistent formatting State the format you want

Optimizing a Claude prompt

  1. State the task and its purpose.
  2. Wrap each input in descriptive tags.
  3. Move long documents to the top and the question to the end.
  4. Add two or three varied examples if format or tone matters.
  5. Remove repetition and emphasis.

The PromptFlowEngine prompt optimizer in structured mode wraps template variables in tags and removes repeated instructions, then verifies nothing was lost. The Chrome extension does the same inside claude.ai.

Compare with the ChatGPT and OpenAI prompting guide and the Gemini prompting guide.