Skip to main content

Claude Prompt to Generate Few-Shot Examples for Any Task

Generate optimal few-shot examples that teach an AI model your exact desired output format, tone, and reasoning pattern.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt
Generate 5 few-shot examples for teaching an AI to classify customer support tickets by priority and department. Requirements: 1) Examples must cover the full spectrum of difficulty (easy, medium, hard), 2) Include at least one edge case example, 3) Show the exact input → output format expected, 4) Each example should demonstrate a different aspect of the task, 5) Add brief reasoning annotations (why this output is correct), 6) Ensure examples are SaaS product support-specific and realistic, 7) Include one negative example (what NOT to output and why), 8) Format examples in XML tags (<example><input>...</input><output>...</output></example>) structure for easy copy-paste into prompts, 9) Verify examples are consistent with each other (no contradictions), 10) Estimate the token cost of including these examples and suggest trimming if over 2000 tokens. Target model: Claude Sonnet.

What this prompt does

This prompt generates a curated set of few-shot examples that teach a model your exact desired output — format, tone, and reasoning pattern — for a task you describe. Instead of writing paragraphs of instructions, you give the model [example_count] worked input-to-output pairs that demonstrate the behavior directly. The prompt deliberately spreads examples across difficulty levels, includes an edge case, annotates why each output is correct, and adds a negative example showing what not to produce and why.

The variables tune the example set to your use case. [task_description] defines what the model is being taught to do, and [domain] keeps the examples realistic and on-topic. [format] controls the structure — XML tags, for instance — so the examples paste cleanly into your prompts. [max_tokens] caps the token budget so the example block does not bloat every request, and [target_model] ensures the formatting suits how that model best ingests few-shot context. The prompt also checks examples for internal consistency.

When to use it

  • A classification or extraction step gives inconsistent output and instructions alone are not fixing it.
  • You want to teach a precise output format that is easier to show than to describe.
  • Format drift is appearing in production and you need a negative example to lock the shape down.
  • You are covering a range of difficulty and need easy, medium, hard, and edge-case examples in one set.
  • Building a reusable prompt where the few-shot block must fit within a [max_tokens] budget.
  • Standardizing examples across a [domain] so outputs stay consistent and realistic.

Example output

Expect [example_count] examples in your chosen [format], each showing the exact input and expected output, spanning easy to hard with at least one edge case and one negative example. Each carries a short annotation explaining why the output is correct, the set is checked for contradictions, and you get a token-cost estimate with trimming suggestions if it exceeds [max_tokens]. It is ready to drop straight into a system or task prompt.

Pro tips

  • Write [task_description] precisely; vague tasks produce vague examples, and the model can only demonstrate what you clearly define.
  • Keep [domain] realistic — examples that mirror your actual inputs transfer far better than sanitized toy cases.
  • Do not skip the negative example; showing what not to output is often what stops format drift in production better than any positive case.
  • Watch the [max_tokens] budget, since few-shot blocks ride along on every request and a bloated set quietly raises cost at scale.
  • Pick [format] to match your parser — structured tags like XML are easy to extract and resist accidental contamination from surrounding text.
  • Re-check the set for contradictions yourself; even two slightly inconsistent examples can teach the model the wrong pattern.

Frequently Asked Questions

How many few-shot examples should I actually include?
Often two to five well-chosen examples outperform a long list, since they cover the format and edge cases without bloating every request. The `[example_count]` and `[max_tokens]` settings let you balance coverage against the token cost that rides along on each call.
Why does it generate a negative example?
Because showing what not to output is frequently what prevents format drift in production. A negative example with a reason teaches the model the boundary of acceptable output, which positive examples alone sometimes fail to convey clearly.
Will these examples work across different models?
The examples transfer broadly, but formatting conventions differ — some models parse XML-delimited examples more reliably than others. Set `[target_model]` so the structure matches how that model best ingests few-shot context, and validate output before relying on it.
Does it account for the token cost of the examples?
Yes. It estimates the token cost of the example block and suggests trimming if it exceeds `[max_tokens]`. This matters because few-shot examples are sent with every request, so a large set can meaningfully raise per-call cost at volume.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

More in AI Prompt Engineering Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

AI assistant · trained on my work

👋

Hey there!

Quick Actions

WhatsApp Direct line to me

Chat on WhatsApp

+880 1723 741224 · Replies within the hour on working days

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

mejba.13@gmail.com

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support