Prompt engineering is the practice of writing instructions that get a language model to produce the output you need, reliably. A good prompt states the task, gives the context and source material, shows 3 to 5 examples of the desired result, specifies the output format and says how success is judged. Then you test it on real cases and change one thing at a time.
Key points
- OpenAI, Anthropic and Google all recommend the same core moves: clear instructions, examples, delimiters such as XML tags or Markdown headings, and context placed deliberately.
- Examples move output more than adjectives. Anthropic's documentation suggests 3 to 5 varied examples; Google's says to always include few-shot examples.
- Reasoning models think before answering on their own. Give them the goal and the criteria instead of telling them to "think step by step".
- With long documents, put the material first and the question last, and ask the model to quote the relevant passages before answering.
- Treat important prompts like code: a test set, a version number, a named owner and a re-test whenever the model changes.
What is prompt engineering?
Prompt engineering is writing and testing the instructions you give a large language model (LLM) so that its output is accurate, consistently formatted and useful for a specific job. For a marketer in ChatGPT it means a well-built request. For a team building an automation, it means a tested set of instructions that runs thousands of times without supervision.
Two kinds of instruction matter. The system prompt (OpenAI calls it the developer message) holds the standing rules: who the assistant is for, what it must and must not do, the format. In chat tools you set it through custom instructions, ChatGPT Projects, Claude Projects or Gemini Gems. The user prompt holds the specific request and its material. OpenAI's documentation compares the two to a function definition and its arguments, and gives developer instructions priority over user messages.
What goes into a good prompt?
A good prompt contains six parts: context, task, input material, examples, output format and success criteria. Not every prompt needs all six, but when output disappoints, one of them is usually missing.
| Part | What it does | Example line |
|---|---|---|
| Context and audience | Tells the model who the output is for and why | "You write for operations managers at Nordic logistics firms who skim on mobile." |
| Task | One clear verb and object | "Write three subject lines for the newsletter below." |
| Input material | The facts the model must use, so it does not invent them | "Use only the product notes inside <notes> tags." |
| Examples | Shows tone, length and structure better than description can | "Here are four subject lines that performed well: …" |
| Output format | Makes the result usable without cleanup | "Return a table with columns: subject line, characters, angle." |
| Success criteria and constraints | Defines what good means and what to avoid | "Under 45 characters. No exclamation marks. Each line uses a different angle." |
Give the reason behind a rule as well as the rule. Anthropic's documentation notes that explaining why a behaviour matters helps the model aim its response. "Keep it under 45 characters because mail apps on phones cut off longer subject lines" works better than "keep it short", because the model can apply the reason to cases the rule does not cover.
Phrase instructions as what to do, not what to avoid. "Write in flowing paragraphs" works better than "don't use bullet points", a pattern Anthropic's guide recommends explicitly.
How do examples improve AI output?
Examples improve output because they show the model the target instead of describing it, a technique called few-shot or multishot prompting. Anthropic calls examples one of the most reliable ways to steer format, tone and structure and suggests 3 to 5 for best results. Google's Gemini guide goes further and recommends always including few-shot examples, with consistent formatting across them.
Three rules make examples work. Vary them, so the model learns the pattern and not one surface feature; OpenAI's guide asks for "a diverse range of possible inputs with the desired outputs". Wrap them in tags such as <example> so the model can tell them apart from instructions. And do not overdo it: Google warns that too many examples can make the model copy them too closely. If all your examples open with a question, so will the output.
Do you still need to tell AI to think step by step?
For current reasoning models you usually do not, because they reason internally before answering. Chain-of-thought prompting, asking a model to show its reasoning, was a major finding in 2022: Wei and colleagues at Google showed that eight worked examples with written-out reasoning let a 540-billion-parameter model reach state-of-the-art accuracy on the GSM8K maths benchmark.
Models now do that work themselves. Google's documentation says Gemini 2.5 and 3 models reason internally, so prompts rarely need to ask for steps. OpenAI advises giving reasoning models high-level goals, like a senior colleague, and giving faster GPT models precise, explicit instructions, like a junior one. Anthropic recommends relying on the built-in thinking setting for its newest models and keeping manual "think first, then answer in <answer> tags" prompting as a fallback when thinking is switched off. In practice, ask for step-by-step reasoning only when you use a fast model on a multi-step problem, and turn up the reasoning setting instead when the tool offers one.
How should you prompt with long documents?
Put the long material first and the question and instructions last, and ask the model to pull out the relevant quotes before answering. Anthropic's guide recommends placing long documents near the top of the prompt, above the query and instructions, and Google's guidance for Gemini 3 likewise places specific instructions at the end of long contexts.
- Label each document. Wrap each file in tags with its source, for example <document><source>Q3 board report</source>…</document>, so the answer can say where a claim came from.
- Quote first. Ask for the passages that answer the question inside <quotes> tags, then for the answer based only on those quotes. This cuts invented details and makes checking fast.
- Say what to do when the answer is missing. "If the documents do not contain the answer, say so" prevents the model from filling gaps from general knowledge.
Grounding in your own material is also the main defence against invented statistics in content work, a problem we cover in our guide to AI content production.
Example
A fictional hotel in Bergen wants a monthly newsletter intro. The first attempt reads: "Write a fun newsletter intro about our autumn offers." The output is generic, mentions a spa the hotel does not have and runs to 180 words.
The rebuilt prompt sets context ("Readers are past guests, mostly couples from Oslo and Stavanger, reading on their phones"), gives the material inside <offers> tags (two-night package, fish soup menu from 15 October, harbour-view rooms), pastes three intros from earlier newsletters that had good click rates as examples, asks for "one paragraph of 50 to 70 words, then one sentence that links to the offer", and adds the rule "mention only facilities listed in <offers>, because readers who arrive expecting something we lack leave bad reviews". Run on five months of material, the new prompt produced on-length intros with no invented facilities in all five, and the editor's changes dropped to a word or two. The hotel saves it as a template with the date and the model it was tested on.
How do you test and improve a prompt?
Test a prompt against a fixed set of real cases and a written definition of a good answer, then change one element at a time. Anthropic's documentation puts this before any prompt writing: have success criteria, a way to test against them, and a first draft. OpenAI recommends building evaluations and pinning production applications to a specific model snapshot so behaviour does not shift under you.
- Write the success criteria. Concrete and checkable: "classifies the email into one of six categories", "under 160 characters", "no claims that are not in the source".
- Collect 20 to 50 test cases. Real inputs, including awkward ones: angry customers, mixed languages, missing information.
- Run and score. Run the prompt on every case and mark each output pass or fail against the criteria. A spreadsheet is enough.
- Change one thing. Add an example, move the instructions, tighten a constraint. Re-run all cases, not only the ones that failed.
- Record the version. Save the prompt with a version number, date, model and pass rate. Re-run the test set when the vendor updates the model.
Prompting is not always the fix. Anthropic notes that some problems, such as latency and cost, are often solved more easily by choosing a different model. If a model keeps failing on a task after several rounds, try another model before writing a longer prompt; we compare the main options in ChatGPT vs Claude vs Gemini.
What are the most common prompt mistakes?
The most common mistakes are vague goals, missing source material and asking for too much in one go. Each has a simple fix.
| Mistake | What happens | Fix |
|---|---|---|
| Adjectives instead of criteria ("make it engaging") | The model guesses, usually towards generic marketing tone | Give examples and measurable limits |
| No source material | Invented facts, prices, features and statistics | Paste the facts and say "use only these" |
| Five tasks in one prompt | Some tasks are skipped or done badly | Split into a chain: research, outline, draft, review |
| Only negative rules ("don't be salesy") | The model fixates on the banned behaviour | Describe the wanted behaviour instead |
| Testing on one input | The prompt fails on the next real case | Keep a test set of 20 or more cases |
| Pasting confidential data into a personal account | Data handled under consumer terms | Use a business plan; see our AI tools guide |
How do you build a prompt library for a team?
Build a prompt library by storing tested prompts where people already work, with an owner, a version and a short note on when to use each one. A shared document goes stale within weeks; prompts stored as ChatGPT Projects or custom GPTs, Claude Projects or Gemini Gems are used because they are one click away.
Start with the five tasks your team repeats most, such as ad variants, meeting summaries, customer replies, briefs and reports. For each, save the system instructions, two or three examples, the test set and the date it was last checked. Name one owner per prompt who updates it when results slip or the model changes. Our guides to ad copy writing and AI in email marketing include task-specific examples you can adapt. Prompts that run inside automated workflows need the strictest version control, because nobody reads their output before it moves on, as described in our AI automation guide. If you want your team trained on this method with your own tasks, see our AI training service.
Frequently asked questions
Is prompt engineering still needed with newer AI models?
Yes, though the emphasis has changed. Newer models need fewer tricks such as "think step by step", but they still need context, source material, examples and a clear definition of a good result. Those parts decide whether output is usable in a business process.
What is the difference between a system prompt and a user prompt?
The system prompt sets standing rules for every conversation, such as role, tone, format and limits. The user prompt is the individual request with its material. Vendors give system or developer instructions higher priority, so put rules that must always hold there.
How long should a prompt be?
As long as it needs to be to include the context, material, examples and criteria, and no longer. A reusable business prompt with examples is often several hundred words. Length is not the problem; vague or contradictory instructions are.
What is few-shot prompting?
Few-shot prompting means including a few examples of input and desired output in the prompt so the model copies the pattern. Anthropic suggests 3 to 5 varied examples, wrapped in tags so they are not confused with instructions.
Do prompts work the same in ChatGPT, Claude and Gemini?
The core techniques transfer, but each model responds differently to the same wording, and vendors update models regularly. Test your important prompts on the model you will actually use, and re-test when it changes.



