Skip to main content

Giving Claude Good Examples: Few-Shot Prompting

How showing two or three examples helps Claude match your format and style, plus what makes a good example set.

🌐 This article was machine-translated and may contain inaccuracies. Read the Korean original if in doubt.

If you show Claude two or three examples of the result you want, it matches your format and style far more accurately than a long description would. Providing examples like this is called few-shot prompting. This guide explains why it works, how to build good examples, and which tasks few-shot fits best.

🟢 Model references match the current lineup · model notice · Fable subscription
🟢 Model references match the current lineup · Claude Opus 5.5 / Claude Sonnet 5 / Claude Haiku 4.5 (higher tier: Claude Fable 5.1). This notice changes only when Anthropic ships a new model.

Fable 5 and 5.1 subscription (updated September 7, 2026): Claude Fable 5.1, released September 1, 2026, is the current Fable model and Fable 5 is now legacy. Plan terms are the same for both — Max and Team Premium plans include Fable at up to 50% of the weekly usage limit; Pro and Team Standard use usage credits (

🟢 Model references match the current lineup · Claude Opus 5.5 / Claude Sonnet 5 / Claude Haiku 4.5 (higher tier: Claude Fable 5.1). This notice changes only when Anthropic ships a new model.
0/M input, $50/M output tokens). The one-time
🟢 Model references match the current lineup · Claude Opus 5.5 / Claude Sonnet 5 / Claude Haiku 4.5 (higher tier: Claude Fable 5.1). This notice changes only when Anthropic ships a new model.
00 credit applied only to the Fable 5 transition and is not offered for 5.1. Some coding and debugging requests may be answered by an Opus model due to a security classifier (both models). See the Fable 5.1 guide and the Fable 5 availability guide for details.

⚡ TL;DR
  • Two or three examples (few-shot) match format and style accurately.
  • Examples are more precise than long explanations.
  • Follow the four conditions of a good example.
  • Especially effective for format-matching tasks.
Examples make the output consistent Zero-shot — no examples output varies Few-shot — 2-3 examples output is consistent

What is few-shot

Giving only instructions with no examples is zero-shot; giving a single example is one-shot; showing two or more examples of the input and the desired output is few-shot. Instead of describing "classify it like this" in words, you show two or three actually-classified examples.

Why it works

Examples convey format, tone, and classification criteria that are hard to put into words. Claude picks up the pattern in the examples and continues in the same way, so a few short examples are often more accurate than a long explanation.

Four traits of good examples

  • Consistent format — every example follows the same structure and order.
  • A sensible count — usually 2 to 5 works well. Too few and the pattern is unclear; too many and the input gets long (adjust per task).
  • Variety — include a range of different cases.
  • Edge cases — one or two tricky examples make the criteria clear.

Where few-shot shines

Few-shot is powerful when the "shape of the right answer" is clear. For the task types below, show two or three examples instead of explaining.

Where few-shot shines Classification sentiment / category labels Extraction pull items from text Transformation change format / tone Style matching output in a fixed shape

Example: matching a format

To classify sentences as "Sentiment: positive/negative/neutral", show examples first:

Input: Shipping was fast, loved it -> Sentiment: positive
Input: It arrived with torn packaging -> Sentiment: negative
Input: It is just average -> Sentiment: neutral
Input: (sentence to classify)

Just two or three examples lead Claude to answer in the same format.

Caveats

If the examples lean one way, the answers follow that bias; for instance, only-positive examples can make Claude reluctant to judge something negative. And if the example format is inconsistent, the output wavers too, so making the examples themselves accurate and consistent matters most.

Few-shot is especially effective for format-heavy tasks (classification, extraction, transformation). It pairs well with specifying the output format and role prompting. For more, see the prompt engineering guide and the official Anthropic documentation.

Frequently asked questions

What is few-shot?

Showing two or three examples of the result you want, so Claude follows that format and style.

How many examples are ideal?

Usually two or three. Too few won't establish a pattern; too many get long — keep to key examples.

When is it most effective?

For tasks that need consistent output format/style (classification, filling templates, unifying tone).

Was this helpful?

Keep reading