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
Reviewing Superpowers: A TDD Framework That Literally Deletes Code Written Before Tests Exist  ·  CLAUDE.md, Rules, Skills, Hooks, Subagents — Which One? Anthropic's Official Seven-Method Decision Framework  ·  Reviewing Anthropic's Frontend Design Skill: Why Is It Installed 57× More Than the Runner-Up?  ·  Building Your First Skill: Turn Something You've Explained Three Times Into One Command  ·  Writing Your First System Prompt: From "You Are an Assistant" to a Role Setup That Actually Works  ·  Claude Code Adds Owner-Wildcard Marketplace Controls, Letting One Rule Allow or Block an Entire GitHub Org
Glossary · Prompt Engineering

Few-Shot Prompting

Prompt Engineering beginner

30-Second Version · For the impatient
Instead of describing in words what output you want, giving a few concrete input-output example pairs directly, letting Claude infer the style and format you're after from the examples themselves — often conveying detail more precisely than a written description can.
Full Explanation +
01 · What is this?

What is Few-Shot Prompting, and how does it differ from purely describing the output you want in words?

Few-shot prompting means including a few concrete example pairs in a prompt — input content matched with the expected output — letting Claude infer the style, format, and level of detail you want directly from those examples, rather than relying on an abstract written description to convey it. For instance, if you want Claude's help writing commit messages, instead of writing "describe the change in a concise, professional tone," you could directly give two or three real cases of "here's what kind of code change this is" paired with "here's the commit message that should result."

The key difference from a purely written description is precision of communication. Written description is prone to gray areas — words like "concise" and "professional" don't mean exactly the same thing to everyone. An example instead lays out the precise picture in your head directly for Claude to see, skipping the lossy translation step of trying to describe a style in words.

02 · Why does it exist?

Why is Few-Shot Prompting needed, and what problem does it solve?

Describing output requirements purely in words runs into a specific limitation: language itself has limited ability to express things like style, tone, and fine-grained formatting rules. You can write "use a friendly but professional tone," but what "friendly but professional" actually looks like when it hits the page can vary quite a bit from person to person in their mental image — this gap isn't because the instruction wasn't written carefully enough; words themselves inherently have limits in conveying this kind of subtle nuance.

Few-shot prompting solves exactly this "limited expressive power of language" problem: rather than continuing to stack up adjectives trying to approximate the style you want, giving an example directly is a more direct form of communication — much like teaching a new colleague how to write a report. Instead of verbally describing "something roughly like this," showing them two or three past reports that were done well lets them grasp what that "feel" actually is on their own. The information density an example conveys is often higher than a written description of the same length.

03 · How does it affect your decisions?

How does Few-Shot Prompting actually work, and how many examples should you give, and how do you pick effective ones?

The underlying mechanism: Claude infers a common pattern (format structure, tone, judgment logic) from the examples provided, then applies that pattern to new input. There's no absolute rule on the number of examples — in practice, two or three usually produces a noticeable effect. What matters isn't the count but whether the examples themselves cover the key variation you care about. For instance, if the content you want Claude to produce spans two common scenarios (say, a feature-addition commit versus a bug-fix commit), it's better to include at least one example of each rather than only examples from one scenario — otherwise, Claude may not have enough reference to draw an analogy when it encounters the other scenario.

When selecting examples, quality matters more than quantity — rather than stuffing in five ordinary examples, curating two or three that clearly demonstrate the difference between "good" and "not quite good enough" works better. If the task has clear output formatting rules (a fixed field order, for instance), pairing examples with an explicit format template lets Claude grasp both the rule itself and what the rule looks like actually applied — combining both is usually more stable than giving only one or the other.

04 · What should you do?

What does Few-Shot Prompting actually mean for me — when should I use examples, and when is a written description enough?

The test to come back to: "can this output requirement be fully stated in clear words?" If what you want is a clear-cut logical rule (a yes/no judgment like "check whether there's an owner field"), a written description is usually precise enough on its own, and no extra example is needed. But if what you want is something like a "style," "tone," or fine-grained formatting nuance that's hard to fully capture in a few sentences, an example usually gets Claude to the point faster than stacking up adjectives.

A useful habit in practice: when you notice you've written several sentences' worth of adjectives trying to describe a requirement and still feel "this still isn't precise enough," that's the signal to consider switching to an example. Also, few-shot prompting doesn't mean inventing an example from scratch every time — if you already have a real, good piece of past work on hand (a report you wrote well before, a good commit message you wrote earlier), using that actual piece as the example is usually closer to the standard you genuinely want than making up a hypothetical one yourself.

Real-World Example +

Anthropic's official Skill authoring best practices documentation demonstrates writing a commit-message-generating skill: it directly provides three concrete pairs of "input code change description" matched with "output commit message format," and adds one line at the end of the examples — "follow this style: type(scope): brief description, then detailed explanation" — letting Claude grasp both the examples themselves and the written statement of the rule.

Common Misconceptions +
✕ Misconception 1
× Misconception: The more examples given, the better Claude grasps the style you want, when actually: an example's quality and how well it covers different variations matters more than quantity — two or three well-chosen examples covering different scenarios usually work better than five that all look similar
✕ Misconception 2
× Misconception: Once you have examples, a written description of the rule becomes redundant and can be skipped, when actually: examples demonstrate what the rule looks like actually applied, while the written description states what the rule is — combining both is usually more stable than giving only one, especially for tasks with clear formatting requirements
The Missing Link +
Direct Impact

The advantage is bypassing the inherent limitations of written description when it comes to conveying style, tone, and fine-grained formatting rules, using concrete cases to more precisely communicate the standard you want — especially effective for subtle nuances that are hard to describe exhaustively in words; the drawback is that it takes time to prepare examples of good enough quality that cover different scenarios, and if the examples themselves are poorly chosen or only cover a single scenario, Claude may actually learn an overly narrow pattern, performing inconsistently when it encounters a scenario the examples didn't cover.

Ask a Question
Please enter at least 10 characters
More Related Topics