What you will be able to do
- Decide when a prompt needs zero, one or a few examples, and add them in that order
- Write example sets that teach Claude the intended pattern instead of surface features
- Prompt chain-of-thought in its basic, guided and structured forms
- Choose between extended thinking and manual chain of thought for a given task
- Lay out a prompt that combines long documents, instructions and a query
Key concept
Showing versus telling — Instructions tell Claude what you want. Examples show the output pattern, and chain-of-thought shows the reasoning path. You add each one only when telling alone has stopped producing consistent, correct results.
1.Zero-shot, one-shot and few-shot prompting
A zero-shot prompt is made of instructions alone, and for many tasks that is all you need. Claude follows clear, explicit direction well. A zero-shot prompt succeeds when it states the output format and constraints, and when it explains the reason behind each rule. A rule like "never use ellipses" works better with its reason attached: the text will be read aloud by a text-to-speech engine that cannot pronounce them. Given the reason, Claude can also handle cases the rule never mentioned, because it is able to generalise from the explanation.
Some requirements are easier to show than to describe, and that is when examples start to pay off. Typical cases are a summary style, a tone of voice, or a labelling convention with fine distinctions. Another is a set of instructions that keeps producing outputs that differ slightly from run to run. Putting example inputs with their outputs in the prompt is called one-shot prompting when there is one example and few-shot (or multishot) prompting when there are several. A few well-crafted examples improve both accuracy and consistency.
| Approach | What the prompt contains | Use it when |
|---|---|---|
| Zero-shot | Explicit instructions, format, constraints and the reasons for them | The output can be fully described in words |
| One-shot | Instructions plus one example of the desired output | The format, tone or style is easier to show than describe |
| Few-shot | Instructions plus several varied examples | One example still leaves outputs inconsistent, or the task has subtle patterns and edge cases |
Escalate one step at a time. Start with one example, and add more only if the output still doesn't match. Each example adds length, and as the next section explains, every detail in an example becomes something Claude may copy. Examples also extend beyond text. In one vision walkthrough, Claude misread a speedometer in km/h until example images were added to the prompt. Few-shot prompting with images doesn't always work, though, so test it on your own case.
Few-shot examples are the standard fix when outputs drift in format or label spelling across similar inputs, such as a triage prompt that returns "High" on one ticket and "high priority" on the next. Asking Claude to explain its reasoning in prose does not fix this, because the problem is the output's shape, not its reasoning. Adding one untagged example after the instructions is the weakest version of the fix. A single example shows no variety, and without tags Claude cannot reliably tell the demonstration apart from the instructions. Several varied ticket-and-output pairs, each wrapped in example tags, teach the exact labels and layout you expect.
Checkpoint 1 of 8· Check yourself
A zero-shot triage prompt gives the correct priority, but the label varies between tickets: "High" on one and "high priority" on the next. What is the most effective fix?
The priority is right, so the problem is the shape of the output, not the reasoning. Examples are the fix for that. Several varied examples show the exact labels and layout, and tags let Claude tell the demonstrations apart from the instructions. Explaining in prose doesn't change the output's shape, and a single untagged example is the weakest version of the fix.
“Examples are one of the most reliable ways to steer Claude's output format, tone, and structure.”Source: platform.claude.com
Checkpoint 2 of 8· Exam question
A team's support-ticket triage prompt asks Claude to output a category label and priority score, but real outputs vary in formatting and label spelling across similar tickets. The team has not yet included any example outputs in the prompt. Which change is most likely to make outputs consistent?
Correct answer: B — Wrap three to five diverse ticket-and-output pairs in <example> tags so Claude can pattern-match on the intended format and labels
- A. Incorrect. Raising temperature increases output variability rather than reducing it, and does nothing to establish a consistent output format or label vocabulary.
- B. Correct. Multishot (few-shot) prompting with several diverse, clearly demarcated examples is the documented technique for steering output format, tone, and structure toward consistency.
- C. Incorrect. A single example provides too little pattern diversity to reliably anchor formatting across varied ticket types, and best-practice guidance recommends three to five examples.
- D. Incorrect. Adding an unrelated summarization and self-explanation step does not address the underlying lack of demonstrated output format and may introduce further inconsistency.
2.Crafting examples Claude learns the right lesson from
Claude learns everything an example shows, including what you did not mean to teach. Modern Claude models pay very close attention to details in examples. A shared length, sentence structure or sentiment across your examples will be read as part of the pattern. Example sets should meet three requirements:
- Relevant: they mirror your real use case closely, with the same kind of input and the same output shape.
- Diverse: they cover edge cases and vary enough that Claude does not pick up unintended patterns.
- Structured: each one is wrapped in example tags, and the set in examples tags, so Claude can tell demonstrations apart from instructions.
A homogeneous example set fails in a specific way. It works on inputs that look like the examples and breaks on everything else. Adding more examples of the same kind makes the unwanted pattern stronger, so the count is not the fix. The fix is coverage: include each label, the hard boundary cases, and varied lengths and phrasings. Varied examples are most useful for nuanced or ambiguous cases, where the line between categories is hard to state in a written description alone.
Comment: This movie was great, I really enjoyed it. The main actor really killed it!
Classification: ALLOW
Comment: Delete this post now or you better hide. I am coming after you and your family.
Classification: BLOCK
Comment: Stay away from the 5G cellphones!! They are using 5G to control you.
Classification: BLOCK
Comment: Thanks for the helpful information!
Classification: ALLOWTags matter as much as content. If an example sits loose among the instructions, Claude may treat its specific values as requirements, or treat an instruction as sample data. Wrapping each example in its own tag removes that ambiguity. Using the same tag names in every prompt keeps the structure predictable. Examples are also the easiest place to tune behaviour: changing the examples in a moderation prompt changes what it allows and blocks, with no other edits.
Checkpoint 3 of 8· Check yourself
Your team's moderation prompt has four varied, relevant comment-and-label pairs, but they are pasted in among the rules with no tags around them. What risk does this layout create?
Structure is one of the three requirements, alongside relevance and diversity. Without tags, Claude cannot reliably tell which text is a demonstration and which is an instruction. Wrapping each example in its own example tag, and the whole set in examples tags, removes that ambiguity.
“Structured: Wrap examples in <example> tags (multiple examples in <examples> tags) so Claude can distinguish them from instructions.”Source: platform.claude.com
Checkpoint 4 of 8· Exam question
While reviewing a few-shot prompt for a sentiment classifier, an engineer notices that all five included examples are short, positive-sentiment product reviews written in the same sentence structure. Model outputs on negative or mixed reviews are now unreliable. What is the most likely cause and fix?
Correct answer: A — The examples are not diverse enough and Claude has picked up unintended patterns from the repeated structure; add negative, mixed, and structurally varied examples
- A. Correct. Examples must be diverse and cover edge cases so Claude does not pick up unintended patterns; a set that is uniform in sentiment and structure fails to represent the full task and biases outputs toward that pattern.
- B. Incorrect. Missing <thinking> tags is unrelated to a diversity problem; sentiment classification of this kind does not require an intermediate reasoning trace to fix a biased example set.
- C. Incorrect. Simply adding more examples without addressing their lack of diversity would likely reinforce the same unintended pattern rather than correct it.
- D. Incorrect. Example placement relative to instructions affects clarity but does not resolve a root diversity problem in the content of the examples themselves.
3.Chain-of-thought prompting in three forms
Chain-of-thought (CoT) prompting asks Claude to reason step by step before giving its answer. It helps because a model answering in a single pass has no room for scratch work, checking or changing course. When Claude reasons first, it restates the problem, tries approaches and checks intermediate results. This matters most for tasks whose answer depends on intermediate work that would otherwise be squeezed into the response or skipped: multi-step analysis, maths, and decisions that weigh several factors.
| Form | What you add to the prompt | What it gives you |
|---|---|---|
| Basic | A phrase such as "Think step-by-step" | Reasoning before the answer, but Claude chooses what to reason about |
| Guided | Named reasoning stages in order: first consider X, then Y, then write the output | Ensures that the specific factors you care about are considered |
| Structured | Guided stages, plus tags that separate reasoning (<thinking>) from the answer (<email>) | Reasoning your code can strip out, and an answer it can extract cleanly |
Draft personalized emails to donors asking for contributions to this year's Care for Kids program.
Program information:
<program>
{{PROGRAM_DETAILS}}
</program>
Donor information:
<donor>
{{DONOR_DETAILS}}
</donor>
Think step-by-step before you write the email.Each form gives you more control than the one before. The basic form lets Claude decide what is worth thinking about. The guided form names the stages, for example the donor's giving history first, then the parts of the programme that fit them, then the email. Use it when the reasoning has to cover specific ground. The structured form adds output tags, which production pipelines usually need. A moderation filter can ask for its reasoning in thinking tags and its verdict in output tags, then parse only the verdict. In a vision example, the same thinking-then-answer layout fixed a dog count Claude had first got wrong.
In a pipeline, code has to separate the reasoning from the answer. Tags give it a reliable boundary, so it can log or discard the thinking section and pass only the answer section on.
Checkpoint 5 of 8· Match them up
Match each form of chain-of-thought prompting to what you add and what it gives you
Tap a term, then the definition that fits it.
The forms build on each other. Basic asks for reasoning without saying what to reason about. Guided names the stages, so specific factors get covered. Structured adds tags that separate the reasoning from the answer, which is what a pipeline needs to parse the output.
“Use tags to separate reasoning from the final answer.”Source: claude.com
4.Extended thinking versus manual chain of thought
Extended thinking is built-in chain-of-thought. When it is active, Claude reasons in thinking content blocks that arrive before its text response. On models that support it, extended thinking is generally preferable to writing CoT instructions by hand. How you turn it on depends on the model. On Claude Opus 4.6 to 4.8 and Claude Sonnet 4.6, thinking stays off until you set adaptive thinking, which lets Claude decide when and how deeply to think. Claude Sonnet 5 has it on by default.
response = client.messages.create(
model="claude-opus-5-5",
max_tokens=16000,
thinking={"type": "adaptive", "display": "summarized"},
messages=[
{
"role": "user",
"content": "What is the greatest common divisor of 1071 and 462?",
}
],
)Manual CoT is still the right choice in two cases. The first is when extended thinking isn't available, such as on the free Claude.ai plan. The second is when you need reasoning you can review. A thinking block never contains the raw chain of thought. With display set to summarized it holds a summary of Claude's reasoning. With omitted, the default on many models, its thinking field comes back empty. Reasoning written in thinking tags as part of the response is exactly what Claude wrote, so an auditor can read it in full. The two approaches can also be combined: even with extended thinking on, explicit CoT instructions can still help on complex tasks.
Thinking has costs, so it should not be on for every request. Thinking tokens are billed as output tokens even when the text is not returned, and they count toward max_tokens. They also add latency. You can steer thinking turn by turn. Adding "Please think hard before responding." to a user message encourages it, and "Answer directly without deliberating." discourages it. An agent harness can add the first phrase on planning steps and the second on routine confirmations. Steering phrases change model behaviour, so measure how often thinking triggers, token use, latency and answer quality before you ship them.
Checkpoint 6 of 8· Fill the gap
You want this adaptive-thinking request to return Claude's thinking text in its thinking blocks, not an empty thinking field. Which display value goes in the blank?
response = client.messages.create(
model="claude-opus-5-5",
max_tokens=16000,
thinking={"type": "adaptive", "display": " ? "},
messages=[
{
"role": "user",
"content": "What is the greatest common divisor of 1071 and 462?",
}
],
)"summarized" returns the thinking text, while "omitted", the default on many models, returns an empty thinking field. No setting returns the raw chain of thought, because even the summarized text is only a summary. If an auditor needs the full reasoning, use manual CoT in thinking tags.
Source: platform.claude.com5.Placing long documents, examples and the query
Prompts that combine large documents with instructions and examples need a deliberate layout. Inputs of 20k+ tokens are where layout matters most; managing the limits themselves is covered under context window budgeting. Three practices apply:
- Put the long documents near the top, above the query, instructions and examples. This improves performance on all models, so moving the question to the very top is the wrong direction.
- Wrap each document in document tags with source and document_content subtags, and nest them all inside a documents tag. Keep this structure rather than pasting raw text, because the tags let Claude tell the documents apart.
- Ask Claude to quote the relevant passages, in their own tag, before it does the task. This keeps it focused on the content that matters and ignoring the rest.
Quoting first is the long-document version of chain-of-thought: the extracted quotes become the intermediate work the answer builds on. If answers keep missing details buried mid-document, quote grounding plus a documents-first layout is the fix. Cutting the input down to a single document is not, because the multi-document tag structure exists precisely so Claude can work across several sources in one prompt.
Checkpoint 7 of 8· Check yourself
An analyst's prompt combines about 60k tokens of supplier contracts with instructions, two tagged examples and the question "Which contracts allow termination without notice?" Answers keep missing clauses buried in the middle of the contracts. Which change follows the recommended layout?
Long documents belong near the top, above the query, instructions and examples, and asking Claude to quote the relevant passages first keeps it focused on the details that matter. Putting the question first is the wrong direction. Cutting the input to one document throws away the multi-document structure, which exists so Claude can work across several sources in one prompt.
“Place your long documents and inputs near the top of your prompt, above your query, instructions, and examples. This improves performance across all models.”Source: platform.claude.com
Checkpoint 8 of 8· Exam question
An engineer is building a Claude prompt that analyzes several long internal documents and answers a question about them. Responses sometimes ignore details buried in the middle of the documents. Which of the following changes are consistent with documented long-context prompting guidance? (Select all that apply.)(Select 3)
Correct answers: A, B, D — Place the long documents near the top of the prompt, above the query and instructions; Wrap each document in <document> tags with source and content subtags to structure the input clearly; Ask Claude to quote the relevant passages inside <quotes> tags before producing the final analysis
- A. Correct. Long-form documents should be placed near the top of the prompt, above the query and instructions, which improves performance across models.
- B. Correct. Wrapping each document in structured tags such as <document>, <source>, and <document_content> helps Claude parse multi-document input unambiguously.
- C. Incorrect. Placing the query at the very top, before the documents, contradicts documented guidance; queries placed at the end can improve response quality, especially with complex multi-document inputs.
- D. Correct. Asking Claude to quote relevant passages before analysis grounds the response and helps it cut through noise in long documents.
- E. Incorrect. Long-context guidance explicitly addresses multi-document analysis via structured tags rather than requiring the input to be reduced to a single document.
- F. Incorrect. Removing XML structure works against the documented recommendation to use tags for clarity when handling multiple documents and metadata.
Sources1
Sources
(6)
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
“Be specific about the desired output format and constraints.”
↩︎ Zero-shot, one-shot and few-shot prompting“Claude is smart enough to generalize from the explanation.”
↩︎ Zero-shot, one-shot and few-shot prompting“A few well-crafted examples (known as few-shot or multishot prompting) improve accuracy and consistency.”
↩︎ Zero-shot, one-shot and few-shot prompting“Relevant: Mirror your actual use case closely.”
↩︎ Crafting examples Claude learns the right lesson from“Wrap examples in <example> tags (multiple examples in <examples> tags) so Claude can distinguish them from instructions.”
↩︎ Crafting examples Claude learns the right lesson from“Use consistent, descriptive tag names across your prompts.”
↩︎ Crafting examples Claude learns the right lesson from“Place your long documents and inputs near the top of your prompt, above your query, instructions, and examples.”
↩︎ Placing long documents, examples and the query“wrap each document in <document> tags with <document_content> and <source> (and other metadata) subtags for clarity”
↩︎ Placing long documents, examples and the query“ask Claude to quote relevant parts of the documents first before carrying out its task”
↩︎ Placing long documents, examples and the query“This helps Claude focus on the relevant content and ignore the rest of the document.”
↩︎ Placing long documents, examples and the query“Examples are one of the most reliable ways to steer Claude's output format, tone, and structure.”
↩︎ Key concept“Diverse: Cover edge cases and vary enough that Claude doesn't pick up unintended patterns.”
↩︎ Exam trap 1“Place your long documents and inputs near the top of your prompt, above your query, instructions, and examples.”
↩︎ Exam trap 3“A few well-crafted examples (known as few-shot or multishot prompting) improve accuracy and consistency.”
↩︎ Exam trap 4“Examples are one of the most reliable ways to steer Claude's output format, tone, and structure.”
↩︎ Checkpoint“Diverse: Cover edge cases and vary enough that Claude doesn't pick up unintended patterns.”
↩︎ Prediction“Structured: Wrap examples in <example> tags (multiple examples in <examples> tags) so Claude can distinguish them from instructions.”
↩︎ Checkpoint“Place your long documents and inputs near the top of your prompt, above your query, instructions, and examples. This improves performance across all models.”
↩︎ Checkpoint - 2.https://claude.com/blog/best-practices-for-prompt-engineeringSecondary source
“Start with one example (one-shot). Only add more examples (few-shot) if the output still doesn't match your needs.”
↩︎ Zero-shot, one-shot and few-shot prompting“Examples aren't always necessary, but they shine when explaining concepts or demonstrating specific formats.”
↩︎ Zero-shot, one-shot and few-shot prompting“Claude 4.x and similar advanced models pay very close attention to details in examples.”
↩︎ Crafting examples Claude learns the right lesson from“Use tags to separate reasoning from the final answer.”
↩︎ Chain-of-thought prompting in three forms“Structure your prompt to provide specific reasoning stages.”
↩︎ Chain-of-thought prompting in three forms“When available, extended thinking is generally preferable to manual chain of thought prompting.”
↩︎ Extended thinking versus manual chain of thought“Extended thinking isn't available (i.e. the free Claude.ai plan)”
↩︎ Extended thinking versus manual chain of thought“The two approaches are complementary, not mutually exclusive.”
↩︎ Extended thinking versus manual chain of thought - 3.
“Note though that few-shot prompting with images doesn't always work but it is worth trying on your use case.”
↩︎ Zero-shot, one-shot and few-shot prompting - 4.
“especially helpful for nuanced or ambiguous cases where the category boundaries may not be entirely clear”
↩︎ Crafting examples Claude learns the right lesson from“explicitly instruct Claude to break down its process into clear steps inside <thinking> tags”
↩︎ Chain-of-thought prompting in three forms - 5.
“Claude works through the problem in its own words before answering”
↩︎ Chain-of-thought prompting in three forms“where the quality of the answer depends on intermediate work that would otherwise be compressed into the response itself or skipped”
↩︎ Chain-of-thought prompting in three forms“what you see is never the raw chain of thought: the text in a thinking block is a summary of Claude's reasoning”
↩︎ Extended thinking versus manual chain of thought“the tokens Claude spends reasoning are billed as output tokens, even when the thinking text isn't returned to you”
↩︎ Extended thinking versus manual chain of thought“which lets Claude determine when and how deeply to think based on the request”
↩︎ Extended thinking versus manual chain of thought“what you see is never the raw chain of thought: the text in a thinking block is a summary of Claude's reasoning”
↩︎ Exam trap 2 - 6.
“Per-message steering is useful when only some requests in a conversation warrant extended reasoning.”
↩︎ Extended thinking versus manual chain of thought“Prompt-based steering changes model behavior, so treat it like any other prompt change: measure before you ship.”
↩︎ Extended thinking versus manual chain of thought