Iterative Refinement with Examples
2-4 input/output examples and test-driven iteration.
Why Examples Beat Adjectives
When a prompt under-performs, architects reach for vague fixes like "be more precise" or "try harder". These rarely move the needle. The reliable lever is explicit criteria plus concrete examples.
Compare: "be more precise" versus "flag a comment only when it contradicts the code". The second tells the model exactly where the decision boundary sits. In this lesson you'll learn to drive a prompt to production quality using 2-4 targeted input/output examples and a tight test-and-iterate loop.
How Few-Shot Actually Works
Few-shot prompting attaches a small set of worked examples to your instructions. The key insight: the model generalizes from the examples — it does not merely copy them. Given 3 representative cases, it infers the underlying rule and applies it to unseen inputs.
Few-shot is strongest for four jobs:
- Consistency across many calls
- Edge cases that words alone describe poorly
- Output format the model should mirror
- Reducing hallucination by anchoring behavior
Aim for 2-4 examples per ambiguity — enough to define the pattern, few enough to keep context lean.
All lessons in this course
- Custom Commands vs Skills
- Skill Frontmatter
- Plan Mode vs Direct Execution
- Iterative Refinement with Examples