Recipes
Sam Q.3 min read1 views

Few-Shot Prompting Recipes That Ship (2026)

Five copy-paste few-shot prompting recipes for July 2026: lock output format, tone, labels, and edge cases. Each with the prompt and the exact case where it breaks.

A neat stack of example cards, each mapping an input line to an output line, one arrow highlighted in amber
A neat stack of example cards, each mapping an input line to an output line, one arrow highlighted in amber
On this page

Quick answer

Few-shot prompting means putting two to five worked examples inside your prompt so the model copies the pattern instead of guessing at it. As of July 2026 it is still the fastest way to lock output format, tone, and edge-case handling without fine-tuning. Below are five recipes you can paste today, each with the prompt, why it works, and the exact case where it breaks.

Zero theory. The examples are the instruction.

These recipes are model-agnostic. They behave the same on OpenAI logo OpenAI's GPT models and Anthropic logo Anthropic's Claude. The name traces back to the GPT-3 paper, Brown et al. (2020), which framed few-shot as showing a model examples at inference time instead of retraining it.

Recipe 1: Lock the output format

Two examples beat a paragraph of formatting rules.

Rewrite each bug report as one line: [SEVERITY] area: summary.

Input: The login page throws a 500 when the password has an emoji.
Output: [HIGH] auth: 500 on login when password contains emoji.

Input: Footer copyright still says 2024.
Output: [LOW] ui: footer shows stale copyright year.

Input: Checkout hangs on Safari after a coupon is applied.
Output:

Why it works: the model pattern-matches the bracket tag, the area slug, and the terse phrasing from the two shown lines. No rule list required.

Fails when: your examples disagree. Mixed casing or two different tag sets across examples, and the model picks one at random. Keep the shots consistent.

Recipe 2: Match a voice

Tone is easier to show than to describe. Stop writing "be friendly but concise."

Rewrite the support reply in our house voice.

Draft: Your refund has been processed and will appear in 5-7 business days.
House: Done. Your refund is on its way and should land within a week.

Draft: We are unable to reproduce the issue you reported.
House: We tried to reproduce this and could not yet. Can you send a screen recording?

Draft: Your account has been suspended for violating our terms.
House:

Why it works: two rewrites teach cadence, contractions, and length better than any adjective. The model infers the register.

Fails when: your two examples are too short to carry the voice. Give it a hard case, not two easy ones.

Recipe 3: Classify with a fixed label set

Free-text classification drifts. Pin the labels with examples.

Label each message as one of: billing, bug, feature_request, other.

Message: The export button does nothing on Firefox.
Label: bug

Message: Can you add SSO for our team?
Label: feature_request

Message: Why was I charged twice this month?
Label: billing

Message: Love the new dashboard, keep it up.
Label:

Why it works: the label set appears once in the instruction and three times in the shots, so the model treats it as closed. It stops inventing new labels.

Fails when: a real message spans two labels. Add a rule for ties, or a fifth example showing the tie broken your way.

Recipe 4: Teach the edge case

Most prompts show the happy path. The value is in the ugly one.

Extract the meeting date. If no date is present, return null. Do not guess.

Text: Let us sync next Tuesday at 3pm.
Date: null

Text: Confirmed for March 4, 2026.
Date: 2026-03-04

Text: Sometime after the holidays works.
Date: null

Text: Pushing our April 9 call to the 11th.
Date:

Why it works: the two null examples do the heavy lifting. They teach the model that vague is not a date, which a rule alone rarely enforces.

Fails when: you only show positive examples. Without a null shot, the model hallucinates a date for "after the holidays" every time.

Recipe 5: Extract to a shape

When you need JSON, show the JSON. This pairs with strict schema work, covered in our structured output recipes.

Extract to JSON: {name, company, ask}. Use null for missing fields.

Email: Hi, Priya from Northwind here. We want a volume quote for 500 seats.
JSON: {"name": "Priya", "company": "Northwind", "ask": "volume quote for 500 seats"}

Email: Following up on the demo. Loved it.
JSON: {"name": null, "company": null, "ask": "follow up after demo"}

Email: This is Dev at Acme, can we get an invoice reissued to a new address?
JSON:

Why it works: one filled example and one sparse example fix both the key order and the null convention. The model stops inventing keys.

Fails when: the shape is deep or recursive. Few-shot handles flat objects well; for nested trees, pair it with a real JSON schema and tool use so the runtime validates the output.

The rule behind all five

Show, do not tell. Two to three consistent examples, at least one of them the hard case, beat a wall of instructions almost every time. Both vendors document the same technique under slightly different names: see Anthropic's multishot guidance and OpenAI's prompting guide. The mechanics are identical; only the message roles differ.

Add more shots only until the output stabilizes. Past four or five, you are paying tokens for nothing.

Cost to test: under $0.01 per recipe. Each is a sub-500-token call, a fraction of a cent on a budget 2026 model.

Sam Q.

Written by

Sam Q.

Sam Q. ships prompt recipes at PromptAttic. Terse by default. Tests everything before writing it down.

FAQ

What is few-shot prompting?

Few-shot prompting is a technique where you include a small number of worked examples, usually two to five, directly in the prompt so the model imitates the demonstrated pattern. It steers the output at inference time without any fine-tuning.

What is the difference between zero-shot and few-shot prompting?

Zero-shot gives the model only an instruction and no examples. Few-shot adds two to five input-output examples. Few-shot is more reliable for fixed formats, tone, and edge cases, while zero-shot is cheaper and fine for simple, unambiguous tasks.

How many examples should a few-shot prompt use?

Start with two or three consistent examples and add more only until the output stabilizes. Most flat tasks are solved by three to five shots; beyond that you usually pay extra tokens for no gain.

Does few-shot prompting work on both Claude and GPT models?

Yes. The technique is model-agnostic. Anthropic documents it as multishot prompting and OpenAI covers it in its prompting guide. Only the message roles differ; the mechanics are the same.

When does few-shot prompting fail?

It breaks when your examples contradict each other, when you only show the happy path and never the hard or null case, or when the target output is deeply nested. For nested structures, combine few-shot with a JSON schema and tool use.

Is few-shot prompting the same as fine-tuning?

No. Fine-tuning changes the model weights with a training run. Few-shot prompting changes nothing about the model; it only adds examples to the context at request time, so it is instant, has no training cost, and is easy to iterate.