Examples teach the shape of an answer far more reliably than describing it does. The trouble is assembling them: hand-built example blocks are where a stray delimiter inside somebody's content quietly closes the section it was supposed to be inside. This escapes the content, offers the four formats worth using — tagged, Markdown, a JSON array, or prior chat turns — and checks the set for the two mistakes that make examples actively harmful. If every output is identical, they teach a constant rather than a rule. If they disagree about their own shape, they teach nothing at all.
Features
Four formats: XML tags, Markdown, a JSON array, or chat turns
Content escaped so a stray angle bracket cannot close a tag early
Element names sanitised into valid tags
Warns when every example has the same output
Warns when the outputs disagree about their format
Notes when there is only one example, or too many
Custom labels for the input and output halves
Optional numbering
How to use the Few-Shot Example Builder
Add each input with the output you want for it
Pick the format that suits where the examples are going
Read the warnings about the set as a whole
Copy the block into your prompt
Example
Input
The export button does nothing on Safari.
Output
{"category": "bug", "severity": "medium"}
Consistent output shape across examples is what teaches the format.
Common errors & troubleshooting
My examples contain angle brackets and break the prompt. — They are escaped here, which is the point. Hand-assembled example blocks are where this goes wrong.
It warns that my outputs are all the same. — Identical outputs teach a constant answer. Vary them across the cases you actually want distinguished.
It warns that the outputs are different shapes. — One example returning JSON and another returning prose gives contradictory instructions about the format. Pick one.
How many examples should I use? — Two or three usually pin the behaviour down. Beyond about a dozen you are paying real tokens on every request, so the later ones need to be earning it.
Frequently asked questions
Which format works best?
Tagged examples are the safest default because the boundaries survive content containing Markdown or braces. Chat turns are often stronger still, since prior turns are a shape the model already understands — but they cost more to assemble.
Why escape the example content?
Because an example containing a closing tag would end the section it is inside, and everything after it would be read as instructions rather than as content. It is the same class of problem as SQL injection, in a prompt.
Do examples work better than a description?
For format, almost always. A worked example fixes the shape of an answer in a way a paragraph describing the shape does not. For judgement calls, a description of the rule tends to generalise better.
Is there a cost to having many examples?
Yes — they are sent on every request. That is fine for a handful and worth reviewing beyond a dozen, which is why the count is flagged rather than left to accumulate.
Should the examples be real cases?
Real ones are better, because invented examples tend to be tidier than reality and teach the tidy case. Just check them for anything you would not want in a prompt that is sent repeatedly.