Bible Network Crypto DeFi Onchain RWA AI Agent Stablecoin Chain SAFU CryptoTax DeFAI AGI Claude Me Claude Skill Claude Design Claude Cowork
Independent Media
Not affiliated with any project
Learn Claude Skills. Do Everything Better.
claudeskill-me.com
LATEST
Who Can Invoke a Skill: The Three States of disable-model-invocation and user-invocable in SKILL.md, and Why a Misspelled Field Raises No Error  ·  Claude Code Plan Mode for Beginners: How to Enter, the Three Options After a Plan, and the Bypass Exception  ·  Teaching Claude to Classify With Examples: A Few-Shot Ticket Prompt, the Official 3–5 Example Guidance and Bad Example Sets  ·  Claude Code Sandbox Will Not Start on Ubuntu 24.04: Checking and Fixing the AppArmor Block on bubblewrap User Namespaces  ·  Which Claude Code Effort Setting Wins: Precedence of CLAUDE_CODE_EFFORT_LEVEL, --effort, modelSettings, effortLevel and maxEffortLevel  ·  Claude Code v2.1.310 and v2.1.311: Compaction Retries a Missing Summary, ultrathink Runs at xhigh, DISABLE_COMPACT Becomes a One-Way Switch
prompt-examples

Teaching Claude to Classify With Examples: A Few-Shot Ticket Prompt, the Official 3–5 Example Guidance and Bad Example Sets

30-Second Version · For the impatient
The docs say few-shot examples should be relevant, diverse and wrapped in tags, 3 to 5 of them; give five of the same label and the pattern Claude learns is that the answer is always that label.

Full Explanation +
01 · Why did this happen?

How many examples should I include?

The docs say "Include 3–5 examples for best results". You can also ask Claude to evaluate your examples for relevance and diversity, or to generate more from your initial set.

02 · What is the mechanism?

What tags should wrap the examples?

The docs recommend <example> around each example and <examples> around several, so Claude can tell examples from instructions. The names of the inner fields are not prescribed; keep them consistent with your real input and output.

03 · How does it affect me?

Will a newer model copy the wording of my examples?

The official section I read does not answer this. There is no official conclusion, so use your own validation set to see whether outputs hug the examples' wording too closely.

04 · What should I do?

I'm not an engineer. One-line version?

Instead of lecturing a new hire with a long list of rules, show them three to five finished examples done right, including a tricky one or two.

Full Content +

When you ask Claude to classify or to rewrite into a fixed format, the fastest improvement is often not a longer instruction but a few examples. Anthropic calls this few-shot or multishot prompting. This article uses a support-ticket classification prompt to show how to choose examples, how to wrap them in tags, and how to check for yourself whether they help. I read the official guidance on Anthropic's platform docs Prompt Engineering page; the example prompt is my own and has no output attached, because I did not run it.

What the official docs say

  • "A few well-crafted examples (known as few-shot or multishot prompting) improve accuracy and consistency." The docs also say examples are "one of the most reliable ways" to steer Claude's Output Format, tone and structure.
  • Count: "Include 3–5 examples for best results." You can also ask Claude to evaluate your examples for relevance and diversity, or to generate more from your initial set.
  • Good examples are Relevant (mirror your actual use case closely), Diverse (cover edge cases and vary enough that Claude does not pick up unintended patterns) and Structured (wrapped in <example> tags, with multiple examples inside <examples>, so Claude can tell them from instructions).
  • Together with thinking: "Multishot examples work with thinking." Worked examples shape how Claude approaches similar problems in its own thinking blocks, and the docs suggest presenting each example as a problem, the method to apply and the expected answer.

A complete example prompt

Below is a ticket-classification prompt I wrote (the tag structure follows the official advice; {{new ticket text}} marks where you substitute real content):

Classify each support ticket into one category: refunds, account, shipping, or other.
Reply with the category name only.

<examples> <example> <ticket>My order arrived with a cracked screen. I want my money back.</ticket> <category>refunds</category> </example> <example> <ticket>How do I change the email on my login?</ticket> <category>account</category> </example> <example> <ticket>Tracking says delivered, but nothing is at my door.</ticket> <category>shipping</category> </example> <example> <ticket>Your app is great, thanks for the update!</ticket> <category>other</category> </example> <example> <ticket>I was charged twice and the parcel is also late.</ticket> <category>refunds</category> </example> </examples>

<ticket>{{new ticket text}}</ticket>

Note the fifth example: it deliberately includes a mixed ticket that looks like both refunds and shipping, labeled with the answer you want. That is the Edge Case "Diverse" asks for; if your rule is "any billing problem goes to refunds", this example teaches Claude the rule without a long paragraph of explanation. The fourth example covers "none of the above", so Claude does not force every message into the first three categories.

Common bad example sets

  • All the same class: five examples all labeled refunds, and the pattern Claude is most likely to learn is "the answer is always refunds". That is one form of the docs' "unintended patterns".
  • Length or format with a pattern: every refunds example is long and every other example is short, and Claude may guess the category from length. Spread the lengths across classes.
  • Unlike real data: the examples are clean sentences you made up, while real tickets are full of typos and mixed languages, which breaks "Relevant". Pick from real data and strip personal information.

Check for yourself whether it helps (my steps, which I have not run)

  1. Sample 20 to 30 real tickets, label them yourself, and keep them as a validation set outside the examples.
  2. With the same model and settings, run three versions: zero examples, three examples, five examples.
  3. Compare how many outputs match your labels for each version, and look especially at the edge cases you expect to fail.
  4. If more examples do not improve things, check whether the examples are diverse instead of adding more; the docs also suggest asking Claude to evaluate your examples for relevance and diversity.

What the official page does not answer

The section I read does not discuss the risk of examples being copied too literally, and gives no trade-off beyond the 3–5 count; another part of the page says newer models follow instructions more literally but does not connect that to examples. So whether a newer model will copy your examples' wording verbatim has no official answer, and only your validation set can tell you.

My judgment

This is my view, not an official conclusion: if your prompt already has a long passage saying "classify like this, not like that", try turning the rules in it into two or three examples with answers, especially edge cases. Examples are harder to misread than rule descriptions and easier for you to check; but they lengthen every call's input, so count that cost if you reuse the prompt heavily, and consider Prompt Caching.

Sources: Prompting best practices: use examples effectively - Claude Platform Docs
Diagram
客服工單分類的 few-shot prompt 結構指令加 3 到 5 個用 examples 標籤包起來的範例(含邊界案例)再接新工單;官方的好範例條件、壞範例組與自我驗證步驟Few-shot prompt for ticket classificationInstructionClassify into refunds, account,shipping, otherReply with the category onlyShort rules, no long essay<examples> (3-5 recommended)refundscracked screen, wants money backaccountchange login emailshippingdelivered but nothing arrivedotherthanks for the updaterefundsedge case: charged twice AND lateNew ticket<ticket>...</ticket>Claude answers withone category nameFormat learned from examplesOfficial: good examples areRelevant: mirror the real use caseDiverse: cover edge casesStructured: wrapped in tagsInclude 3-5 examplesBad example setsAll the same labelLength tracks the labelClean made-up text, real data messyClaude picks up unintended patternsCheck it yourselfHold out 20-30 labeled ticketsRun 0, 3 and 5 examplesCount matches with your labels(my steps, not run)Claude Skill Me · claudeskill-me.com
Feel free to share. Please credit the source.
Ask a Question
Please enter at least 10 characters
Related Articles
How to Actually Use XML Tags in Prompts: 3 Before/After Examples vs. Plain Text
prompt-examples · Aug 31
How to Write Your First Custom Slash Command in Claude Code: A Working Example From Scratch
prompt-examples · Sep 05
Writing Your First System Prompt: From "You Are an Assistant" to a Role Setup That Actually Works
prompt-examples · Aug 14
Who Can Invoke a Skill: The Three States of disable-model-invocation and user-invocable in SKILL.md, and Why a Misspelled Field Raises No Error
skill-library · Nov 05
More Related Topics