Prompt engineering guide: techniques that work, with the evidence
Prompt engineering is the craft of telling a model what you want in a form it can act on. This guide is the map: each technique, what vendors and researchers say about it, what it costs in tokens, and where to read more. Count your prompts in the token counter; the hub is prompting and AI workflows.
By the Chelure Enterprises Editorial Team. Last reviewed . How we check our sources.
The techniques at a glance
| Technique | What it does | What the sources say | Read more |
|---|---|---|---|
| Clear role and instructions | Sets scope, tone and rules | Anthropic: a single sentence of role in the system prompt focuses behaviour; OpenAI: developer messages are prioritized ahead of user messages | System prompts |
| Examples (few-shot) | Shows the format and judgement you want | Brown et al. (2020): task and demonstrations specified through text alone; Anthropic: 3 to 5 examples | Few-shot prompting |
| Step-by-step reasoning | Gets intermediate steps before the answer | Wei et al. (2022) and Kojima et al. (2022) for earlier models; reasoning models think internally | Chain-of-thought |
| Structure and delimiters | Separates instructions, context and input | Anthropic: tags reduce misinterpretation; OpenAI: Markdown headers and XML tags | System prompts |
| Stable content first | Enables prompt caching | OpenAI and Anthropic cache by prefix; cached reads cost a fraction of input | Prompt caching |
| Guarding untrusted input | Limits injected instructions | OWASP: no fool-proof prevention is known; limit privileges and validate output | Prompt injection |
A practical workflow
- Define success. Write 10 to 20 real inputs and what a good output looks like.
- Write the simplest prompt. A clear instruction, the input, and the format you want.
- Add structure. Separate role, instructions, examples and context, in that order, with the variable input last.
- Add examples only if needed. Start with three; test five.
- Measure. Compare accuracy and cost across prompt versions and across models; the prompt cost calculator prices each variant.
- Harden. Validate outputs, limit what the model can do, and test with hostile input.
Where each vendor puts the emphasis
- Anthropic: examples in tags (3 to 5), a role in the system prompt, long documents at the top of the prompt, and general instructions over rigid step lists for its thinking models.
- OpenAI: a structure of identity, instructions, examples and context; few-shot examples in the developer message; high-level goals for reasoning models and precise instructions for GPT models.
Frequently asked questions
What is prompt engineering?
Prompt engineering is writing and structuring the instructions, examples and context you give a model so it produces the output you want reliably, and measuring whether it does.
What is the single most useful tip?
Be specific about the task, the audience and the output format, and test your prompt on real inputs. Vendors agree on structure: OpenAI suggests sections for identity, instructions, examples and context, and Anthropic recommends wrapping different kinds of content in their own tags.
Do I still need chain-of-thought prompts?
For non-reasoning models on multi-step problems, yes it can help; for reasoning models, OpenAI says they do better with high-level goals and Anthropic advises general instructions such as thinking thoroughly. See the chain-of-thought page.
How many examples should I include?
Anthropic recommends 3 to 5 well-crafted examples; OpenAI says to show a diverse range of inputs. Each example costs tokens on every request, so measure the gain.
Does prompt wording affect cost?
Yes. Prompt length is input tokens, reply length is output tokens, and repeated prefixes can be cached at a discount. Put stable content first.
Can a good prompt make a model safe against attacks?
No. OWASP says no fool-proof prevention of prompt injection is known; treat the prompt as guidance, not a security boundary.
Sources
- Anthropic: prompting best practices
- OpenAI: prompt engineering guide
- OWASP: LLM01 Prompt Injection
- Brown et al.: Language Models are Few-Shot Learners (arXiv:2005.14165)
- Wei et al.: Chain-of-Thought Prompting (arXiv:2201.11903)
Primary sources opened on November 13, 2026. Prices come from our verified price table (see the methodology).