CONCEPT A few, chosen for relevance and diversity
Anthropic's guidance is specific: include 3–5 examples for best results, and scale up for more complex tasks. The count is not the important part on its own — which examples you pick is. Two properties decide whether examples help or mislead:
- Relevant — each example should mirror your actual use case closely. Examples drawn from a different domain, format, or difficulty than your real inputs teach Claude the wrong pattern.
- Diverse — examples should vary enough that Claude doesn't pick up unintended patterns, and should cover edge cases. If all three examples happen to share an incidental trait (all short, all positive, all one category), Claude may latch onto that accident instead of the real rule.
| Situation | How many | Why |
|---|---|---|
| Simple, well-defined task | 3 | Enough to lock format + show a little range |
| Typical task | 3–5 | Anthropic's recommended sweet spot |
| Complex task, many categories/edge cases | More (scale up) | Each category/edge case needs representation |
| Very few examples, all similar | ⚠️ risky | Over-fits to their surface form (see 3.5) |
DIAGRAM Picking a set that covers the range
to the real inputs?"} R -->|"no — off-domain / wrong format"| FIX1["🟠 Replace with
use-case-mirroring examples"] R -->|"yes"| D{"Set diverse enough?
edge cases + categories covered?"} D -->|"no — all similar"| FIX2["🟠 Add variety
ask Claude to generate more"] D -->|"yes, 3–5 (more if complex)"| GOOD["🟢 Ship the set"] FIX1 --> D FIX2 --> GOOD classDef ok fill:#d4edda,stroke:#28a745,color:#155724; classDef gate fill:#ffe8cc,stroke:#ff9f40,color:#9a4a0a; class GOOD ok; class FIX1 gate; class FIX2 gate;
CODE A relevant + diverse set, and asking Claude to extend it
Four examples that mirror the task (short product reviews → sentiment) while spanning categories and a tricky mixed case — that's diversity doing real work, not four near-duplicates.
# Relevant (all short product reviews) AND diverse (pos / neg / neutral / mixed) system = "Label each review's sentiment: positive, negative, neutral, or mixed." examples = """<examples> <example><review>Battery lasts all day, love it.</review><label>positive</label></example> <example><review>Screen cracked on day two.</review><label>negative</label></example> <example><review>It's a phone. Does phone things.</review><label>neutral</label></example> <example><review>Camera is stunning but it overheats badly.</review><label>mixed</label></example> </examples>""" # Let Claude broaden coverage before you finalize audit = client.messages.create( model="claude-opus-4-8", max_tokens=16000, system=system, messages=[{"role": "user", "content": f"{examples}\n\nAre these examples relevant and diverse? " "Suggest 2 more that cover edge cases my set is missing."}], )
TRADE-OFFS Too few vs. too many
✅ 3–5 relevant, diverse
- Locks format and shows the range
- Covers the common categories + a couple of edge cases
- Modest, predictable token cost
⚠️ Too few / all similar / too many
- Too few + narrow → over-fits their surface form (3.5)
- Off-domain examples → teaches the wrong pattern
- Many near-duplicates → pure token cost, no coverage gain
EXAM TRAPS
PRACTICE
Q1 · How many examples does Anthropic recommend, and when do you add more?
3–5 for best results, scaling up for more complex tasks (more categories, more edge cases). The count follows task complexity — add examples to fill genuine gaps in coverage.
Q2 · Why isn't relevance alone sufficient?
If every relevant example shares an incidental trait (all short, all one category), Claude can pick up that unintended pattern and over-fit. Diversity — varying the examples and covering edge cases — prevents that while keeping them relevant.
Q3 · How can Claude itself help you choose examples?
You can ask Claude to evaluate your examples for relevance and diversity, and to generate additional examples based on your initial set — a quick way to broaden coverage and catch missing edge cases before finalizing the prompt.