How to Write Better Prompts: 12 Patterns with Before and After Examples
Twelve patterns that OpenAI, Anthropic and Google recommend in their own prompting guides, each with a short before and after you can adapt for work.
To write better prompts, give the model what a smart new colleague would need on their first day: one clear task, the background it cannot guess, who the answer is for, the format and length you want, and an example of good output. Most weak answers come from missing context, not from missing magic words.
That advice is not folklore. It runs through the prompting guides that OpenAI, Anthropic and Google publish for their own models. The 12 patterns below are drawn from those guides, as of October 2026, and each one has a short before and after.
The 12 patterns at a glance
Which vendor guides recommend each pattern (October 2026)
| Pattern | OpenAI | Anthropic | |
|---|---|---|---|
| 1. Lead with a verb and one task | Yes | Yes | Yes |
| 2. Give the context it cannot guess | Yes | Yes | Yes |
| 3. Explain why a rule matters | โ | Yes | โ |
| 4. Set audience, format and length in numbers | Yes | Yes | Yes |
| 5. Show an example of good output | Yes | Yes | Yes |
| 6. Separate instructions from material | Yes | Yes | Yes |
| 7. Say what to do, not only what to avoid | Yes | Yes | โ |
| 8. Long documents first, question last | Context last | Yes | Yes |
| 9. Give a role when it changes the answer | Yes | Yes | Yes |
| 10. Split big jobs into a chain | โ | Yes | Yes |
| 11. Ask for a check against your criteria | โ | Yes | โ |
| 12. Write calmly, without capitals and threats | โ | Yes | Yes |
A dash means the current guide does not make that point, not that it advises against it.
Patterns 1โ4: say exactly what you want
1. Lead with a verb and one clear task
Google's Workspace prompting guide calls the verb "the most important part of a prompt". OpenAI's help center tells you to be "specific, descriptive and as detailed as possible about the desired context, outcome, length, format, style".
Before: Something about the pricing change for customers.
After: Write a 150-word email telling current customers that the Team plan price changes on 1 March, why it changes and what they can do before then.
2. Give the context it cannot guess
Anthropic puts it best: "Think of Claude as a brilliant but new employee who lacks context on your norms and workflows." Paste the material instead of describing it, and add the facts nobody wrote down.
Before: Write a reply to this customer complaint.
After: Write a reply to the complaint below. The customer was charged twice because of a bug we fixed yesterday. The refund is already issued and arrives in 5 to 10 business days. We cannot offer credit beyond the refund. [complaint]
3. Explain why a rule matters
Anthropic's guide says giving "context or motivation behind your instructions" helps the model understand your goal. Its own example replaces "NEVER use ellipses" with the reason: the text is read aloud by a text-to-speech engine. A model that knows the reason also handles the cases your rule did not mention.
Before: Never use abbreviations.
After: Spell out abbreviations, because this page is read by people new to finance and by screen readers.
4. Set the audience, format and length in numbers
OpenAI's help article warns against "fluffy" descriptions and gives this pair: "fairly short, a few sentences only" becomes "Use a 3 to 5 sentence paragraph". Google's guide lists response format next to constraints as part of a clear instruction.
Before: Explain our churn numbers, keep it fairly short.
After: Explain the churn numbers below to our CEO, who has two minutes. Use three bullet points of one sentence each, then one sentence on what we should do next.
Patterns 5โ8: structure the prompt
5. Show an example of good output
All three vendors recommend examples. Anthropic suggests "3โ5 examples for best results", wrapped in example tags. Google says to "always include few-shot examples" and to keep their format consistent. OpenAI asks for "a diverse range of possible inputs with the desired outputs".
Before: Write taglines for our invoicing app.
After: Write five taglines for our invoicing app. Match the tone and length of these two: "Send the invoice. Skip the chase." and "Get paid before the coffee cools."
6. Separate instructions from your material
OpenAI's help article suggests ### or """ to separate instructions from context, and its API guide adds Markdown headings and XML tags. Anthropic says that wrapping each kind of content in its own tag "reduces misinterpretation". Google recommends XML or Markdown delimiters, used consistently.
Before: summarize this and make it friendly the notes are we agreed to move launch to May, Sam owns QA...
After:
<instructions>
Summarize the meeting notes in five bullet points for people who missed the call.
List decisions first, then open questions with an owner for each.
</instructions>
<notes>
[paste the notes here]
</notes>7. Say what to do, not only what to avoid
OpenAI's rule is "Instead of just saying what not to do, say what to do instead". Anthropic's version turns "Do not use markdown" into "Your response should be composed of smoothly flowing prose paragraphs." A ban leaves the model guessing what you want in its place.
Before: Don't use jargon. Don't make it long.
After: Use words a new customer would know, and keep it under 120 words.
8. Put long documents first and the question last
For long inputs, Anthropic says to place documents "near the top of your prompt, above your query, instructions, and examples", and reports that queries at the end "can improve response quality by up to 30 percent in tests". Google's guide for its current models says to supply all the context first and put the question "at the very end".
OpenAI's API guide orders things differently: instructions and examples first, with context "usually best positioned near the end". A layout that works with all three is short instructions first, the document in tags, then the precise question again at the end.
<task>You will answer a question about the contract below.</task>
<contract>
[40 pages of contract text]
</contract>
Based on the contract above, list every clause that lets either side end the
agreement early, with the clause number and a one-line summary.Patterns 9โ12: guide how the work gets done
9. Give a role when it changes the answer
Anthropic says a role in the system prompt focuses tone and behavior, and that "even a single sentence makes a difference". Google's Workspace guide starts its framework with persona, and OpenAI's guide opens a developer message with an identity section. A role helps most when it changes the viewpoint, not when it only adds "expert".
Before: You are an expert. Review my cover letter.
After: You are a recruiter who screens a few hundred applications a week for product roles. Review my cover letter and tell me what you would skip after the first ten seconds.
10. Split big jobs into a chain of prompts
Google's guide suggests you "make each step a prompt and chain the prompts together". Anthropic keeps chaining for cases where you "need to inspect intermediate outputs". You check each step before the next one builds on it.
Before: Read these 30 customer interviews, find the themes, write a report and suggest a roadmap.
After:
- List every problem mentioned in each interview, with a short quote and the interview number.
- Group the problems from that list into themes and count how many interviews mention each.
- Draft a one-page report from the themes, most frequent first.
11. Ask for a check against your criteria
Anthropic suggests ending with something like "Before you finish, verify your answer against [test criteria]." Named criteria give the model, and you, a concrete test.
Before: Write a SQL query for monthly revenue.
After: Write a PostgreSQL query for monthly revenue from the orders table. Before you finish, check that it excludes refunded orders, groups by calendar month in UTC and returns one row per month.
12. Write calmly, without capitals and threats
Anthropic's guide says newer models respond well to plain instructions: where you once wrote "CRITICAL: You MUST use this tool when...", write "Use this tool when...". Google's guide says to avoid "unnecessary or overly persuasive language". Shouting can make a model apply a rule too often.
Before: CRITICAL!!! You MUST ALWAYS answer in JSON. NEVER add any other text.
After: Reply with JSON only, matching the schema below, because a script reads your answer.
If you call a model through an API, its structured-output feature enforces a JSON schema more reliably than any wording.
Prompt reasoning models with goals, not scripts
Reasoning models plan before they answer, and the guides adjust their advice for them. OpenAI compares a reasoning model to "a senior co-worker" you can give a goal and trust with the details, and a GPT model to "a junior coworker" that needs explicit instructions. Anthropic notes that "think thoroughly" often beats a hand-written step-by-step plan. Google says it is generally not necessary to have its models spell out reasoning steps in the answer.
In practice: for a reasoning model, describe the goal, the constraints and how you will judge the result, then let it work. Keep step-by-step instructions for fast, non-reasoning models and for workflows where the order of steps matters to you.
Test a prompt before you rely on it
Anthropic's overview lists three things to have before you tune a prompt: success criteria, a way to test against them and a first draft. You do not need an evaluation suite to borrow the idea.
- Write down what a good answer must contain, in two or three checkable lines.
- Collect five real inputs, including one awkward one.
- Run the prompt on all five and mark each answer against your lines.
- Change one thing at a time, and keep the version that scores best.
Long prompts with pasted documents eat into the model's context window. Check the size with the Token Counter, and see tokens and context windows explained for why a long chat starts to "forget".
Build a structured prompt in a minute
Most of these patterns fit one template: role, task, context, audience, format, constraints and an example. The AI Prompt Builder gives you a field for each, lets you choose labeled sections, XML tags or plain sentences, and counts the [placeholders] you have not filled in yet. It only arranges your words; it does not call a model, so you can paste the result into any assistant.
AI Prompt Builder Build a clear prompt from role, task, context and format, or start from a template.Try the patterns in the assistants whose guides they come from, or run one prompt on several models to compare the answers:
For pictures rather than text, the vocabulary is different: see how to write image prompts.
FAQ
How long should a prompt be?
As long as the context requires. In the 2024 edition of its Workspace prompting guide, Google reported that the most fruitful prompts averaged around 21 words with relevant context, while most prompts people tried were under nine words. A pasted document can make a good prompt much longer.
Do I need to start with "Act as an expert"?
No. A role helps when it sets a specific viewpoint or vocabulary, such as a recruiter or a tax accountant. A clear task and real context matter more.
Do the same prompts work in ChatGPT, Claude and Gemini?
Mostly, yes. All three vendors recommend clear tasks, context, examples and a stated format. Details differ: Anthropic leans on XML tags, and its newest models no longer accept a prefilled start of the answer through the API.
Should I still write "think step by step"?
For reasoning models, usually not. The vendors suggest stating the goal and criteria and letting the model plan. For fast models on multi-step problems, asking for steps can still help.
Why does the same prompt give different answers?
Models sample their output, so some variation is normal. Examples, a fixed format and explicit criteria narrow it down.