Guide
What Is Prompt Engineering?
A plain-English guide to prompt engineering: what it is, what a good prompt contains, which techniques the AI vendors recommend, how reasoning models changed chain-of-thought prompting, context engineering, prompt injection, and whether it is still a job.
Quick answer: Prompt engineering is the practice of writing and structuring the input you give an AI model so that it produces the output you want, reliably. It still matters, but the advice has changed. The prompting guides that OpenAI, Anthropic and Google publish for the models behind ChatGPT, Claude and Gemini ask for plain, direct instructions, and put the weight on clear goals, the right background material and, where tone or format matters, good examples. Chain-of-thought prompting, the “let’s think step by step” technique, shows the change: it lifted one 2022 model from 17.7% to 78.7% on a maths benchmark, but in a 2025 test Wharton researchers found it added little or nothing on reasoning models, which already think before they answer. The part that has not changed is the context: the instructions, examples and documents the model is given. Anthropic calls the work of choosing them context engineering, “the natural progression of prompt engineering” (Anthropic).
Definition: Prompt engineering is the craft of designing the instructions, examples, background information and output format given to an AI model so that its answers are accurate, consistent and useful. For everyday users it means asking clearly. For developers it means writing, testing and versioning the system prompts that sit behind AI products.
This page is the explainer: what prompt engineering is, what the vendors recommend and what has changed. For tools that write prompts for you, see best AI prompt generators. For pay and job prospects, see prompt engineer salary. For the models the prompts go into, see what is an LLM, and for one-line definitions of the surrounding vocabulary, see the AI glossary.
What is prompt engineering?
Prompt engineering is the work of shaping what goes into an AI model so that what comes out is right. A prompt is the full input a model receives for one turn, and prompt engineering is deciding what that input contains, in what order and in what form.
A language model has no idea what you want beyond what the prompt tells it. It predicts the most plausible response to the text in front of it, so a vague prompt gets a generic answer and a specific prompt gets a specific one. Anthropic’s prompting guide puts the test simply: show your prompt to a colleague with minimal context on the task, and “if they’d be confused, Claude will be too.”
What goes into a prompt
Most well-built prompts, whether typed into a chatbot or written into an app, are made of the same handful of parts.
| Part | What it does | Example |
|---|---|---|
| Instruction | States the task and the goal | ”Summarise this contract for a non-lawyer” |
| Context | Gives the background the model cannot know | Who the reader is, what the summary is for, what has already been decided |
| Examples | Shows the pattern you want rather than describing it | Two or three sample summaries in the style you like |
| Input data | The material the model works on | The contract itself |
| Constraints | Sets limits | ”Under 200 words; flag anything about termination” |
| Output format | Says what shape the answer should take | A table, bullet points, JSON, a single paragraph |
Not every prompt needs every part. A quick question needs only the instruction. A prompt that runs thousands of times inside a product usually needs all six.
System prompts vs user prompts
AI apps split the prompt into two layers. The system prompt is the standing instruction set written by whoever built the app: the model’s role, rules, tone and available tools. The user prompt is what you type. OpenAI’s API calls the first layer a developer message, and its reasoning guide says its reasoning models take developer messages in place of system messages. When you set custom instructions in ChatGPT, or a Gem in Gemini, you are writing a small system prompt of your own.
Does prompt engineering still matter?
Yes, but the advice has changed. The vendors’ guides advise against several habits written for older models, while clear goals and the right context appear in all three.
Plain instructions work. Anthropic’s guide says Claude Opus 4.5 and Claude Opus 4.6 respond more closely to the system prompt than earlier models, so prompts written to stop older models under-using a tool may make them over-use it. Where you might once have written “CRITICAL: You MUST use this tool when…”, it suggests “more normal prompting such as ‘Use this tool when…’”. Google’s Gemini prompting guide says Gemini 3 models respond best to prompts that are “direct, well-structured, and clearly define the task”. OpenAI’s reasoning guide advises keeping prompts “simple and direct”.
Step-by-step prompting adds little on reasoning models. Chain-of-thought prompting was introduced in 2022. On the reasoning models the Wharton Generative AI Labs report tested in 2025, it added “only marginal, if any” gains while making requests take 20% to 80% longer (see the chain-of-thought section below).
Formatting can swing results. A study by Melanie Sclar and colleagues (ICLR 2024) found that subtle formatting changes to a few-shot prompt, such as separators and spacing, produced “performance differences of up to 76 accuracy points” on Meta’s LLaMA-2-13B, and that the sensitivity remained with larger models, more examples and instruction tuning. It is the reason prompts are worth testing rather than guessing.
What changed, and what didn’t
| Old habit | What the vendors advise | Source |
|---|---|---|
| ”Think step by step” on every hard question | Let reasoning models reason; ask for step-by-step reasoning when thinking is switched off | Wharton, OpenAI, Anthropic |
| CAPITALS, “CRITICAL”, “you MUST” | Normal wording; Anthropic advises softening aggressive language | Anthropic |
| ”NEVER do X” | Say what to do instead, and why | Anthropic |
| Long, elaborate prompt templates | A minimal prompt first, then instructions and examples for the failures you see | Anthropic |
| Clear goal, the right documents, examples | Still recommended; OpenAI suggests trying its reasoning models without examples first | OpenAI, Anthropic, Google |
Prompt engineering techniques that still work
These techniques come from the prompting guides that OpenAI, Anthropic and Google publish for their models; the last column says which guides recommend each one. None of them is a trick. Each one gives the model information it would otherwise have to guess.
| Technique | What it means | When it helps most | Recommended by |
|---|---|---|---|
| Be clear and specific | State the task, the goal and what a good answer looks like | Always | OpenAI, Anthropic, Google |
| Explain why | Give the reason behind a rule, not just the rule | Any rule the model might apply too rigidly or too loosely | Anthropic |
| Give examples (few-shot) | Show a few sample inputs and outputs | Tone, format and classification tasks | Anthropic, Google; OpenAI suggests trying its reasoning models without them first |
| Separate the parts | Mark instructions, documents and examples with headings, XML-style tags or other delimiters | Long prompts and prompts with pasted material | OpenAI, Anthropic, Google |
| Put long documents first | Paste the material at the top and ask the question at the end | Questions about long reports, contracts or code | Anthropic, Google |
| Specify the output format | Ask for a table, list, word limit or JSON schema | Anything you will reuse, paste or parse | Anthropic, Google |
| Give the model a role | One line on who it is and who it is writing for | Expert or audience-specific answers | Anthropic, Google |
| Break big jobs into steps | Run one prompt per stage and feed each result into the next (prompt chaining) | Multi-stage work such as research, then outline, then draft | Anthropic, Google |
| Ask for quotes | Have the model quote the passages it relied on before answering | Reducing hallucinations on document questions | Anthropic |
Be clear, and explain why
Anthropic’s own example is the clearest illustration. An instruction that says “NEVER use ellipses” is less effective than telling the model its response will be read aloud by a text-to-speech engine, which will not know how to pronounce them, because “Claude can generalize from the explanation.” The model can then avoid other things a speech engine would stumble over, without being told.
Examples: the vendors disagree on how many
All three vendors mention examples, but they disagree on when to use them.
- Google is the most emphatic: “We recommend to always include few-shot examples in your prompts,” and prompts without them “are likely to be less effective” (Google).
- Anthropic calls examples “one of the most reliable ways to steer Claude’s output format, tone, and structure”, and advises “3–5 examples for best results”, wrapped in example tags and varied enough that the model does not pick up unintended patterns (Anthropic).
- OpenAI says its reasoning models often do not need examples and suggests writing prompts without them first; if you add examples, they must match your instructions closely (OpenAI).
Read together, the guides treat examples as most useful for tone, format and structure, and OpenAI treats them as optional for its reasoning models.
Long documents go at the top
For prompts that include long material, Anthropic recommends putting the documents at the top and the question at the end, and says queries placed at the end “can improve response quality by up to 30 percent in tests, especially with complex, multidocument inputs.” That figure is Anthropic’s own, from its own testing. Google gives the same advice for Gemini 3: “supply all the context first” and put the question at the end.
Settings: leave the sampling settings alone
Temperature controls how often a model picks less likely words. Google’s guide says Gemini 4 and Gemini 3.6 and later models ignore custom temperature, top-p and top-k values, and advises keeping them at their defaults on earlier Gemini 3 models “to avoid degraded reasoning performance” (Google).
Chain of thought prompting
Chain-of-thought prompting is asking a model to write out its reasoning step by step before giving a final answer. Researchers introduced it in 2022, and reasoning models have since built it in.
Where it came from
A Google Research team led by Jason Wei introduced chain-of-thought prompting in a paper first posted on 28 January 2022. They gave a 540-billion-parameter model “just eight chain of thought exemplars”, worked examples that included the reasoning, and it reached what was then state-of-the-art accuracy on the GSM8K benchmark of school maths word problems, “surpassing even finetuned GPT-3 with a verifier.”
Four months later, a team led by Takeshi Kojima found that no examples were needed at all. Adding the phrase “Let’s think step by step” before the answer raised OpenAI’s text-davinci-002 from 17.7% to 78.7% on the MultiArith benchmark and from 10.4% to 40.7% on GSM8K (Kojima et al., first posted 24 May 2022).
A follow-up technique, self-consistency, samples several different reasoning paths and takes the most common final answer. Its authors, led by Xuezhi Wang and including several of the chain-of-thought paper’s Google authors, reported a 17.9% gain on GSM8K over standard chain-of-thought prompting (Wang et al., first posted 21 March 2022).
Why reasoning models changed it
A reasoning model is trained to think through a problem before it answers, so chain of thought is built in rather than prompted. OpenAI released its first reasoning model, o1-preview, on 12 September 2024. Google’s guide says Gemini 2.5 and 3 series models generate internal “thinking” text, and Anthropic’s describes extended and adaptive thinking for Claude (see what is an LLM for how reasoning models work).
The Wharton Generative AI Labs report by Lennart Meincke, Ethan Mollick and colleagues (June 2025) tested chain-of-thought prompts on GPQA Diamond, a set of 198 PhD-level multiple-choice questions in biology, physics and chemistry, asking each question 25 times per condition.
| Model type | Effect of asking for step-by-step reasoning | Extra time per request |
|---|---|---|
| Non-reasoning models (including GPT-4o and Claude 3.5 Sonnet) | Average scores generally rose against a prompt telling the model to answer directly. Against no instruction at all, the gain was much smaller, because many models already reasoned step by step unprompted. In three of the five models, it also caused errors on questions the model otherwise got right | 35% to 600% longer |
| Reasoning models (o3-mini, o4-mini, Gemini 2.5 Flash) | “Only marginal, if any” gains: o3-mini and o4-mini improved slightly on average, and Gemini 2.5 Flash scored slightly lower | 20% to 80% longer |
The vendors say the same thing:
- OpenAI’s reasoning guide says prompting its reasoning models to “think step by step” or “explain your reasoning” is unnecessary, because they reason internally, and that such prompts can sometimes hinder performance (OpenAI).
- Google says Gemini 2.5 and 3 series models “automatically generate internal ‘thinking’ text”, so “it’s generally not necessary” to ask the model to outline or plan its reasoning in the response (Google).
- Anthropic advises that, with thinking on, a general instruction such as “think thoroughly” often produces better reasoning than a hand-written step-by-step plan, and gives asking Claude to think through the problem before it answers as the fallback for when thinking is off (Anthropic).
When chain-of-thought prompting is still useful
- On models with thinking off. The Wharton report concludes that a simple chain-of-thought prompt is “generally still a useful tool” for non-reasoning models, “especially older or smaller models” that do not reason by default. Anthropic gives it as the fallback for Claude with thinking switched off.
- When you want to check the working. Asking for the steps makes an answer easier to audit. Keep in mind that a visible chain of thought is text the model generated, not a reliable record of how it reached the answer (see chain of thought in the glossary).
- When a task has a required procedure. If the answer must follow set steps, such as a checklist or a house calculation method, the prompt has to state them, because the model cannot know them otherwise.
Prompting terms you will see
| Term | What it means |
|---|---|
| Zero-shot prompting | Asking for a task with no examples |
| One-shot and few-shot prompting | Including one or a handful of worked examples in the prompt; OpenAI’s GPT-3 paper (28 May 2020), “Language Models are Few-Shot Learners”, used “few-shot” for a model given a few demonstrations of a task in its prompt, with no retraining |
| Chain-of-thought prompting | Asking the model to reason step by step before answering |
| Self-consistency | Sampling several reasoning paths and taking the majority answer |
| Role prompting | Telling the model who it is and who it is writing for |
| System prompt | The standing instructions set by an app’s builder, applied before every user message |
| Prompt chaining | Splitting a job into a sequence of prompts, each using the last one’s output |
| Prefill | Writing the first words of the model’s reply for it to continue; Anthropic stopped supporting prefill on the last assistant turn starting with its Claude 4.6 models (Anthropic) |
| Meta-prompting | Asking a model to write or improve a prompt for you |
| Context engineering | Curating everything in the model’s context window, not just the instructions (see below) |
| Prompt injection | An attack that hides instructions in content the model reads (see below) |
From prompt engineering to context engineering
Context engineering is the practice of deciding everything a model sees when it works: instructions, documents, search results, tool descriptions, conversation history and memory. Prompt engineering is usually treated as one part of it.
Andrej Karpathy backed the term over “prompt engineering” in June 2025, describing context engineering as “the delicate art and science of filling the context window with just the right information for the next step”, as Drew Breunig recorded at the time. On 29 September 2025, Anthropic published a guide to context engineering for AI agents that calls it “the natural progression of prompt engineering.”
Anthropic’s guide makes three points that apply well beyond agents:
- Less, but better. The goal is “the smallest possible set of high-signal tokens” that gets the job done. Anthropic says a model has an “attention budget”, and every new token depletes it by some amount.
- The right altitude. A system prompt should sit between brittle, hard-coded rules for every case and vague guidance that assumes the model shares your background.
- Start minimal. Test a minimal prompt with the best model available first, then add instructions and examples to fix the failures you observe.
The guide also explains why more is not always better. As the number of tokens in the context window grows, a model’s ability to recall information from that context falls, an effect it calls context rot. Adding everything available is not the same as giving the model what it needs.
For everyday users, context engineering is less abstract than it sounds. Custom instructions, saved memory, project folders with reference files and connected apps are all ways of giving a chatbot standing context so you do not have to repeat it in every prompt. For developers, it covers retrieval-augmented generation (RAG), which fetches relevant documents into the prompt, and the Model Context Protocol (MCP), which connects models to tools and data. Both are building blocks of agentic AI.
How to write a better prompt: a quick method
For anyone using a chatbot, five habits put the vendors’ advice into practice.
- Say what the result is for. “Write an email” becomes “Write a short email to a client explaining a two-week delay; they are annoyed, and I want to keep the account.”
- Give the background the model cannot know. Paste the relevant document, the earlier thread or the numbers. The model cannot read your mind or your inbox unless you connect it.
- Show an example if style matters. Paste one or two pieces you like and say “match this tone and length.”
- Say what shape you want back. A table, three options, a word limit, plain text with no headings.
- Iterate in the same conversation. Treat the first answer as a draft: tell the model what to change and why.
Before and after
| Before | After |
|---|---|
| ”Give me some marketing ideas." | "I run a two-person bakery in a commuter town. Suggest five low-cost marketing ideas for weekday mornings, each with a rough cost in dollars and one sentence on why it suits commuters. Put them in a table.” |
The second prompt contains no tricks. It gives the model the goal, the context, the constraint and the format.
If you would rather have the model write the prompt for you, ask it: describe what you want, ask what a good brief would need, answer its questions and have it draft the prompt. That works in any major chatbot, including on free plans.
Prompt engineering for developers
Inside a product, a prompt behaves like code: it runs thousands of times, and a change to it needs testing like any other change.
- Define success first. Anthropic’s prompt engineering overview assumes you already have “a clear definition of the success criteria for your use case” and a way to test against it before you start tuning. It also notes that not every success criterion or failing eval “is best solved by prompt engineering”: latency and cost, for example, are sometimes easier to improve by choosing a different model.
- Test against a fixed set of cases. Run each prompt change against the same test cases and score the results. The Sclar study’s 76-point swings from formatting alone are the argument for doing this.
- Re-tune when you change models. Prompts written for one model generation can misfire on the next. Anthropic’s guide says Claude Opus 4.5 and 4.6 may over-trigger on tool instructions written to stop older models under-using them, and advises softening aggressive language. OpenAI’s guide to its GPT-6.2 models (GPT-6.2 Astra and GPT-6.2 Sol) says to revisit instructions such as “be concise”, because their writing is more concise and direct by default.
- Use structured output for machine-readable answers. Google recommends its structured output feature for complex JSON rather than describing the schema in the prompt (Google); OpenAI and Anthropic offer equivalents.
- Set reasoning effort deliberately. Reasoning models let developers choose how hard the model thinks; OpenAI suggests starting a new GPT-6.2 integration at medium effort (OpenAI). Higher effort costs more and takes longer.
For coding work specifically, where the same principles apply to briefing AI coding agents, see best AI for coding and vibe coding.
Prompt injection: the security side of prompts
Prompt injection is an attack in which instructions hidden inside content a model reads, such as a web page, an email or a document, take over its behaviour. The OWASP Foundation ranks it first, LLM01, in its 2025 Top 10 risks for LLM applications.
OWASP distinguishes two kinds:
- Direct prompt injection, where a user’s own input changes the model’s behaviour.
- Indirect prompt injection, where the model takes in external content, such as a website or file, that carries hidden instructions.
OWASP says that “it is unclear if there are fool-proof methods of prevention for prompt injection.” Its recommended mitigations include constraining what the model is allowed to do and requiring human approval for high-risk actions. Those mitigations matter most for AI agents: an agent that browses the web or reads a mailbox takes in untrusted text while holding access to your accounts, and a carefully written system prompt does not stop injected instructions on its own.
Is prompt engineering a job?
Prompt engineer exists as a job title, and writing and testing prompts is also part of broader roles such as AI engineer and AI product manager. For what those roles pay and how demand has moved, see prompt engineer salary; for the wider map of AI careers, see AI career paths.
For people who use AI without building it, prompting is part of using the tools well, much as writing a clear brief is part of delegating. For structured training, see best AI courses.
A short history of prompt engineering
| Date | Event |
|---|---|
| 28 May 2020 | OpenAI’s GPT-3 paper, “Language Models are Few-Shot Learners”, shows a model can do a task from a few examples in its prompt, with no retraining |
| 28 January 2022 | Google researchers post the chain-of-thought prompting paper |
| 21 March 2022 | Researchers led by Xuezhi Wang post self-consistency, sampling several reasoning paths and taking the majority answer |
| 24 May 2022 | Kojima and colleagues show “Let’s think step by step” works with no examples |
| 30 November 2022 | OpenAI launches ChatGPT |
| 17 October 2023 | Sclar and colleagues post evidence that formatting alone can swing accuracy by up to 76 points |
| 12 September 2024 | OpenAI releases o1-preview, its first reasoning model |
| June 2025 | Andrej Karpathy backs “context engineering”; Wharton publishes The Decreasing Value of Chain of Thought in Prompting |
| 29 September 2025 | Anthropic publishes its context engineering guide |
| 30 November 2026 | OpenAI’s dataset-backed prompt optimizer is scheduled to close with its Evals platform |
Frequently asked questions
What is prompt engineering in simple terms?
Prompt engineering is writing the instructions you give an AI model so that it gives you the answer you actually want. In practice it means stating the goal clearly, giving the background the model cannot know, showing an example when style matters and saying what format you want back.
Is prompt engineering still relevant?
Prompt engineering is still relevant, but the advice has changed. The prompting guides from OpenAI, Anthropic and Google ask for plain, direct instructions; Anthropic advises softening forceful wording written for older models, and OpenAI says its reasoning models do not need to be told to think step by step. Clear goals, the right context and, for tone and format, good examples remain the core advice.
What is chain of thought prompting?
Chain-of-thought prompting is asking an AI model to write out its reasoning step by step before giving a final answer. Google researchers introduced it in January 2022. In a May 2022 study by Takeshi Kojima and colleagues, adding “Let’s think step by step” raised one model from 17.7% to 78.7% on the MultiArith maths benchmark. Reasoning models do this internally, so the prompt adds little on them.
Does “think step by step” still work?
“Think step by step” can still help models that do not reason by default, but it adds little or nothing on reasoning models. A June 2025 Wharton study found only marginal gains, if any, on reasoning models such as o3-mini and o4-mini, with requests taking 20% to 80% longer. OpenAI and Google both say their reasoning models do not need the instruction.
What is the difference between prompt engineering and context engineering?
Prompt engineering is writing the instructions given to an AI model; context engineering is curating everything the model sees, including documents, search results, tool descriptions, conversation history and memory. Anthropic describes context engineering as “the natural progression of prompt engineering”, and Andrej Karpathy backed the term in June 2025.
What are the main prompt engineering techniques?
The main prompt engineering techniques are clear and specific instructions, explaining the reason behind rules, few-shot examples, separating the parts of a prompt with headings or tags, putting long documents before the question, specifying the output format, giving the model a role and breaking big jobs into a chain of smaller prompts. Each appears in the prompting guide of at least one of OpenAI, Anthropic and Google, and clear instructions and separating the parts of a prompt appear in all three.
What is the difference between zero-shot and few-shot prompting?
Zero-shot prompting asks a model to do a task with no examples, while few-shot prompting includes a handful of worked examples so the model can copy the pattern. Google recommends always including few-shot examples, Anthropic suggests three to five, and OpenAI suggests trying its reasoning models without examples first.
Is prompt engineering a real job?
Prompt engineer exists as a job title, and writing and testing prompts is also part of broader roles such as AI engineer and AI product manager. Pay and demand are covered in our prompt engineer salary guide.
Do I need a prompt generator?
Not necessarily. ChatGPT, Claude and Gemini will each draft or improve a prompt if you describe what you want and answer their questions, including on their free plans, which is why our best AI prompt generators page names the chatbot you already use as its pick for most people. OpenAI’s dataset-backed prompt optimizer is scheduled to close with its Evals platform on 30 November 2026.
What is prompt injection?
Prompt injection is an attack in which instructions hidden in content an AI model reads, such as a web page, email or document, hijack its behaviour. The OWASP Foundation ranks it the number one risk for LLM applications in its 2025 Top 10 and says it is unclear whether any fool-proof prevention exists.
How do I write a good prompt?
A good prompt says what the result is for, gives the background the model cannot know, shows an example if style matters, states the format you want back and is refined over a few turns. “Suggest five low-cost marketing ideas for a two-person commuter-town bakery, with rough costs, in a table” gives a model far more to work with than “give me marketing ideas”.