Lv.1 0 XP

Format Examples — Controlling Output Structure with Few-Shot

Core 6 min +25 XP
💡
THE ANALOGY

A style guide with annotated examples. Telling writers 'write in AP style' produces variability. Showing them three exemplary articles with annotations produces consistent house style. Few-shot format examples do the same for Claude's output.

⚠️ EXAM TRAP — The Wrong Answer People Choose

Using few-shot only for content guidance and ignoring its power for format control. For complex nested JSON, showing examples is often more reliable than describing the schema.

KEY POINTS
1 Format examples show exact output structure — more reliable than format descriptions for complex structures.
2 All examples must use identical format — variation in examples creates variation in output.
3 Include null/missing cases explicitly — prevents Claude from inventing values.
4 Combine few-shot format examples with schema validation for production reliability.
5 Input/output pair examples teach both content judgment AND format simultaneously.