Skip to main content
Guide Prompting

How to prompt better, and why it works

Five moves cover nearly everything that separates a strong prompt from a weak one: being specific and giving context, naming the output format, showing examples, asking for step-by-step reasoning on hard problems, and assigning a role. This guide covers all five, and the more useful question behind each one: why it actually works, traced back to how a model predicts its next word.

Reference11 min readLast verified August 2026

What you’ll learn

  • Explain why a vague prompt produces a generic answer, in terms of next-token prediction
  • Write prompts that name the audience, length, and format before the model starts generating
  • Decide when a few-shot example will outperform a written instruction, and avoid teaching the model an accident from a single example
  • Recognize which problems benefit from step-by-step reasoning and which just spend tokens for nothing
  • Assign a role that shifts vocabulary and priorities, without expecting it to add knowledge the model does not have
  • Run a one-variable-at-a-time iteration loop instead of guessing at a full rewrite

Most prompting advice sounds like folklore: talk to it nicely, tell it to take a breath, promise it a tip. None of that is why prompts succeed or fail. A model does one mechanical thing, over and over: given the tokens so far, it computes a probability for every possible next token, samples one, and repeats. A prompt is not a request the model interprets with judgment. It is the text that shapes those probabilities before a single token comes out. Every technique below works, when it works, for a specific mechanical reason tied to that one loop, not because it is polite or clever.

New to this? A token is the small chunk of text a model reads and writes one piece at a time, often a word or part of a word ("prompt" might be one token, "prompting" might be two). Every idea in this guide comes down to shaping which token gets picked next.

The one mechanism every technique leans on

A model's grasp of a topic is statistical structure it learned once, during training, then frozen. Nothing in your prompt changes what it knows. What your prompt changes is which part of that frozen structure gets pulled forward, and how tightly the next-token predictions get constrained. A vague prompt is consistent with an enormous number of different, individually reasonable continuations, so the highest-probability token at each step drifts toward the generic middle of that set: a composite of everything a person might have meant. A precise prompt rules most of that space out before generation starts, so what is left to predict sits much closer to what you actually wanted.

Key idea
Every move in this guide does the same one thing from a different angle: it narrows the range of continuations the model treats as plausible, before generation starts, so the highest-probability path lands closer to the answer you want.

At a glance: weak versus strong

Five moves cover almost every real prompting problem. This is the fast version; the reasoning behind each row follows.

MoveWeakStrong
Specificity & contextWrite about our new featureWrite a 100-word announcement of the new export feature, for existing users who already know the product. Plain text, one paragraph.
Output formatGive me the complaints from this feedbackReturn the complaints as a JSON array of strings, one per element. No other text.
Examples (few-shot)Normalize the date to a standard formatShow 2 to 3 example inputs paired with the exact YYYY-MM-DD output you want, then the real input
Step-by-step reasoning"Answer directly""Work through this step by step, then give the final number"
RoleReview this codeYou are a senior security engineer reviewing this before it ships. Flag injection risks and unsafe defaults first.
One example per move. The reasoning for each is below.

1. Be specific, and give it context it does not have

Vagueness is not a style problem. It is a probability problem. "Write about our product" is compatible with thousands of genuinely different, equally valid pieces of text: a press release, a tweet, a technical spec, a joke. Nothing in that sentence rules any of them out, so the model falls back on whatever is statistically typical for that phrase in its training data, which tends to be a bland composite of all of it. Naming the audience, the length, the goal, and the format removes those branches from the tree before generation ever starts.

Context closes a different kind of gap. The model has no memory of your company, your last conversation, or the constraint sitting in your head that you never typed. Leave that gap open and the model does not leave it blank; it fills it with whatever is most common for that kind of request in general, which is rarely your specific situation. A practical test: if a new hire who has never met you would need a fact to do the task well, the model needs it too, spelled out, every time, since it starts from zero on every request.1

2. Name the output format before it starts writing

Generation is sequential: each token is chosen conditioned on every token before it, including the ones the model itself just wrote a moment earlier. That is why a format instruction usually works best before the content request, not after. Ask for JSON at the start of the prompt and every subsequent token gets predicted with "this is JSON" already baked into the context, so the model is effectively continuing a pattern it already committed to. Tack the same request onto the end of a prompt that opened with "tell me about X," and the model has already started conditioning on a prose answer; the format request now has to fight the momentum of everything that came before it instead of shaping the answer from the first token.

Same request, format named up front instead of assumed
Before:
List the complaints from this customer feedback.

After:
Extract the complaints from this customer feedback as a JSON array
of strings, one complaint per element. Return only the JSON, no
other text.

Feedback: "Shipping took 9 days, the box arrived damp, and support
never replied to my email."

Format is not decoration on top of the content. The same content returned as a wall of prose instead of a table is not a smaller version of a good answer; it is a differently shaped answer that now costs you the work of restructuring it by hand.

3. Show it, do not just describe it: zero-shot vs few-shot

A zero-shot prompt is instructions with no sample of the output attached. That is fine for common, low-ambiguity tasks. It is a weak fit for anything whose shape is easier to show than to describe: an exact schema, a specific tone, a formatting quirk you cannot cleanly name.

A few-shot prompt adds one or more input-output pairs before the real request, and it works for a reason specific to how these models behave at scale. GPT-3 was shown to perform new tasks from a handful of examples placed directly in the prompt, with no gradient update and no retraining at all: the pattern already sitting in the prompt was enough for the model to infer what came next.2 In prediction terms, a written instruction like "make it punchy" is one fuzzy phrase the model has to interpret from scratch, while two or three worked examples are a visible pattern already present in the tokens it is conditioning on. Completing a pattern that is already in the context is a narrower, easier prediction problem than inferring a style from an adjective.

Zero-shot vs few-shot, same task
Zero-shot:
Extract the date and turn it into a standard format.

Text: "Meeting moved to next Tues, the 14th of July"


Few-shot:
Extract the date and normalize it to YYYY-MM-DD.

Text: "Let's meet on March 3rd"
Date: 2026-03-03

Text: "See you next Monday, the 9th of Feb"
Date: 2026-02-09

Text: "Meeting moved to next Tues, the 14th of July"
Date:
An example teaches everything about itself, including quirks you did not intend to teach. If your one example happens to be unusually short, or handles a case you did not mean to generalize, the model will often copy that too. Two or three varied examples guard against this far better than one.

4. Ask for the steps, on problems that actually have steps

Chain-of-thought prompting means asking the model to work through intermediate reasoning before it gives a final answer, instead of jumping straight there. It matters because of what one forward pass actually is: one token predicted from everything before it. A hard, multi-step problem answered with no working shown is being asked to compress several logical hops into one leap, with no scratch space to do it in. Writing out the intermediate steps gives the model somewhere to put that work: each reasoning token becomes part of the context the next token conditions on, so the model builds its own scratch space one token at a time, instead of trying to leap straight to the answer.

This is not free, and it is not universal. On a simple factual lookup or a short rewrite, asking for step-by-step reasoning adds tokens without adding accuracy, because there is no multi-step structure to unpack in the first place. It earns its cost specifically on problems with real intermediate steps: arithmetic with several stages, logic puzzles, multi-part instructions. The paper that popularized the technique found the gain was consistent on that kind of task, and also found the effect showed up mainly in large, capable models; smaller models did not reliably benefit from being asked to show their work.3

Same question, one instruction added
Direct:
A store has 340 items. 17% are on clearance. Of the clearance
items, 12 are damaged and pulled from the shelves. How many
clearance items are left?

Step-by-step:
A store has 340 items. 17% are on clearance. Of the clearance
items, 12 are damaged and pulled from the shelves. How many
clearance items are left?

Work through this step by step, then give the final number.
Key idea
Step-by-step reasoning does not make a model smarter. It gives an already-capable model somewhere to do multi-step work in tokens, instead of forcing it into one impossible leap. Reach for it on problems with real steps, and skip it on ones that do not have any.

5. Assign a role, and know exactly what it does not do

A role instruction like "you are a senior security engineer" is more conditioning text, nothing more mystical than that. It works because "senior security engineer" is strongly associated, across the training data, with a certain vocabulary, certain priorities, and a certain level of scrutiny. Adding it to the prompt shifts the probability mass toward continuations carrying that register: the model becomes more likely to mention injection risks and unsafe defaults first, because that is what text near "senior security engineer" tends to talk about.

The limit follows directly from the mechanism. A role reweights which patterns the model draws on. It does not hand the model new facts, new training, or expertise it did not already have. Asking it to act as a doctor changes the vocabulary and framing of the answer; it does not grant medical judgment. Anthropic's own prompting documentation for Claude makes close to the same point from the vendor side: treat the model like a capable new employee who lacks your specific context, since the more precisely you spell out the situation, the better the result, a role included.1

Iterate: change one variable at a time

The first result from a prompt is rarely the final one, and that is fine: prompting is a short experiment, not a one-shot spell. The reason to change only one thing per attempt is not superstition either. Generation is stochastic, so the same prompt can sample a different path on different runs, and every part of a prompt is part of the same conditioning text feeding the same prediction. Rewrite the tone, the length, and the format in one edit, and if the new answer is better you cannot tell which change did it, which means you cannot repeat it on your next prompt without guessing again.

  1. 1DraftWrite the prompt, get a first result.
  2. 2TestCheck the result against what you actually needed.
  3. 3Change one thingAdjust a single variable: context, format, an example, the phrasing.
  4. 4CompareKeep the change only if the new result is actually better.
The iterate loop

Treat each attempt as a controlled comparison against the last one, not a fresh guess. A handful of passes through this loop, run this way, will teach you more about what a specific model responds to than any general list of tips, this one included.

Key idea
Specificity and context remove guesswork about the situation. A named format removes guesswork about the shape of the answer. Examples show a pattern instead of describing one. Step-by-step reasoning gives a hard problem room to work. A role reweights tone and priorities, not knowledge. None of it is persuasion. All of it is conditioning the same next-token prediction, one deliberate constraint at a time.
Going further: These five moves are not exclusive. A strong prompt often stacks several at once: a role to set tone, a named format for the output shape, two or three examples to lock in an exact pattern, and a request for step-by-step reasoning if the task has real steps. Each move narrows the model's next-token predictions along a different axis, so stacking them narrows the space faster than any one move alone.
Read next: the Prompting course walks through all five of these ideas as full lessons, with more worked examples and a quiz per lesson. If any of the vocabulary here, tokens, context window, temperature, is new, start with Using AI well in the AI Foundations course.

Sources

Verified against primary sources: August 2026.

  1. Prompting best practices. Anthropic, Claude Docs. https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices
  2. Language Models are Few-Shot Learners. Brown et al., arXiv:2005.14165. https://arxiv.org/abs/2005.14165
  3. Chain-of-Thought Prompting Elicits Reasoning in Large Language Models. Wei et al., arXiv:2201.11903. https://arxiv.org/abs/2201.11903
Read nextWhat an AI agent actually is