CONCEPT Demonstrate the tricky inputs, don't just describe them
Diversity (3.2) isn't only about spreading examples across the common categories — its stated purpose is to cover edge cases. The hard, ambiguous, or malformed inputs are exactly where a zero-shot prompt drifts: how should Claude handle an empty field, a mixed signal, an out-of-scope request, a message in the wrong language? Instead of writing a paragraph of rules for each, show one example that demonstrates the desired handling. An example that resolves a tricky case is worth more than the prose trying to describe the same behavior.
This is the same "show, don't tell" leverage from 3.1, aimed at the parts of the input space that are hardest to specify. Common edge cases worth an example:
| Edge case | What the example demonstrates |
|---|---|
| Missing / empty field | Exactly what to output when data is absent (e.g. null, "N/A") |
| Ambiguous / mixed signal | Which label wins, or how to flag the ambiguity |
| Out-of-scope / refusal | The precise decline or "cannot classify" response |
| Malformed / noisy input | How to still produce a clean, valid output |
| Boundary values | Where the line between two categories actually falls |
DIAGRAM Examples cover the input space
empty · ambiguous · out-of-scope"] C --> EX1["🟢 Ordinary examples
lock the format"] E --> EX2["🟢 Edge-case examples
teach the exceptions"] EX1 --> SET["Combined example set"] EX2 --> SET SET --> GEN["Claude generalizes to
unseen inputs too"] classDef ok fill:#d4edda,stroke:#28a745,color:#155724; classDef gate fill:#ffe8cc,stroke:#ff9f40,color:#9a4a0a; class EX1 ok; class EX2 ok; class E gate;
CODE Ordinary + edge-case examples together
An extraction task where the edge cases — a missing price and an out-of-scope message — are
demonstrated, not described. Claude learns to emit null for absent data and a fixed
marker for irrelevant input, then applies both to the real request.
system = """Extract product and price from each message as JSON: {"product": ..., "price": ...}. Handle the edge cases exactly as shown in the examples.""" user = """<examples> <example> <msg>Grabbed the Aero headphones for $199.</msg> <json>{"product": "Aero headphones", "price": 199}</json> </example> <example> <!-- edge: price missing --> <msg>The Aero headphones look great but I forgot the price.</msg> <json>{"product": "Aero headphones", "price": null}</json> </example> <example> <!-- edge: out of scope --> <msg>What time do you close on Sundays?</msg> <json>{"product": null, "price": null}</json> </example> </examples> <msg>Thinking about the Nova speaker, no idea what it costs.</msg>""" message = client.messages.create( model="claude-opus-4-8", max_tokens=16000, system=system, messages=[{"role": "user", "content": user}], ) # → {"product": "Nova speaker", "price": null} — the demonstrated edge-case rule applied.
TRADE-OFFS Demonstrate vs. describe the exceptions
✅ Edge-case examples
- Encode the rule and its output shape at once
- Unambiguous — no room to misread a prose rule
- Handle empty/ambiguous/out-of-scope consistently
⚠️ Prose rules only
- Each rule is open to interpretation
- Output shape for the exception still unspecified
- Rules pile up and start to conflict
- But: needed for cases you can't enumerate
EXAM TRAPS
PRACTICE
Q1 · Why demonstrate an edge case instead of describing it?
A demonstrating example encodes both the rule and the exact output shape for the exception in one unambiguous artifact, whereas a prose rule can be misread and leaves the output format unspecified. Examples steer the hard cases more reliably than descriptions.
Q2 · How do edge-case examples relate to the diversity guidance from 3.2?
Diversity's stated purpose is partly to cover edge cases. Adding examples for empty, ambiguous, or out-of-scope inputs is exactly how you make the set diverse in a way that improves real-world robustness, not just cosmetic variety.
Q3 · Do edge-case examples let you drop the general instruction?
No. You can't demonstrate every possible input, so keep a clear instruction for the general rule. The examples steer the specific hard cases; the instruction lets Claude generalize to edge cases you didn't show.