Prompt engineering is the skill of writing instructions for an AI tool such as ChatGPT, Claude or Copilot so that it does a task well, and keeps doing it well. In practice you say what the task is, who it is for and what a good result looks like, add an example, and try the prompt on a few real cases before you rely on it.
Where does prompt engineering come from?
Once language models could carry out tasks from a text instruction, as GPT-3 showed in 2020, the wording of that instruction started to matter. A survey by Liu et al. (2021) defines prompt engineering as creating the prompt that gives the best performance on a task. In The Prompt Report (2024), Schulhoff et al. counted 58 prompting techniques for text alone, and drew up a vocabulary of 33 terms because the field used them in conflicting ways.
How does it work in practice?
Anthropic's guide starts before the first prompt: define what counts as success, have a way to test against it, and only then improve a first draft. OpenAI's guide (September 2026) adds two habits for software built on a model: pin the application to a specific model snapshot, and build tests that measure how the prompt behaves, because even snapshots within one model family can respond differently. OpenAI also advises keeping production prompts in the application code, so that a change goes through review and tests like any other change.
Which techniques are there?
The basics are in the entry on the prompt: be clear, explain why, give examples, and keep instructions, context and examples apart. Common techniques beyond that:
- Examples of the input and output you want (few-shot prompting), which work through in-context learning.
- Asking for the reasoning before the answer (chain-of-thought). Adding "Let's think step by step" raised the accuracy of OpenAI's text-davinci-002 on the MultiArith arithmetic test from 17.7% to 78.7% (Kojima et al., 2022).
- A fixed output format, such as JSON with named fields (structured output).
- Splitting a task into steps, each with its own prompt (prompt chaining).
- A system prompt with standing instructions for every conversation.
Techniques age with the models. For reasoning models, which work through a problem before they answer, OpenAI's guide (September 2026) advises against chain-of-thought prompts: asking them to think step by step is unnecessary and can even hurt.
Where does it go wrong?
- Small changes, big effects. Sclar et al. (2023) changed only the formatting of few-shot prompts, such as separators, spacing and capital letters, and saw accuracy differ by up to 76 percentage points on LLaMA-2-13B. How well a format works on one model says little about another.
- Some problems lie elsewhere. Anthropic notes that latency and cost are sometimes easier to improve by choosing a different model. Knowledge the model lacks has to come from your own documents, for example through RAG.
- Text from outside, such as an email the model reads, can carry instructions of its own (prompt injection).
Example
Suppose a bicycle shop wants descriptions for the e-bikes in its webshop. "Write a product description for this e-bike" gives generic text, sometimes with invented details. A better prompt:
1 You write product descriptions for a bicycle shop. Our customers are commuters and older riders. 2 Use only the specifications below. If something is missing, write "unknown" instead of guessing. 3 Write 80 to 120 words in a friendly, plain tone, then list the three most important specifications. 4 A description we like: {example} 5 6 <specifications> 7 {spec sheet} 8 </specifications>
The shop tries it on ten bikes, checks every figure against the spec sheets, and saves the working version with a date, so it can compare when the tool or the model changes.
Sources
- Anthropic: Prompt engineering overview (Claude Platform Docs)Web
- OpenAI: Prompt engineering (API guide)Web
- Schulhoff et al.: The Prompt Report, a Systematic Survey of Prompt Engineering Techniques (2024)arXiv
- Liu et al.: Pre-train, Prompt, and Predict, a Systematic Survey of Prompting Methods in NLP (2021)arXiv
- Sclar et al.: Quantifying Language Models' Sensitivity to Spurious Features in Prompt Design (2023)arXiv
- OpenAI: Reasoning best practices (API guide)Web
