Domain 4 · Prompt Engineering & Structured Output

Few-shot prompting

When a task is ambiguous, don't add more adjectives — add examples. Showing Claude 2–5 input→output pairs (few-shot) pins down the exact format, edge-case handling, and tone far more reliably than describing them. Add examples one at a time and watch the model's output snap into shape.

zero / one / few-shotedge cases format lockingconsistency
Explain like I'm 10
Telling someone "sort these toys nicely" is confusing — nice how? But if you show them: "see, red ones here, blue ones there, broken ones in the bin" — now they get it instantly and can do the rest themselves. Examples teach faster than instructions. Claude is the same: show, don't just tell.

Add examples — watch reliability climb

The task: classify a customer message into billing / technical / cancellation, and flag urgency. Start with zero examples and add them. Notice how the tricky "mixed" message gets handled correctly only once an example shows how:


    
Model output on the test input "App keeps crashing AND you double-charged me, fix it now!!":

How many, and which?

Exam trap: for an ambiguous or inconsistent task, the right fix is few-shot examples, not "write a longer description" or "raise the temperature." And the examples must be consistent and cover the edge cases — a sloppy or all-easy example set is a distractor that looks helpful but doesn't fix the failure.
Takeaways: ambiguity → add examples, not adjectives. 2–5 consistent input→output pairs lock the format and teach edge-case handling better than prose. Choose examples that cover the hard cases, keep the format identical across them, and wrap them in <example> tags.

Curated companion: Anthropic — Multishot (few-shot) prompting.