Chapter 1 · Prompt Foundations
Core Patterns I: Zero-Shot, Few-Shot, Roles and Constraints
- Page 5 of 24
- 18 min read
Mateo in Bogotá sorts customer messages every morning: billing, delivery, product, or something else. On the first day he types each message into his assistant with a different instruction. By the end of the week he has a prompt that he pastes in, a short list of examples, and a habit of checking the labels. Nothing in it is clever. He found a few patterns, which are prompt shapes that solve common problems, and he reused them.
This page starts the core prompt patterns. You already know the parts of a prompt from The Anatomy of a Good Prompt: Task, Context, Input and Output Format and the tools from Constraints, Delimiters and a Reusable Prompt Checklist. Here you learn five patterns built from them: prompts with no examples, one example or several; roles and personas; constraints; output formats; and breaking a big request into smaller steps and deliverables. The next page, Core Patterns II: Decompose, Critique and Revise, continues with checking and improving drafts.
What you will learn
- The difference between zero-shot, one-shot and few-shot prompts, and how to choose examples that cover different cases.
- How a role or persona changes viewpoint and tone, why it does not make answers more correct, and why you must never invent credentials.
- How to write constraint-based and output-format prompts that you can check.
- How to split a task into steps, and a big request into smaller deliverables.
The patterns at a glance
| Pattern | What it does | Use it when | Watch out for |
|---|---|---|---|
| Zero-shot | Task and rules, no examples | The task is common and clear | The model guesses your style or borderline rules |
| One-shot | One worked example | You mainly need a format or style | The model copies the example too closely |
| Few-shot | Several worked examples | Labels or style need to be shown, not described | Unbalanced or unclear examples mislead the model |
| Role / persona | A viewpoint or voice | Tone and perspective matter | It is not an accuracy booster |
| Constraint-based | Hard limits and exclusions | Length, scope or content must be controlled | Limits you cannot check |
| Output format | A defined shape | You will paste or process the answer | Format can be right while values are wrong |
| Decomposition | Smaller steps or deliverables | The task is large or has ordered stages | Scripting every thought of the model |
Zero-shot, one-shot and few-shot prompting
A shot is one worked example inside the prompt. The three names only count the examples. All the invented data below is for practice.
Zero-shot prompting for an unseen task
Zero-shot means no examples: you describe the task and rely on what the model already knows. It works well for common tasks with clear rules, and it is the right first try because it is the shortest.
Weak prompt:
Sort this message: "I was charged twice for order 5521."There is no list of categories and no output shape, so the reply may be a paragraph.
Better prompt:
Classify the customer message into exactly one category: billing, delivery,
product, other. Answer with the category name only.
Message: "I was charged twice for order 5521."Example reply (illustrative; yours will differ):
billingWhat to verify: the reply is one word and comes from your list. Zero-shot starts to fail on borderline messages, for example "I returned the jacket last week and the refund has not arrived." Is that billing, delivery or product? Your rules decide, and the model cannot know your rules unless you show them.
One-shot prompting with one example
A one-shot prompt adds a single example. One example is good at fixing the shape of the answer: the label format, the tone, the length.
Better prompt:
Classify each customer message into exactly one category: billing, delivery,
product, other.
Message: "My parcel has been in the same city for six days."
Category: delivery
Message: "The zip broke after one wash."
Category:Example reply (illustrative; yours will differ):
productThe prompt ends on the open line "Category:", so the reply continues the pattern. The risk with a single example is that the model copies it too closely, including its length, its wording or its label. Treat the example as a pattern to follow, not as a fact.
Few-shot prompting with multiple examples
Few-shot prompting gives several examples, so the model can infer rules that are hard to describe. Use it for labelling, for a house style, or for a format. Show your decisions about borderline cases as examples, and state the rule in words as well.
Better prompt:
Classify each customer message into exactly one category: billing, delivery,
product, other. If a message mentions two problems, use the category of the first
problem. Answer with the category name only.
Message: "I was charged twice for order 5521."
Category: billing
Message: "My parcel has been in the same city for six days."
Category: delivery
Message: "The zip broke after one wash."
Category: product
Message: "Do you sell gift cards?"
Category: other
Message: "I returned the jacket last week and the refund has not arrived."
Category: billing
Message: "The jacket arrived late and the sleeve is torn."
Category:Example reply (illustrative; yours will differ):
deliveryWhat to verify: the label follows your rule ("first problem"), so "delivery" is right under this rule. Whether that rule serves your business is a decision for you, not the model. Check also that the format matches the examples.
Provider note (as of 2026-10-12): the guides of OpenAI, Anthropic and Google each advise examples that are relevant and varied and that keep the same format throughout. Anthropic suggests wrapping examples in tags and a handful (about three to five); Google notes that too many examples can lead a model to overfit to them. Counts and wording change, so check the current documentation and test on your own task.
Choose examples that cover different cases
The model learns from the examples you pick, including their accidents. A skewed set teaches a skewed rule. Here is a typical failure pattern: every example has the same label.
Weak prompt:
Classify each customer message into one category: billing, delivery, product, other.
Message: "I was charged twice for order 5521."
Category: billing
Message: "My card was charged after I cancelled."
Category: billing
Message: "The invoice shows the wrong amount."
Category: billing
Message: "Do you sell gift cards?"
Category:Example reply (illustrative; yours will differ):
billingThis reply shows how a one-sided set can pull the answer toward the label it saw most. It is a pattern to watch for, not a rule that every model follows. The few-shot prompt above avoids it. Use this table when you choose examples.
| Cover | Why |
|---|---|
| Every label at least once | The model sees what each label looks like. |
| A borderline case with your decision | It learns your rule, not a generic one. |
| A "none of these" case (here: other) | It has a safe place for messages that fit nowhere. |
| Different lengths and wording | It does not tie a label to one phrase. |
| A mixed order of labels | The order itself is not a hidden signal. Change the order and test. |
| Examples that are not your test items | Otherwise you test the model on its own answers. |
Keep examples short, correct and free of private data. A wrong label in an example becomes a wrong rule.
Role prompting and persona prompting
Role prompting for a defined perspective
A role tells the model whose viewpoint to take. It is most useful when the viewpoint itself is the point, for example reading a text as a new customer would.
Weak prompt:
Review this product description.Better prompt:
Act as a first-time customer who has never heard of our shop and is deciding
whether to buy. Read the product description in the tags and list the three
questions you would still want answered before buying. Questions only; do not
rewrite the description.
<description>
Handmade linen shirt. Comfortable. Many colours. Ships soon.
</description>Example reply (illustrative; yours will differ):
1. Which sizes are available, and how does the shirt fit?
2. Which colours exactly, and are they the same as in the photos?
3. How many days is "soon", and what does the shipping cost?What to verify: the questions point at real gaps in the text, such as sizes, colours and the delivery time, and the model did not invent facts about the shirt.
Persona prompting without inventing credentials
A persona is a role with a voice: "a patient teacher", "a calm health educator", "a friendly librarian". It changes tone, vocabulary and level of detail. Two rules apply.
- A persona is for tone and viewpoint, not for correctness. Studies of earlier-generation models did not find a reliable accuracy gain from personas; check facts as you always do.
- Never invent credentials. "You are a licensed doctor" does not make the reply a medical opinion, and it may push the model to sound more certain than it can be. For health, law, money or safety, ask for general information, ask for the limits, and ask which questions to bring to a qualified professional.
Weak prompt:
You are a licensed doctor. Tell me what is wrong with my cough.Better prompt:
Answer in the voice of a calm, plain-spoken health educator. I am an adult and my
cough has lasted three weeks. Give general information only: why a cough might last
this long, signs that mean I should contact a health professional soon, and three
questions to ask at an appointment. Do not claim to be a doctor and do not diagnose me.Example reply (illustrative; yours will differ):
A cough that lasts three weeks can have many causes, and I cannot tell which one
applies to you. Contact a health professional soon if you have trouble breathing,
chest pain, blood when you cough, a fever that does not go away, or unexplained
weight loss. Questions to ask: What could be causing this? Which tests, if any, do
you suggest? What should I watch for before my next visit?What to verify: the reply gives general information, does not diagnose and points to a professional. Treat it as a start for a conversation, not as advice.
Constraint-based and output-format prompting
Constraint-based prompting
In a constraint-based prompt, the limits are the main content: the facts to use, the amount, what must appear and what must not. Use it when length, scope or content must be controlled. Write each limit so you can check it.
Weak prompt:
Write a nice description of the sandals.Better prompt:
Write a product description for leather sandals.
Facts: sizes 36 to 44; colours brown and black; handmade; leather sole;
ships in 3 to 5 days.
Must: 25 to 40 words; include the sizes and the shipping time.
Must not: say waterproof; use the words "best" or "perfect"; add any fact not listed.Example reply (illustrative; yours will differ):
Handmade leather sandals in brown or black, sizes 36 to 44. The sole is leather.
Choose your size and colour today, and your pair ships within 3 to 5 days.What to verify: count the words (this example has 30), look for sizes and shipping time, search for the banned words, and compare every claim with the fact list.
Output-format prompting
An output-format prompt describes the shape of the answer: columns, order, field names, length, and what to write when a value is missing. Use it whenever you will paste the answer elsewhere or compare several answers.
Better prompt:
Read the notes in the tags. Return a table with the columns Task, Owner, Due.
One row per task. If a value is not in the notes, write "not stated". Return only
the table.
<notes>
Mina will update the plan by Friday. Omar books the room for 2026-11-12.
Aiko still needs to send the invoice; no date was given.
</notes>Example reply (illustrative; yours will differ):
Task | Owner | Due
Update the plan | Mina | Friday
Book the room | Omar | 2026-11-12
Send the invoice | Aiko | not statedWhat to verify: the columns and the row count, and that "Friday" has no date in the notes, so the reply did not invent one. If a program will read your answer, you can ask for JSON, but be careful: a prompt that asks for JSON is a request, and the reply can still be invalid or have wrong values. Some tools can force a schema, which guarantees the shape but not the values. Either way, check syntax, the fields and the values. The Advanced tutorial covers this properly.
Stepwise decomposition and smaller deliverables
Stepwise task decomposition
Decomposition means splitting a task into parts. You can do it in two ways: put numbered steps in one prompt (when later steps use earlier results), or send the steps as separate messages (when you want to review each result). Ask the model to show the intermediate results you want to check, such as a list or a calculation.
Weak prompt:
Can I do all these tasks this week? Report 5 hours, slides 4 hours, rehearsal 2 hours.Better prompt:
Work in this order and show each result.
1. List the three tasks below with their hours.
2. Add the hours to get a total.
3. Compare the total with the 12 hours I have, and say whether it fits.
Tasks: report 5 hours; slides 4 hours; rehearsal 2 hours.Example reply (illustrative; yours will differ):
1. Report 5 h; slides 4 h; rehearsal 2 h.
2. Total: 5 + 4 + 2 = 11 hours.
3. You have 12 hours, so it fits, with 1 hour to spare.What to verify: add the hours yourself. A visible calculation is easy to check.
A correction to a popular belief. "Think step by step" is not a magic phrase that improves every answer. For many current models that already reason internally, the providers advise stating the goal, the constraints and the output you need, not scripting every step. Use your own decomposition when the task has stages you want to review, and ask for a short, checkable explanation (a list, a calculation, the evidence) rather than for the model's hidden thinking.
Break a complex request into smaller deliverables
A deliverable is one finished piece with a clear test for "done". A request like "Prepare everything for our product launch" mixes many deliverables, and the model will give a shallow answer to all of them. First ask for the list, then do one deliverable at a time.
Weak prompt:
Prepare everything for our product launch.Better prompt:
We launch a new notebook on 2026-11-20 with a small team and no advertising budget.
Do not write anything yet. List the deliverables we need (at most 5). For each give
a one-line "done when" test. Then wait for me to choose where to start.Example reply (illustrative; yours will differ):
1. Announcement email. Done when: it states the date, the product and one link.
2. Three short social posts. Done when: each is under 40 words and has one call to act.
3. Product page text. Done when: it lists size, price and shipping in a short list.
4. FAQ with five questions. Done when: each answer is under 30 words.
Which one should we start with?Now continue with one message per deliverable: "Write deliverable 1 only, using the facts below..." Each deliverable has its own facts, constraints and format, and you check it against its "done when" test before you move on. The next page shows how to summarise results between steps.
Where this shows up at work
- Support and operations: few-shot classification of tickets, and fixed formats such as a Task, Owner, Due table for meeting notes.
- Marketing and content: constraint-based copy with a fact list and banned claims; a role such as a first-time customer for review.
- Projects: a request split into deliverables with "done when" tests, so progress can be checked.
- Building AI features: developers keep example sets as test cases and review changes to them like code. The same few-shot set can later check whether a new prompt version broke anything.
Common mistakes
- Few-shot with a one-sided set. The model leans toward the label it saw most. The fix: cover every label, a borderline case and a "none of these" case.
- Using your test items as examples. You then learn nothing about new input. The fix: keep a few held-out items for checking.
- Believing a role makes answers correct. It changes voice and viewpoint only. The fix: use it for perspective, and verify facts as usual.
- Inventing credentials. A "licensed expert" persona gives false confidence. The fix: ask for general information and the questions to bring to a real professional.
- Limits you cannot check. "Short" and "nice" are not constraints. The fix: numbers, lists and must-not lines.
- Everything in one request. A big request gets shallow answers. The fix: list the deliverables, give each a "done when" test, and do them one at a time.
Try it yourself
- Easy. On The Anatomy of a Good Prompt: Task, Context, Input and Output Format you saw four comments: A "Beautiful mug, but it arrived a week late." B "Fast delivery and the bowl is perfect." C "The colour is different from the photo." D "Lovely quality. Will order again." Write a zero-shot prompt that labels each comment positive, negative or mixed, one label per line. Then add one example and compare the two replies.
- Medium. Build a few-shot prompt that labels workplace messages urgent, normal or ignore. Messages: (1) "Server room is flooding, call me now." (2) "Can you send last week's slides when you have time?" (3) "You won a free prize! Click here." (4) "Reminder: invoice 3301 is due tomorrow." (5) "Thanks!" (6) "Is the meeting on Thursday at 10:00 or 11:00?" Choose four as examples and keep two for testing. Explain your choice in one sentence per example, and state one rule for borderline cases.
- Hard. A community group in Accra wants to hold a two-day neighbourhood clean-up. Use the patterns of this page: first ask for a list of at most five deliverables with "done when" tests; choose one; then write a prompt for it with a role (a viewpoint), constraints with must and must-not lines, an output format, and one short example. Run it, then check the reply with the checklist from Constraints, Delimiters and a Reusable Prompt Checklist.
Answers
Easy. A strong zero-shot prompt:
Label each comment as positive, negative or mixed. Answer with one line per comment:
the letter, a colon, then the label. Nothing else.
A. "Beautiful mug, but it arrived a week late."
B. "Fast delivery and the bowl is perfect."
C. "The colour is different from the photo."
D. "Lovely quality. Will order again."Expected labels: A mixed, B positive, C negative, D positive. Pass checklist: the label list is stated; the format is stated; your replies are one line each; you compared the zero-shot and one-shot replies and noted whether the example changed the format or any label. Your one-shot reply may copy the example's wording: if it does, that is the lesson.
Medium. A strong choice: examples 1 (urgent), 2 (normal), 3 (ignore) and 4 (borderline, urgent because of the date); keep 5 and 6 for testing, with expected labels ignore and normal. The borderline rule could read: "A deadline within one day is urgent." Pass checklist: every label appears at least once; there is a borderline example with the rule stated in words; the test items are not among the examples; the format of all examples is identical; you ran the two held-out messages and compared the labels with the expected ones.
Hard. Answers vary. A plausible deliverable list: volunteer sign-up message, route and tools plan, safety notes, thank-you message. Your result passes if: there are at most five deliverables, each with a testable "done when"; the role is a viewpoint, not a credential; the constraints include numbers and at least one must-not; the format is stated; the example is short and labelled; the reply was checked against the "done when" test and the checklist; and any invented fact was noted or removed.
Summary
- Zero-shot describes the task, one-shot fixes a format with an example, and few-shot shows rules and borderline decisions with several examples.
- Choose examples that cover every label, a borderline case and a "none of these" case, and keep test items out of them.
- A role or persona sets viewpoint and tone. It is not an accuracy booster, and credentials must never be invented.
- Constraints and output formats work when you can check them: numbers, lists, columns and a rule for missing values.
- Split work into steps or deliverables with a "done when" test, and review each result before you continue.
Next: Core Patterns II: Decompose, Critique and Revise continues with summarising results between steps, reviewing a draft with a checklist, asking for a second-pass critique and revising against clear criteria.

