Instructions vs Examples in Prompts: When to Use Each

JS
Jai Singh
16 Nov, 2026 4 min read 14 views

Use instructions when the behaviour can be stated clearly as a rule, and use examples when the behaviour is easier to show than to describe, such as a tone, a format or a subtle judgement. Often the best prompt uses both: a short instruction that states the rule and one to three examples that show it in action. Examples are strong signals, so choose them carefully.

What instructions do well

Instructions are compact and explicit. They are the right tool for:

  • Hard limits ("never include personal email addresses").
  • Process steps ("search first, then answer").
  • Scope ("only discuss billing topics").
  • Output constraints ("return valid JSON with these keys").

An instruction costs few tokens and is easy to edit. If it works, you do not need anything else.

What examples do well

Examples show things that are hard to put into words: the voice of your brand, the level of detail in a summary, how to label a borderline case. Models are good at picking up patterns from demonstrations. The risk is that they pick up too much. If every example starts with "Great question!", the model will probably start that way too, even if you never asked for it.

A direct comparison

Here is a task: classify support tickets as bug, billing or question. We try an instruction-only version and an instruction-plus-examples version.

import anthropic

client = anthropic.Anthropic()
MODEL = "claude-sonnet-5-5"

INSTRUCTION_ONLY = (
    "Classify the support ticket as one of: bug, billing, question. "
    "Reply with the label only."
)

WITH_EXAMPLES = INSTRUCTION_ONLY + """

Examples:
Ticket: "The export button does nothing when I click it."
Label: bug

Ticket: "Why was I charged twice this month?"
Label: billing

Ticket: "Does the Pro plan include API access?"
Label: question"""

tickets = [
    "I was charged after cancelling, and also the invoice PDF is blank.",
    "How do I add a teammate?",
]

def classify(system, ticket):
    r = client.messages.create(
        model=MODEL, max_tokens=2000, system=system,
        messages=[{"role": "user", "content": ticket}],
    )
    return "".join(b.text for b in r.content if b.type == "text").strip()

for t in tickets:
    print(t)
    print("  instruction only:", classify(INSTRUCTION_ONLY, t))
    print("  with examples:   ", classify(WITH_EXAMPLES, t))

For clear tickets both versions agree. The first ticket is mixed (billing plus a bug), so the outputs may differ, and that difference tells you something: your instruction does not say how to resolve mixed cases. The fix is to add that rule ("if a ticket mentions money, choose billing") or an example of a mixed ticket with the label you want.

How to choose

SituationPrefer
Hard rule or boundaryInstruction
Tone, style, voiceExamples
Exact output formatInstruction plus one example
Edge cases with a specific answerInstruction for the rule, example for the edge
Behaviour that changes oftenInstruction (easier to edit)

Combining the two

The strongest prompts state a rule and then show it. For example: "Write release notes in the past tense, one line per change, starting with a verb." followed by two real lines such as "Fixed a crash when exporting empty projects." and "Added keyboard shortcuts for the timeline." The rule gives the model the principle, and the examples give it the texture. If the two ever disagree, the model must guess which to follow, so check that your examples obey your rules. A rule that says "under 15 words" next to an example of 22 words will produce unpredictable lengths.

Another useful pattern is to give a negative example only when a failure is common and hard to describe. Label it clearly as a bad answer and explain why it is bad. Use this sparingly, because models can still be drawn toward whatever is shown.

Costs to keep in mind

  • Examples use tokens on every call, and in an agent they are re-sent each turn. Cache them (post 43) or keep them few.
  • Examples can over-constrain. The model may copy surface features such as length and opening words.
  • Examples can go stale when the product changes. Instructions go stale too, but they are easier to spot in review.

A practical workflow

  1. Start with an instruction only and read ten outputs.
  2. If failures are about a rule, sharpen the rule.
  3. If failures are about style or judgement, add one example that shows the right behaviour.
  4. Re-run the same ten inputs plus a few new ones. Check that the examples did not cause copying.

The next post explains how to write examples that guide without being copied.

Was this article helpful?

Comments

No comments yet. Have a question or a tip? Be the first to share it.

Leave a comment

Comments are reviewed before they appear.