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. Refer to 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 and how to build good examples.

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; showing 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.

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). For more, see the official Anthropic documentation.

Keep reading

Have a question or want to share how you use Claude?

Join the community to share tips with other users, or explore more guides.