What you will be able to do
- Rewrite a vague or bare-rule instruction into a specific one that explains its purpose
- Choose few-shot examples that are relevant, diverse and clearly separated from instructions
- Use XML tags to keep instructions, context, examples and inputs distinct
- Decide what belongs in the system prompt and what belongs in the user turn
- Constrain Claude's output with an explicit JSON, XML or template format
Key concept
Prompt as a briefing for a capable newcomer — Claude brings strong general ability to a request but knows nothing about your norms, audience or definition of done. Every prompt technique on this page is a way to supply that missing context explicitly instead of hoping Claude infers it.
1.Write the prompt a new colleague could follow
Claude starts every request without knowing your conventions, your audience, or what a finished answer looks like. Anthropic's guidance says the more precisely you explain what you want, the better the result, and it gives a simple test, the golden rule. Show your prompt to a colleague who has minimal context on the task and ask them to follow it. If they would be confused, Claude will be too.
Three habits follow from that test. First, be specific about the output format and constraints instead of leaving them implied. Second, if you want more than the minimum, ask for it. "Create an analytics dashboard" gets you a dashboard. Adding "Include as many relevant features and interactions as possible. Go beyond the basics to create a fully-featured implementation" asks explicitly for the fuller version. The guidance tells you to request "above and beyond" behaviour directly rather than relying on Claude to infer it from a vague prompt. Third, when the order or completeness of steps matters, write the steps as a numbered list or bullet points.
The documented fix is to give a reason, not to shout louder. The best-practices guide rewrites the rule as: "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." Giving the context or motivation behind an instruction helps Claude understand your goal and respond more precisely. The guide's explanation is short: Claude is smart enough to generalize from the explanation.
A developer prompts Claude with the bare request "Create an analytics dashboard" and consistently gets a minimal, bare-bones implementation. The team wants a fully-featured result with rich interactions on the first attempt, without relying on multiple follow-up turns. What change to the prompt best achieves this?
Correct answer: A — Rewrite the request to state the desired scope explicitly, such as asking for as many relevant features and interactions as possible and to go beyond the basics, rather than leaving scope for Claude to infer
- A. Correct. Claude responds well to explicit, specific instructions; if you want above-and-beyond behavior, you need to request it directly rather than relying on the model to infer elevated scope from a vague prompt.
- B. Incorrect. Capitalization is not a documented mechanism for increasing thoroughness; it does not substitute for stating the desired scope and features explicitly.
- C. Incorrect. Temperature controls sampling randomness, not the thoroughness or feature-completeness of a response; it is not the lever for controlling scope.
- D. Incorrect. Moving unchanged, vague wording into the system prompt does not add the specificity needed; the fix is adding detail about desired scope, not relocating the same wording.
Sources1
2.Steer format and tone with a few well-chosen examples
Sometimes describing the output isn't enough, and it's clearer to show it. The guide calls examples one of the most reliable ways to steer Claude's output format, tone and structure. It says a few well-crafted examples, a technique known as few-shot or multishot prompting, improve accuracy and consistency. What makes them work is quality, not quantity, and the guidance names three properties to aim for.
| Property | What to do |
|---|---|
| Relevant | Mirror your actual use case closely |
| Diverse | Cover edge cases and vary enough that Claude doesn't pick up unintended patterns |
| Structured | Wrap each example in <example> tags, and multiple examples in <examples> tags, so Claude can tell them apart from instructions |
They fail on diversity. Examples should cover edge cases and vary enough that Claude doesn't pick up unintended patterns. A uniform set can teach the accidental similarities (length, tone, one label) instead of the rule you meant, and it never shows Claude the hard cases.
A team is building a multishot prompt to classify support tickets into categories, but Claude's output format is inconsistent across different ticket inputs. They want to revise the example set to follow Anthropic's guidance on using examples effectively. Select the changes that align with that guidance.(Select 3)
Correct answers: A, B, E — Wrap each individual example in <example> tags, with the full set inside an outer <examples> tag, so Claude can clearly distinguish examples from surrounding instructions; Ensure the examples are diverse and cover edge cases so Claude does not pick up an unintended, overly narrow pattern from a repetitive set; Include three to five well-crafted examples that closely mirror the actual use case rather than a single loosely related one
- A. Correct. Structuring examples in <example> tags (with an outer <examples> tag for multiple examples) helps Claude distinguish examples from instructions.
- B. Correct. Examples should be diverse and cover edge cases so Claude does not pick up unintended patterns from a repetitive or narrow set.
- C. Incorrect. Guidance recommends including three to five examples, not reducing to a single example, for the most reliable results.
- D. Incorrect. Making every example nearly identical works against diversity and risks Claude latching onto incidental structure rather than the intended task pattern.
- E. Correct. Including three to five relevant, well-crafted examples that mirror the actual use case is the recommended range for best results.
- F. Incorrect. Randomizing labels away from the real categories would teach Claude the wrong mapping and is not part of the documented guidance on effective examples.
Sources1
3.Separate instructions, context and inputs with XML tags
Examples aren't the only content that can blur into your instructions. Retrieved documents and variable inputs can too. According to the guide, XML tags help Claude parse complex prompts unambiguously, particularly when a prompt mixes instructions, context, examples and variable inputs. Putting each type of content in its own tag, such as <instructions>, <context> or <input>, reduces misinterpretation.
The guide lists two best practices. Use consistent, descriptive tag names across your prompts, and nest tags when the content has a natural hierarchy: documents go inside <documents>, and each one sits in its own <document index="n">. When every source has its own indexed tag, Claude can still tell the sources apart. If they are pasted in as one undifferentiated block, it can't.
Sources1
4.Put the role in the system prompt and the request in the user turn
Where an instruction goes matters as much as how it is worded. The guide says that setting a role in the system prompt focuses Claude's behaviour and tone for your use case, and that even a single sentence makes a difference. In the Messages API, the system parameter says who Claude is for this application, and the messages array carries the specific request:
client = anthropic.Anthropic()
message = client.messages.create(
model="claude-opus-5-5",
max_tokens=1024,
system="You are a helpful coding assistant specializing in Python.",
messages=[
{"role": "user", "content": "How do I sort a list of dictionaries by key?"}
],
)
print(message.content)The system prompt is also where standing guidance on tone belongs. On Claude Sonnet 5, setting temperature, top_p or top_k to a non-default value returns a 400 error. The Sonnet 5 guide says to remove those parameters and use system-prompt instructions to guide tone and variety instead.
5.Constrain the output with an explicit format
The final part of a clear prompt is the shape of the answer. The consistency guide says to define your output format precisely, using JSON, XML or a custom template, so that Claude follows every formatting element you require. A JSON instruction can name the keys and their allowed values. The guide's customer-feedback example asks for "sentiment" (positive/negative/neutral), "key_issues" (list) and "action_items" (list of dicts with "team" and "task"). A template goes further and can fix the structure and length of each field. This market-intelligence prompt puts the input in <data> tags and then shows the exact shape to follow:
<competitor>
<name>Rival Inc</name>
<overview>A 50-word summary.</overview>
<swot>
<strengths>- Bullet points</strengths>
<weaknesses>- Bullet points</weaknesses>
<opportunities>- Bullet points</opportunities>
<threats>- Bullet points</threats>
</swot>
<strategy>A 30-word strategic response.</strategy>
</competitor>The template uses several techniques from this page at once. It is an example that also serves as a format specification, it uses XML to keep the data separate from the instruction, and it sets explicit length limits ("A 50-word summary", "A 30-word strategic response").
Exam traps
Each one states something that sounds right. Open it to see what is actually true.
1.If Claude ignores a rule, restating it in capitals ("NEVER ...") is the best way to enforce it.Why is that wrong?
The guidance improves the rule by adding its reason. Once Claude understands the goal behind an instruction, it follows it more precisely and can generalize from the explanation.
2.Few-shot examples work best when they are near-identical, so Claude sees one consistent pattern.Why is that wrong?
Examples should vary and include edge cases. Uniform examples can teach patterns you never intended.
Covered in Steer format and tone with a few well-chosen examples
3.Concatenating several source documents as plain text is fine because Claude will keep them apart on its own.Why is that wrong?
When a prompt mixes content types, give each its own tag and nest documents in indexed tags. This reduces misinterpretation.
Covered in Separate instructions, context and inputs with XML tags
Sources
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practicesOfficial docs
“Golden rule: Show your prompt to a colleague with minimal context on the task and ask them to follow it.”
↩︎ Write the prompt a new colleague could follow“Provide instructions as sequential steps using numbered lists or bullet points when the order or completeness of steps matters.”
↩︎ Write the prompt a new colleague could follow“Claude is smart enough to generalize from the explanation.”
↩︎ Write the prompt a new colleague could follow“Examples are one of the most reliable ways to steer Claude's output format, tone, and structure.”
↩︎ Steer format and tone with a few well-chosen examples“Wrap examples in <example> tags (multiple examples in <examples> tags) so Claude can distinguish them from instructions.”
↩︎ Steer format and tone with a few well-chosen examples“XML tags help Claude parse complex prompts unambiguously, especially when your prompt mixes instructions, context, examples, and variable inputs.”
↩︎ Separate instructions, context and inputs with XML tags“Nest tags when content has a natural hierarchy”
↩︎ Separate instructions, context and inputs with XML tags“Setting a role in the system prompt focuses Claude's behavior and tone for your use case. Even a single sentence makes a difference”
↩︎ Put the role in the system prompt and the request in the user turn“Be specific about the desired output format and constraints.”
↩︎ Constrain the output with an explicit format“Think of Claude as a brilliant but new employee who lacks context on your norms and workflows.”
↩︎ Key concept“Providing context or motivation behind your instructions, such as explaining to Claude why such behavior is important, can help Claude better understand your goals”
↩︎ Exam trap 1“Diverse: Cover edge cases and vary enough that Claude doesn't pick up unintended patterns.”
↩︎ Exam trap 2“Wrapping each type of content in its own tag (for example, <instructions>, <context>, <input>) reduces misinterpretation.”
↩︎ Exam trap 3 - 2.https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/prompting-claude-sonnet-5Official docs
“use system-prompt instructions to guide tone and variety instead.”
↩︎ Put the role in the system prompt and the request in the user turn - 3.https://platform.claude.com/docs/en/test-and-evaluate/strengthen-guardrails/increase-consistencyOfficial docs
“Precisely define your desired output format using JSON, XML, or custom templates so that Claude follows every output formatting element you require.”
↩︎ Constrain the output with an explicit format