Prompt EngineeringFundamentals

Examples & few-shot

When showing beats telling — and when a few examples quietly hurt.

Sometimes the fastest way to specify an output is to show one. A couple of well-chosen examples ("few-shot") can pin down a format or a judgment call that's awkward to describe in prose. But examples are not free, and used carelessly they hurt.

When examples help

  • Format is easier shown than said — the exact shape of a commit message, a review comment, a structured record.
  • The task is a judgment call — showing two borderline cases (one that passes, one that doesn't) calibrates the threshold better than an adjective.

When they hurt

  • They over-anchor — if every example follows one pattern, the agent will force the next case into that pattern even when it doesn't fit. Vary your examples deliberately.
  • They leak into the answer — an agent may echo the specifics of an example (its variable names, its exact wording) instead of applying the pattern. Keep examples structurally clear and content-generic.
  • They bloat the context — examples are tokens too. One sharp example usually beats three redundant ones (context is finite).

Rule of thumb

Reach for a constraint first; reach for an example when the constraint would be longer than the example. And if you find yourself maintaining a growing set of examples for a recurring task, that's the signal it should become an Agent Skill.