Positive and Negative Examples in Claude

Positive and Negative Examples in Claude

A practical guide to teaching Claude by showing it: how to use examples of what you want and examples of what you do not want, how to write and label them, and how to avoid the traps that make examples backfire.

You have probably had this experience. You describe the writing style you want in careful detail, and the result still feels off. Then you paste one sample of the style you like, and the next reply is suddenly right. Examples are often the fastest way to close the gap between what is in your head and what appears on the screen.

This guide is about using that power well with Claude, the AI assistant made by Anthropic. You will learn what positive and negative examples are, why they work, and how Claude uses them. You will see how to write examples that teach the right lesson, how to label them so nothing gets confused, how to explain the reasons behind them, and how to pair good and bad examples so the contrast does the teaching. You will also meet the common pitfalls, such as copying and over-fitting, and see how teams use example banks in real products, keep private data safe, and measure whether their examples are working. Every idea comes with an everyday comparison, so no technical background is needed.

1What Are Positive and Negative Examples?

Two simple ideas that change how well Claude understands you.

Positive examples: “do it like this”

A positive example is a sample of the output you want. It shows Claude the right length, tone, structure, and wording in a form it can copy the pattern of. If you want product descriptions that are short and playful, you paste one description that is short and playful. If you want customer replies that are calm and specific, you paste one reply that is calm and specific.

Negative examples: “not like this”

A negative example is a sample of what you do not want, usually shown together with a reason. It marks the edge of the target. Showing a reply that is cold and defensive, and saying “this is too defensive because it blames the customer”, tells Claude which habits to stay away from. Negative examples are most helpful when the mistake is subtle or common, and hard to describe in words alone.

Everyday analogy

Imagine training a new waiter. You could hand over a rulebook, but it works far better to say, “Watch how Maria greets a table: she smiles, uses the guest’s name, and mentions the specials. And here is what to avoid: standing with arms crossed, saying ‘What do you want?'” One good demonstration and one warning teach more than a page of rules. Positive and negative examples do the same for Claude.

2
kinds of examples: ones to copy, and ones to avoid
1 to 5
examples are often plenty, as a rule of thumb
1
reason should travel with every negative example

A few words you will meet

Term

Prompt

Everything you give Claude to read in a request: instructions, background, examples, and the material to work on.

Term

Few-shot prompting

Including a small number of examples in the prompt. The word “shot” simply means one example.

Term

Zero-shot

Asking with instructions only and no examples at all.

Term

Edge case

An unusual input that does not fit the normal pattern, and that often needs its own example.

i
Key idea

Instructions tell Claude what you want. Examples show Claude what you mean. The strongest prompts use both, and let each cover the other’s weak spots.

2Why Claude Learns from Examples

Understanding the mechanism explains both the power of examples and their dangers.

Claude continues patterns

Claude is built on a large language model, which is trained to produce text that fits well with the text before it. When your prompt contains examples, those examples become part of the text Claude is continuing. Claude notices what they have in common: the length, the order of ideas, the vocabulary, the formatting. Then it writes a new answer that fits the same pattern. This ability to pick up a pattern from examples placed directly in the prompt is often called in-context learning.

flowchart TD
    A["Your instructions"] --> D["One prompt in the context window"]
    B["Positive examples: do it like this"] --> D
    C["Negative examples: not like this, and why"] --> D
    D --> E["Claude reads everything and notices the pattern"]
    E --> F["Claude writes a new answer that follows the pattern"]
    F --> G["You compare the answer with your examples"]
Figure 1: How examples travel inside a prompt and shape the reply

Read the diagram from top to bottom. Your instructions, your positive examples, and your negative examples are all combined into a single prompt. Claude reads the whole thing at once and works out the pattern. The new reply follows that pattern, and you check it against what you showed.

A short history of learning from examples

The idea of teaching a language model by placing examples in the prompt became widely known in 2020, when researchers at OpenAI described how their large model GPT-3 could perform new tasks after seeing only a few examples, without any extra training. The paper was even titled “Language Models are Few-Shot Learners”. Since then, every major family of language models, including Claude, has been used this way, and the technique has become one of the first tools that experienced prompt writers reach for.

Nothing is permanently changed

It is important to understand that examples in a prompt do not retrain Claude. The model’s internal numbers stay exactly the same. The examples work only because they sit in the conversation Claude is reading right now. This is why a new chat starts without them, and why you need to include them again, unless a feature such as saved project material or saved preferences keeps them for you, where such features are available.

Everyday analogy

Think of an apprentice who is shown a finished piece of work on the bench and asked to make another one like it. The apprentice studies the sample, spots how it was built, and copies the approach. When the sample is taken away, they do not suddenly become a different craftsman. The sample guided one job. Examples in a prompt guide one conversation.

Why showing often beats telling

Words are a lossy way to describe style. Try to describe “friendly but professional” and ten people will picture ten different emails. A single sample removes the ambiguity, because it carries the length, the rhythm, the level of formality, and a hundred small choices that you could never list. This is why even a short example can change a reply more than a long description.

The context window holds the examples

Everything Claude can see in a conversation sits in its context window, which has a size limit measured in tokens. Examples take up room there. A handful of short examples costs very little, but a dozen long ones can crowd out space for your real input. Include the fewest examples that do the job.

i
Practical tip

Anthropic’s own prompting guidance recommends being clear and detailed, and using positive and negative examples among its core techniques. You can read the overview at docs.claude.com for the current recommendations.

3Zero-Shot, One-Shot, and Few-Shot

How many examples should you give? It depends on how hard the target is to describe.

ApproachWhat you give ClaudeWorks well when
Zero-shotInstructions onlyThe task is common and easy to state, such as summarizing a paragraph
One-shotInstructions and one exampleYou want a particular style or layout and one sample shows it clearly
Few-shotInstructions and several examplesThe task has variations, categories, or subtle rules that one sample cannot show
Contrast pairOne positive and one negative example of the same taskThe difference between good and bad is subtle and easy to miss
Everyday analogy

Learning to cook a new dish works the same way. A written recipe alone is zero-shot: you must interpret every instruction. Watching a friend cook it once is one-shot, and you pick up the feel of the timing. Watching a few times with different ingredients is few-shot, and you start to understand which parts can change and which cannot.

Start with the simplest approach

A good habit is to begin with clear instructions and no examples. If the result is already good, you are done. If it misses in a way that is hard to explain, add one example. If it is still inconsistent, add a few more, and consider a negative example for the mistake that keeps recurring. Each added example costs tokens and effort, so add them only when they earn their place.

When examples help most

Helps

Matching a voice or style

Brand tone, a personal writing style, or a house format are far easier to show than to describe.

Helps

Consistent structure

When many outputs must look the same, examples fix the layout and the order of parts.

Helps

Classification and labeling

Examples define what each label means, including borderline cases.

Helps

Extracting information

Examples show which fields to pull out and how to write them.

When examples may not be needed

For simple factual questions or standard tasks, Claude usually does well with clear instructions alone. Adding examples to a task that did not need them can even narrow the answer too much, pulling the reply toward the example when you wanted variety. Use examples as a tool, not as a ritual.

!
Watch out

More examples are not always better. Past a certain point, extra examples add cost and can bias the reply toward their details. If results stop improving, stop adding.

4Positive Examples: Showing the Target

A good positive example is a small, accurate picture of the finished work.

What makes a positive example good

Quality

It is genuinely good

Claude will copy whatever it sees, flaws included. Only show work you would be happy to receive.

Quality

It matches the real task

The example should be the same kind of job as the one you are asking for, with a similar input and a similar output.

Quality

It uses the exact format you want

If you want three bullet points, show three bullet points. Claude copies layout very closely.

Quality

It is not too long

A concise example shows the pattern without drowning the prompt. Trim anything that is not part of the lesson.

Everyday analogy

A tailor often pins a fabric swatch to an order form. The swatch is small, it is exactly the real cloth, and it removes all argument about color and texture. A positive example is a swatch of the finished work: small, real, and decisive.

Show the input and the output together

When the task is transforming something, include both halves of the example: the input, and the output you wanted for it. For instance, if you want rough notes turned into polished updates, show one set of rough notes and the polished update that should come from it. This teaches Claude not just the style of the result but the relationship between the two.

Say what the example is

Introduce every example with a plain sentence such as “Here is an example of the kind of reply I want.” Without this, Claude may wonder whether the sample is part of the material to be processed. A one-line introduction removes the doubt.

Say which parts to copy

An example contains many features: topic, length, tone, structure, word choices. You usually want only some of them. Say so directly: “Match the length and the friendly tone, but write about the new topic below.” This one sentence prevents the most common problem with examples, which is copying details that were never meant to be copied.

A quick recipe for writing one

1

Find a real piece of work you like

Pick something from your own files that already did its job well, such as an email that got a quick answer.

2

Trim and clean it

Remove private details and anything that is not part of the lesson, so only the useful pattern remains.

3

Introduce it and name the features

Say what it is and which parts to match, such as length, tone, and order of ideas.

A positive example in practice

Suppose you want short product descriptions for an online shop. Your prompt might say: “Here is an example of the style I want: ‘Our canvas tote: sturdy enough for your groceries, pretty enough for your lunch date.’ Write descriptions in the same style, one sentence each, for a leather wallet and a ceramic mug. Match the playful tone and the length, but do not reuse the words from the example.” Claude now has a target that no adjective list could have supplied.

i
Remember

Your best examples are real work you already like: an email you were proud of, a summary a colleague praised, a report that got great feedback. Reuse them, after removing any private details.

5Negative Examples: Showing What to Avoid

Used with care, a negative example marks the fence around the target. Used carelessly, it can pull the reply toward the mistake.

When a negative example helps

Negative examples are most useful when a particular mistake keeps happening and is hard to explain in words. Typical cases include a tone that sounds slightly wrong, a habit of adding unwanted filler, an overly formal style, vague answers where precision is needed, or a format that keeps drifting. Showing the exact bad version makes the problem concrete.

Everyday analogy

A driving instructor does not only demonstrate a perfect turn. They also point out common mistakes: “See how he swung wide? That is why he nearly hit the curb.” The warning is memorable because it comes with a reason. A negative example works when it, too, comes with a reason.

Always attach a reason

A negative example without an explanation can be confusing. Claude may not know which feature of the bad sample you dislike: the length, the tone, the opening, the vocabulary. So always add a short “because” clause. For instance: “Avoid replies like this one, because it blames the customer and offers no solution.”

Better still: pair the bad with a good

The most effective negative example is shown next to a corrected version. The pair teaches both what to avoid and what to do instead, which closes the loop. “Instead of this… write this” is one of the most useful patterns in all of prompting.

SituationNegative exampleReason to attachPositive version
Reply to an upset customer“Our products are checked before shipping, so the damage probably happened at your end.”Defensive and blames the customer“I am sorry it arrived damaged. I have sent a replacement today.”
Meeting update“Dear Sir or Madam, I hereby wish to inform you that the meeting has been rescheduled.”Far too stiff for an internal team“Hi all, quick update: the meeting has moved to Thursday at 3.”
Code comment“Loop through the rows.”Repeats what the code already says“Skip empty rows, because the export adds a blank line at the end.”
SummaryStarts with three sentences of background before the pointBuries the key resultOpens with the result and its main number

The priming risk

There is a known side effect with negative examples. Showing a model a bad pattern places that pattern in front of it, and the model may sometimes echo it. It is a bit like saying “Whatever you do, do not think of a pink elephant”, which makes the elephant harder to ignore. The fixes are simple: label the bad example clearly as something to avoid, give the reason, show the improved version, and rephrase the rule positively too, for example “Acknowledge the problem and offer a next step.”

!
Watch out

A prompt full of bad examples and no good ones can lead Claude toward the very style you dislike. Lead with the positive. Add a negative example only for the specific mistake you need to prevent.

Keep negative examples few and focused

One or two well-chosen negative examples are usually enough. Each one should illustrate a single clear mistake. A long list of different bad samples blurs the lesson and fills the prompt with the very text you want to avoid.

6Contrast Pairs: Good and Bad Side by Side

Placing a positive and negative example of the same task next to each other lets the contrast do the teaching.

Why contrast works

A single good example shows what to do, but it does not show which of its features matter. A bad example of the same task, with the differences highlighted, reveals those features. When Claude sees a calm reply beside a defensive one, the difference between them becomes the lesson: acknowledgment, specificity, and a next step.

flowchart TD
    A["Task: reply to an upset customer"] --> B["Positive example: calm, specific, offers a fix"]
    A --> C["Negative example: defensive, vague, blames the customer"]
    B --> D["Claude sees what to copy"]
    C --> E["Claude sees what to avoid"]
    D --> F["Rule Claude infers: acknowledge, be specific, offer a next step"]
    E --> F
    F --> G["New reply in the right style"]
Figure 2: A contrast pair lets Claude infer the rule behind the examples

The diagram shows two branches for the same task. One branch is the positive example and the other is the negative one. Each teaches a different half of the lesson, and Claude combines them into a working rule, which it then applies to a fresh customer message.

Everyday analogy

Think of a spot-the-difference puzzle. Two nearly identical pictures sit side by side, and the differences jump out only because you can compare them. A contrast pair is a spot-the-difference puzzle for style, and Claude is very good at spotting what changed.

How to build a good contrast pair

  • Keep the task and the input the same. Both examples should respond to the same message, so the only difference is the quality of the response.
  • Change one thing at a time when you can. If the bad version differs in five ways, the lesson is muddy. A bad version that differs mainly in tone isolates the tone.
  • Label both clearly. Use names like “Good reply” and “Reply to avoid”, so they are never mixed up.
  • Say why. Add one sentence after the pair that names the difference that matters.

A complete contrast pair

Customer message

“My order arrived broken and I am really annoyed.”

Good reply

“I am sorry the order arrived broken. That is not the experience we want you to have. I have sent a replacement today, it should reach you in three to five days, and you do not need to return the damaged one.”

Reply to avoid

“Our products are checked before shipping, so the damage probably happened on your side. Please read our returns policy.”

Why they differ

The good reply acknowledges the problem, takes ownership, and gives a specific next step. The reply to avoid is defensive, blames the customer, and offers no solution. Write new replies in the style of the good one.

i
Practical tip

Whenever you correct Claude in a conversation, you are creating a contrast pair for free. Paste the reply you did not like, say why, and show what you wanted instead. Claude can often learn the rule from that single correction.

7Choosing and Writing Good Examples

The examples you pick matter as much as the instructions around them.

Cover the range, not just the middle

If all your examples look alike, Claude concludes that every answer should look like that. If your task has variations, such as short and long inputs, formal and casual messages, or typical and unusual cases, include examples that show them. This tells Claude which features are fixed and which should vary.

Everyday analogy

Imagine learning about music from a sampler. If every track is a slow ballad, you will think all music is slow. A good sampler includes a ballad, a dance track, and a classical piece, so you learn what the word “music” really covers. A good set of examples works like that sampler.

Include an edge case

Edge cases are the unusual inputs that cause the most trouble. A sentiment task that only shows clearly happy and clearly unhappy reviews will stumble on a flat, neutral one. Add one example for the awkward case: “It works.” with the label neutral. Handling edge cases is where examples earn their keep.

Keep examples consistent with each other

If one example uses bullet points and another uses paragraphs, Claude will not know which to follow. If one labels a borderline review positive and another labels a similar one negative, the labels become confusing. Before you send a prompt, read your examples side by side and check that they follow the same rules.

Watch for accidental patterns

Claude notices patterns you did not intend. If every positive example happens to start with “Great news!” or to mention a discount, Claude may start doing it too. If all your “negative” labels happen to sit on longer texts, the model may link length with the label. Vary the incidental details so only the intended lesson is consistent.

CheckQuestion to askIf it fails
QualityWould I be happy to receive this exact output?Replace it with better work
RelevanceIs it the same kind of task as my real one?Choose a closer example
VarietyDo the examples show the range of inputs I expect?Add an example for each kind
ConsistencyDo they follow the same format and rules?Edit them until they agree
Edge casesIs there one for the awkward, unusual input?Add an edge-case example
Incidental patternsDo they all share a quirk I do not want copied?Vary the surface details
LengthIs each one as short as it can be?Trim anything that is not part of the lesson

How many examples?

There is no magic number. A style task often needs only one or two. A classification task with several labels usually needs at least one for each label. Complex tasks with many variations may benefit from five or more. Start small, test the results, and add an example only when you can name the specific gap it fills.

Order can matter

Claude pays attention to the whole prompt, but examples near the end can have extra influence. If you have a most important example, put it last, and avoid ending with a negative example that might linger. A neat pattern is to show a contrast pair and finish with the good version.

8Structuring Your Prompt: Labels, Tags, and Separators

When a prompt has instructions, examples, and real input all mixed together, clear boundaries keep Claude from getting confused.

Why labels matter

Imagine a pile of papers on a desk with no folders. A person has to guess which pages are instructions, which are samples, and which are the work to be done. Claude faces the same situation when everything in a prompt runs together. Clear labels tell it exactly what each part is.

Everyday analogy

A tidy filing cabinet has labeled drawers: “Invoices”, “Contracts”, “Photos”. Nobody has to open every drawer to find what they need. Labels and tags in a prompt are the drawer labels. They let Claude go straight to the right part and treat it correctly.

Ways to mark sections

The simplest method is plain-language headings such as “Examples to copy:” and “Examples to avoid:”. Another popular approach, which Anthropic’s guidance recommends for Claude, is wrapping sections in descriptive tags, for example a tag named example around each sample, and a differently named tag for samples to avoid. Both work. What matters is that the labels are consistent and descriptive, and that the real input is clearly separated from the examples.

flowchart TD
    A["Role and goal"] --> B["Context and rules"]
    B --> C["Positive examples in labeled sections"]
    C --> D["Negative examples in labeled sections, each with a reason"]
    D --> E["The real input to work on"]
    E --> F["Reminder of the output format"]
Figure 3: A clean layout for a prompt that uses both kinds of examples

The layout in the diagram moves from the general to the specific. It begins with the role and goal, then the background and rules, then the examples to copy, then the examples to avoid with their reasons, then the real material to work on, and finally a short reminder of the format. Keeping the real input after the examples helps make clear what is a sample and what is the actual task.

Labeling tips

  • Use names that say what the section is. “Good reply” and “Reply to avoid” are clearer than “Example 1” and “Example 2”.
  • Keep the same label style throughout. Switching between tags, headings, and dashes makes the prompt harder to read.
  • Separate the real input. Mark where the material to process begins and ends, so Claude does not treat it as another example.
  • Refer to sections by name. Say “Follow the style of the good replies above” so the instruction and the labels connect.
i
Practical tip

If you paste your own text into a prompt, tell Claude where it starts and ends, and say it is material to work on and not instructions to follow. This helps keep the prompt tidy and also adds a layer of safety, which Chapter 15 explains.

9Explaining the Why Behind Your Examples

An example shows a result. A reason shows the thinking that led to it.

From copying to understanding

Without a reason, Claude can only imitate surface features. With a reason, it can apply the underlying principle to new situations. “This reply is good” tells it little. “This reply is good because it names the problem, takes responsibility, and gives a date” gives it three rules it can use on any customer message, even one that looks nothing like the example.

Everyday analogy

A good teacher does not just mark an answer right or wrong. They write a note: “Correct, because you remembered to carry the one.” That note turns one answer into a lesson that helps with every future sum. A reason attached to an example does the same.

Useful reason phrases

PurposePhrase you can use
Explain a good exampleThis works because it leads with the result and then gives one supporting detail.
Explain a bad exampleAvoid this, because it repeats the question instead of answering it.
Say what to copyCopy the structure and the friendly tone, not the specific facts.
Say what not to copyDo not reuse the exact words or the topic from the example.
Name the ruleThe rule is: acknowledge first, then solve, then confirm.
Allow variationThe wording can change as long as the three parts stay in this order.

State the rule in words as well

Even the best examples can be read in more than one way. After showing them, add one sentence that states the rule you want Claude to take away. This guards against the model drawing the wrong conclusion. The examples show the pattern, and the sentence names it.

Generalize or copy?

Be clear about whether you want Claude to imitate closely or to take inspiration. For a rigid format, such as a fixed report layout, close imitation is right, and you can say “follow this format exactly”. For writing style, you usually want the feel and not the words, and you can say “capture the spirit, but write it in fresh words”. Claude can do either, if you say which.

!
Watch out

If you give an example and no instruction about how closely to follow it, Claude may follow it very closely, sometimes even reusing phrases. When variety matters, say so clearly.

10Worked Examples Across Everyday Tasks

See how positive and negative examples change the outcome in six common situations.

1. Matching a tone

Goal: friendly workplace messages. Positive example: “Hi Sam, quick update: the report is ready for your review. Could you look at it by Thursday?” Negative example: “Dear Sir or Madam, I hereby wish to inform you that the report has been completed.” Reason: the second is far too stiff for a colleague. Claude learns the warm, direct register and avoids formal filler.

2. Labeling customer reviews

Goal: sort reviews into positive, negative, or neutral. Examples: “The battery lasts all day” is positive. “Arrived late and the box was crushed” is negative. “It works.” is neutral, and is a borderline case shown on purpose. Including the neutral edge case teaches Claude not to force every short comment into a strong label.

3. Extracting details from text

Goal: pull out meeting details. Example input: “Meet Priya on 12 March at 4 pm at the Central Cafe.” Example output: Person: Priya. Date: 12 March. Time: 4 pm. Place: Central Cafe. With the output shown in the exact layout, every later extraction follows the same fields in the same order.

4. Writing summaries

Goal: executive summaries. Positive example: a two-sentence summary that opens with the main result and its number. Negative example: a summary that spends three sentences on background before reaching the point. Reason: busy readers need the result first. Claude learns to lead with the conclusion.

5. Explaining code with comments

Goal: helpful code comments. Positive example: “Skip empty rows, because the export adds a blank line at the end.” Negative example: “Loop through the rows.” Reason: the second repeats what the code already shows, while the first explains the purpose. Claude learns to explain why, not what.

6. Replying to upset customers

Goal: support replies. Positive example: a calm reply that acknowledges the problem and offers a next step. Negative example: a defensive reply that blames the customer. Reason: the first resolves the situation and the second escalates it. This is the contrast pair from Chapter 6, and it works for almost any sensitive reply.

7. Writing for a younger reader

Goal: explanations for ten-year-olds. Positive example: “A battery is like a small water tank. It stores energy until something needs it.” Negative example: “A battery is an electrochemical cell that converts stored chemical energy into electrical energy.” Reason: the second uses words a ten-year-old does not know. Claude learns to reach for everyday comparisons and short sentences.

i
Pattern to notice

In every case, the example is short, the reason is one sentence, and the lesson is a single clear rule. Examples succeed when each one teaches exactly one thing.

11Using Examples to Control Format and Structure

Format is where examples shine brightest, because Claude copies layout very faithfully.

Show the layout

If you need output in a particular shape, show a sample in exactly that shape. A table with named columns, a list with a title and a one-line description for each item, an email with a subject line and sign-off, a report with fixed headings. Claude will reproduce the layout reliably, which is far easier than describing every detail in words.

Everyday analogy

Think of a pastry shop using a tray with shaped hollows. Pour the batter in and every cake comes out the same shape. A format example is the tray: it fixes the shape, and the content can change each time.

Format examples for people and for programs

When people will read the output, examples keep results neat and consistent. When another program will read the output, examples are even more valuable, because small differences in layout can break the next step. In that case, show the exact field names in the exact order, and say “reply with only this structure and nothing else”.

You need…Show Claude…
Consistent report sectionsOne finished report with the headings in the right order
A tableThe header row and one filled row
Labeled fields for later useOne input and its output with the field names in place
A particular email layoutA sample email with subject, greeting, body, and sign-off
Short, punchy list itemsTwo items written at the length you want
A reply of a certain lengthA sample at that length, plus the number in words

Combine an example with a number

An example shows length by feel, and a number makes it exact. Say both: “Write replies about this long (under 60 words), like the example.” Claude then has both a picture and a measurement, and the two reinforce each other.

A negative example for format

Negative examples are useful for format too. If Claude keeps adding an introduction such as “Sure, here is your summary”, you can show that opening and say “Do not start with an opening line like this. Begin directly with the first bullet point.” Showing the unwanted habit and the preferred start is often the fastest cure.

!
Watch out

Make sure every example uses the format exactly. If one sample has a trailing comment or a different heading style, Claude may treat that as part of the pattern. Check each example character by character when exact format matters.

12Common Pitfalls: Copying, Over-Fitting, and Priming

Examples are powerful, and anything powerful can be misused. These are the problems to watch for.

Copying too closely

Claude can reproduce the wording, topic, or structure of an example when you wanted only its spirit. If every reply starts to sound like your sample, the examples are too dominant. Add variety, say which features to copy, and ask for fresh wording.

Over-fitting to the examples

If your examples cover only a narrow slice of the real inputs, Claude may handle that slice perfectly and stumble on everything else. This is called over-fitting. The remedy is to widen the examples to cover the range of real cases, including at least one unusual one.

Priming a bad pattern

As Chapter 5 showed, a negative example can sometimes pull the model toward the mistake. Guard against it by labeling the bad sample clearly, giving the reason, and showing the corrected version next to it.

flowchart TD
    A["Reply looks wrong"] --> B{"What kind of problem?"}
    B -->|"Copies example wording"| C["Add variety and say what to copy"]
    B -->|"Repeats a bad pattern"| D["Rephrase the negative example as a positive rule"]
    B -->|"Ignores the format"| E["Make every example match the format exactly"]
    B -->|"Wrong on unusual input"| F["Add an edge-case example"]
    B -->|"Too long or costly"| G["Trim to the fewest examples that work"]
    C --> H["Run again and compare"]
    D --> H
    E --> H
    F --> H
    G --> H
Figure 4: A diagnosis guide that matches each symptom to a fix
SymptomLikely causeFix
Replies echo the example’s wordsOne dominant example, no guidance on what to copyAdd a second, different example and say “do not reuse the wording”
Replies repeat the bad patternNegative example without a reason or a corrected versionAdd the reason and the good version, and state the rule positively
Output layout keeps driftingExamples differ from each other in formatMake all examples match exactly
Fails on unusual inputNo edge case in the examplesAdd an edge-case example
Labels come out inconsistentBorderline cases labeled differentlyAlign the labels and add a short definition for each
Replies are too long, prompt is hugeToo many or too long examplesShorten examples and use the fewest that work
ANTI-PATTERN 01Avoid
What people do

They paste five bad examples and one good one, with no labels and no reasons, hoping Claude will “figure it out”.

Why it fails

Claude cannot tell which samples to follow and which to avoid, and the sheer amount of bad text can push the reply toward it.

Better approach

Lead with one or two good examples, add a single labeled bad example for the specific mistake, give a reason, and show the corrected version.

ANTI-PATTERN 02Avoid
What people do

They use a single example for a task that has many variations, such as a mix of short and long inputs or several categories.

Why it fails

Claude assumes every case looks like the one example, and treats incidental details as rules.

Better approach

Add examples that show the range, including one unusual case, and state the rule in a sentence so the pattern is not left to guesswork.

13Iterating: Turning Failures into Examples

Every disappointing reply is raw material for a better example.

The correction loop

1

Run the prompt

Try it on a realistic input and read the reply with a critical eye.

2

Name the miss

Decide exactly what went wrong: tone, length, structure, content, or a repeated habit.

3

Turn the miss into a negative example

Copy the faulty reply into the prompt, label it, and explain the problem in one sentence.

4

Write the corrected version

Edit the faulty reply into what you wanted, and show it as the matching positive example.

5

Test again, on more than one input

Check that the fix works on other inputs and has not broken something that was working.

Everyday analogy

Skilled craftspeople keep a notebook of mistakes and fixes. Each entry records what went wrong and how it was put right, and over the years the notebook becomes their most valuable tool. A growing set of corrected examples is your notebook for working with Claude.

Correcting inside a conversation

You do not have to rewrite the original prompt each time. In a chat, you can say “That reply was too formal. Here is a version I would prefer, which is warmer and shorter. Please write the rest in that style.” This gives Claude a fresh contrast pair at the exact moment it is most useful.

Ask Claude to help build examples

Claude can also write candidate examples for you. You can ask it to draft three sample replies in different styles, then pick the one you like and use it as your positive example. You can even ask for a deliberately poor version, labeled as such, to use as a negative example. Always review what it produces, because examples you approve become the standard for everything that follows.

Keep a personal example library

When you find examples that work, save them. A small collection, organized by task, such as “polite decline”, “weekly update”, and “product blurb”, saves time and keeps your results consistent. Where your account offers saved project material or saved preferences, a standing example can be stored there, so you do not need to paste it every time.

i
Practical tip

Change one example at a time and rerun. If you swap three examples at once and the result improves, you will not know which one helped, and you will not be able to repeat the success.

14Examples Inside Real Products

Teams that build tools on Claude treat examples as a managed resource, not a one-off paste.

The example bank

A company that uses Claude to draft support replies, label documents, or write product text often keeps a collection of approved examples, both positive and negative, called an example bank. Each entry has an input, a good output, and sometimes a bad output with a reason. The bank is reviewed by people who know the business, so quality is controlled in one place.

Everyday analogy

Think of a restaurant chain’s recipe binder. Each dish has a photo of how it should look, plus a note on common mistakes. New cooks in any branch follow the binder, and every plate comes out consistent. The example bank is that binder, and Claude is the cook.

Choosing the right examples at the right time

A large bank holds far more examples than can fit in one prompt. So a product often picks the few most relevant ones for each request, choosing those whose inputs are closest to the new input. A request about a late delivery gets examples about late deliveries, and a request about a refund gets refund examples. This keeps prompts short and the examples on target.

flowchart TD
    A["Example bank: positive and negative examples"] --> B["Example selector picks the closest matches"]
    C["Fixed instructions and rules"] --> D["Prompt builder"]
    B --> D
    E["New user input"] --> D
    D --> F["Input checks"]
    F --> G["Claude"]
    G --> H["Output checks: format and safety"]
    H --> I["Reply to user"]
    H --> J["Logs and quality metrics"]
    J --> K["Failures added to the example bank"]
    K --> A
Figure 5: A product pipeline that selects, uses, and improves its examples over time

The diagram shows a loop. A selector pulls the best examples from the bank, and a prompt builder combines them with the fixed instructions and the new input. After input checks, Claude writes the reply, and output checks confirm the format and safety. Logs record how things went, and failures are reviewed and turned into new examples that go back into the bank. The system gets better with use.

Design patterns worth knowing

Pattern

Fixed examples

A small, hand-picked set that is always included. Simple and predictable, good for style and format.

Pattern

Dynamic examples

Examples selected per request by similarity to the input. Better coverage with shorter prompts.

Pattern

Contrast pairs

Good and bad versions stored together, with the reason. Excellent for subtle quality rules.

Pattern

Edge-case set

A special group of unusual examples that are included when the input looks unusual.

Pattern

Human review loop

People check a sample of outputs and promote good ones into the bank, and bad ones into negative examples.

Pattern

Versioned prompts

Every change to the examples is numbered and recorded, so a bad update can be rolled back.

Real-world scenarios

A support team keeping a consistent voice

The team stores approved replies and a few labeled bad replies. Claude drafts, an agent reviews and sends, and a monthly review adds new examples from real cases. The voice stays consistent across many agents.

A document-sorting workflow

An office uses Claude to label incoming documents as invoice, contract, or other. The examples include tricky documents on purpose, such as an invoice that looks like a letter, so the labels remain accurate on messy real-world files.

A marketing team protecting its brand voice

The team keeps a handful of approved headlines and a few rejected ones with reasons such as “too pushy” or “too vague”. Every new draft starts from that guidance and needs far less editing.

15Privacy and Security When Using Examples

Examples are real text, and real text can carry private details or hidden instructions.

Everyday analogy

Training posters in a company break room often show sample forms. Smart companies fill those forms with made-up names and numbers, never real customer data, because the poster is on display to everyone. Treat the examples in your prompts like the poster: use made-up details, not real ones.

Use anonymized or invented examples

The best examples come from real work, but real work often includes names, phone numbers, account details, or confidential facts. Before an example goes into a prompt, replace those with placeholders or invented values. “Customer A” and “order number 12345” teach the same lesson as the real details, with none of the risk.

Remove

Names and contact details

Replace real people with invented names or roles.

Remove

Account and ID numbers

Swap them for obviously fake values.

Remove

Passwords and secret keys

These never belong in an example, or in any prompt.

Remove

Confidential business facts

Unreleased plans, prices, and legal terms should not appear in samples unless your organization allows it.

Examples can leak into outputs

Because Claude often copies from examples, details in them can reappear in replies, sometimes in front of the wrong audience. If a sample contains a real customer’s complaint, a later reply may echo it. Another reason to use invented details, and to tell Claude “do not reuse specifics from the examples”.

Untrusted examples and hidden instructions

If examples or material in your prompt come from outside sources, such as a web page, an email, or a shared document, they might contain hidden instructions aimed at the model, like “ignore your earlier rules”. This is called prompt injection. Claude is trained to resist it, and no defense is perfect. Keep your own instructions separate from outside material, label the material as content to work on, and review results before acting on them, particularly where money or private data is involved.

ANTI-PATTERN 03Avoid
What people do

They paste real customer emails, complete with names, addresses, and order details, as examples in a shared prompt used by a whole team.

Why it fails

Private information spreads to everyone who can see the prompt, can reappear in replies, and may break privacy rules.

Better approach

Rewrite examples with invented details, store them in a controlled place, and check them before they enter a shared prompt or an example bank.

Examples do not guarantee safe behavior

A strong set of examples improves consistency, but it is not a security control. For sensitive work, combine good examples with permission limits, input and output checks, and human review for important actions.

16Measuring and Monitoring Example-Driven Prompts

How do you know your examples are doing their job? You test them.

Everyday analogy

A kitchen tastes the soup before it leaves the pass. Nobody assumes a recipe is right just because it worked last week. Prompts with examples need the same regular tasting, particularly after any change.

Build a small test set

Collect twenty to fifty realistic inputs, including some unusual ones and the cases that failed before. Each time you change the examples or the instructions, run the whole set and compare the results with the previous run. This shows whether a change helped overall or only fixed one case while breaking others.

MeasureWhat it tells youExample check
Style matchDoes the output sound like the positive examples?A reviewer rates each reply from one to five
Format complianceDoes it follow the layout you showed?Count outputs that contain every required part
Avoided mistakesIs the negative-example behavior gone?Count replies that still repeat the bad pattern
AccuracyAre labels and facts correct?Compare against known right answers
CopyingIs it reusing the examples’ wording or details?Search outputs for phrases from the examples
ConsistencyAre results steady across runs?Run the same input several times and compare
Cost and speedHow many tokens do the examples add?Track average prompt size and response time

Version everything

Give each version of your prompt and example set a number. Note what changed and why, and keep the old versions so you can go back if a change makes things worse. In a product, log the version, the model used, the time taken, and a quality score for each reply, taking care that logs do not keep sensitive text longer than needed.

Retest when things change

When the model version changes, when your inputs change, or when you edit the examples, run the test set again. A prompt that behaved perfectly before can behave a little differently after an update, and a quick retest catches the change before your users do.

Turn complaints into permanent tests

Every time a real user or reviewer flags a bad output, add that input to the test set, and consider turning the output into a negative example. Over time the set grows into a complete safety net of past mistakes that cannot quietly return.

17Best Practices, Common Mistakes, and Checklists

A short field guide you can keep next to your keyboard.

Best practices

Do

Start with instructions

Try clear instructions first, and add examples only where words fall short.

Do

Lead with the positive

Show what you want first. Add a negative example only for a specific recurring mistake.

Do

Attach a reason

Explain why each example is good or bad, in one short sentence.

Do

Pair bad with good

Show the corrected version right beside every negative example.

Do

Cover the range

Include variety and at least one edge case.

Do

Label everything

Use clear names or tags, and keep the real input separate.

Do

Say what to copy

Name the features to match and the ones to ignore.

Do

Use invented details

Anonymize every example and keep secrets out entirely.

Common mistakes

  • Pasting examples with no introduction, so Claude is unsure whether they are samples or the task.
  • Using a flawed example and expecting Claude to somehow ignore the flaws.
  • Giving only negative examples, so the target is never shown.
  • Letting examples contradict each other in format or labels.
  • Leaving out edge cases, then being surprised when unusual inputs fail.
  • Including real personal data in examples that will be shared or reused.
  • Never testing the examples on more than one input.
ANTI-PATTERN 04Avoid
What people do

They keep adding examples every time something goes wrong until the prompt grows to many pages, and nobody remembers why each one is there.

Why it fails

The prompt becomes slow, costly, and contradictory, and a new example can quietly undo an old fix.

Better approach

Review the set regularly, keep each example tied to a note about the lesson it teaches, remove duplicates, and run the test set after every change.

Checklist before you press Send

1

Is my goal stated plainly?

A clear instruction comes first, and the examples support it.

2

Are my examples good and relevant?

Each one is something I would be happy to receive, and matches the real task.

3

Is every example labeled, with a reason?

Claude can tell samples from the task, and knows what to copy and what to avoid.

4

Do the examples agree with each other?

Their formats and labels follow the same rules, and one covers an edge case.

5

Are the details safe?

Names, numbers, and secrets are invented or removed.

18Frequently Asked Questions

Quick answers to questions people ask about examples in Claude.

Q1Do I always need negative examples?
No. Positive examples and clear instructions are enough for most tasks. Add a negative example when a specific mistake keeps recurring and is hard to explain in words.
Q2How many examples should I include?
Start with one or two. Add more only when you can name a gap they fill, such as a missing category or an unusual case. More examples cost tokens and can push the reply toward their details.
Q3Will Claude remember my examples in future chats?
Not by default. Examples work inside the conversation where you provide them. Depending on your account and settings, features such as saved project material or saved preferences may keep standing instructions, so check what is available to you.
Q4Do examples retrain or change Claude?
No. Examples guide the current conversation only. The model’s internal numbers do not change.
Q5Why did Claude copy my example too closely?
Claude is very good at matching patterns, and if you do not say which parts to copy, it may copy many. Add a second example for variety, and write something like “match the tone and length, but use fresh wording and a different topic”.
Q6Can a negative example backfire?
It can, by drawing attention to the pattern you wanted to avoid. Reduce the risk by labeling it clearly, giving a reason, showing the corrected version beside it, and also stating the rule positively.
Q7Should I use examples or instructions?
Use both. Instructions state the goal and the rules, and examples show what those words mean in practice. When the two disagree, Claude may follow the example, so check that they match.
Q8Do I need special tags to mark examples?
No, though they can help. Plain headings such as “Good example” and “Example to avoid” work well. Descriptive tags are a popular alternative that keeps sections clearly separated. Whatever you pick, use it consistently.
Q9Do examples work in both the chat app and when building products?
Yes. In the chat app you paste them into your message. In a product, builders include them in the instructions or the message that is sent to Claude. The same principles apply.
Q10Can Claude write examples for me?
Yes. You can ask for sample replies in different styles and choose the best one. Review them carefully, since any example you approve becomes the standard for what follows.
Q11Should my examples be real or invented?
Real work makes the best starting point, but remove names, numbers, and confidential details before using it. Invented details teach the same lesson without the privacy risk.
Q12Do examples guarantee the output I want?
They improve consistency but do not guarantee it. Always review important outputs, test your prompt on several inputs, and check facts that matter. For current recommendations, see Anthropic’s prompting documentation.

19Summary and Key Takeaways

The whole idea in one place.

Positive examples show Claude what you want, and negative examples show it what to avoid. Because Claude continues patterns, a few well-chosen examples placed in the prompt can shape length, tone, structure, and labels far more precisely than a long description. The best results come from combining instructions with examples, leading with the positive, attaching a short reason to every example, and pairing each negative example with a corrected version. Labels and clear separators keep the prompt tidy, edge cases and variety prevent narrow results, and invented details keep private data safe. When replies go wrong, treat the failure as raw material: turn it into a labeled contrast pair, retest on several inputs, and keep a growing library of what works. In real products, teams manage examples in a bank, select the most relevant ones, and measure results over time.

Key Takeaways

  • Showing beats telling for style and format. A short example carries length, tone, and structure that words struggle to describe.
  • Lead with positive examples. Show the target first, and add a negative example only for a specific mistake that keeps recurring.
  • Every negative example needs a reason and a fix. Pair it with a corrected version so Claude learns what to do, not only what to avoid.
  • Choose examples with care. Make them good, relevant, consistent with each other, varied, and include at least one edge case.
  • Label and separate. Use clear names or tags, and keep the real input apart from the examples so nothing is confused.
  • Say what to copy. Name the features to match and the ones to ignore, to prevent copying and over-fitting.
  • Protect privacy and keep testing. Use invented details, treat outside text with care, and verify your examples on a test set after every change.