Prompt Engineering: A Complete Guide With Examples
Prompt engineering explained: what goes into a prompt, core techniques with before-and-after examples, how to test prompts, and templates you can reuse.
New to this? Start with What is a prompt?
AI-generated · This report was generated using AI language models trained on publicly available data. It reflects editorial analysis at the time of generation and is not the result of hands-on product testing, independent verification by a human analyst, or a commercial endorsement. All scores, assessments, and claims are derived from signals indexed by Mindber at generation time and are subject to change without notice. Mindber and its operators make no warranty of accuracy, completeness, or fitness for any commercial decision-making purpose. This report is for informational purposes only.
Quick answer
Prompt engineering is the practice of designing the instructions, context and examples given to a large language model so that it reliably produces the output you need. In practice, that means stating the task and audience plainly, supplying the facts the model needs, showing an example or two, fixing the output format and testing each change on real inputs, because model output varies between runs.
What is prompt engineering?
Prompt engineering is the work of turning a loose request into instructions a model can follow consistently. A prompt is everything the model receives before it answers: instructions, reference text, examples and the conversation so far. A large language model generates its response from that input, so the wording, order and completeness of the prompt shape the result.
OpenAI's prompt engineering guide defines the discipline as "the process of writing effective instructions for a model" and notes that, because model output is non-deterministic, getting it right is a mix of art and science. The same skills apply whether you type into a chat app such as ChatGPT or send requests through an API.
Prompting is usually the first lever to pull: it takes minutes, while fine-tuning a model needs training data and evaluation. Everything in the prompt also occupies the model's context window and is billed in tokens, so longer is not automatically better.
Anatomy of a prompt
Effective prompts draw on six parts. Not every prompt needs all six, but a missing one often explains weak output.
| Part | What it does | Example |
|---|---|---|
| Role | Sets perspective and expertise | "You are a support engineer for a billing API." |
| Task | States the job as one clear instruction | "Classify the ticket and draft a reply." |
| Context | Supplies facts the model cannot know | Account plan, product docs, earlier messages |
| Examples | Shows the pattern to copy | Two labeled sample tickets |
| Constraints | Sets limits | "Under 120 words. Never promise refunds." |
| Output format | Defines the shape of the answer | JSON with category and reply fields |
Two structural habits help. First, separate sections with clear delimiters: OpenAI's guide recommends Markdown headings and XML tags to mark where instructions end and reference material begins, and Anthropic's prompt engineering overview also recommends XML tags. Second, put durable rules in the system prompt. OpenAI calls this the developer message and says it takes priority over user messages.
Core prompt engineering techniques
Seven techniques cover most everyday prompting. The examples are illustrative, written for this guide.
Zero-shot prompting
Zero-shot prompting gives the model instructions only, with no examples. It works for common tasks when the instruction names audience, length and format.
BEFORE
Summarize this.
AFTER
Summarize the support ticket between the triple quotes in 3 bullet points
for the on-call engineer. Quote any error message exactly.
"""[ticket text]"""
Few-shot prompting
Few-shot prompting adds a handful of worked examples so the model can infer the pattern. Brown et al. (2020) showed a large language model handling new tasks from a few demonstrations supplied as text, with no gradient updates or fine-tuning. Google's Gemini prompting guide recommends including examples, keeping their formatting consistent and showing patterns to follow rather than anti-patterns to avoid.
BEFORE
Is this review positive or negative? "Setup took an hour."
AFTER
Classify each review as positive, negative or mixed.
Review: "Fast, and support answered in minutes." -> positive
Review: "Great features, but the app crashes daily." -> mixed
Review: "Setup took an hour." ->
Role and system prompts
A role tells the model whose perspective to adopt; a system prompt holds rules that apply to every turn of a conversation. Anthropic's overview lists giving the model a role through the system prompt among its core techniques.
BEFORE
Explain our refund policy.
AFTER
System: You are a support agent for Acme Cloud. Answer only from the
policy text provided. If the policy does not cover a case, say so and
offer to escalate. Use a friendly, plain-English tone.
User: Can I get a refund after 45 days?
Structured output
Asking for a fixed structure, such as JSON with named fields, makes output machine-readable and easy to validate. Name every field, list allowed values and say what to do when data is missing. Some APIs can also enforce a JSON schema natively.
BEFORE
Pull out the key details from this invoice.
AFTER
Extract fields from the invoice below. Return only JSON:
{"vendor": string, "invoice_date": "YYYY-MM-DD", "total": number,
"currency": "3-letter ISO 4217 code"}
Use null for any field that is not present. Do not guess.
Step-by-step reasoning (chain of thought)
Chain-of-thought prompting asks the model to work through intermediate steps before it answers. Wei et al. (2022) described a chain of thought as "a series of intermediate reasoning steps" and reported gains on arithmetic, commonsense and symbolic reasoning tasks. Kojima et al. (2022) found that simply adding "Let's think step by step" improved zero-shot reasoning. Reasoning models now do much of this internally, and OpenAI's guide says they generally perform better with high-level guidance than with very precise instructions.
BEFORE
Which plan is cheaper for 12 users?
AFTER
Compare the two plans below for a 12-user team over one year.
Work through the cost of each plan step by step, then give the
result on a final line that starts with "Answer:".
[plan details]
Prompt chaining
Prompt chaining splits a complex job into a sequence of prompts, where each output becomes the input of the next step. Each step is easier to test and fix on its own. Anthropic's overview recommends chaining complex prompts.
BEFORE
Read this 40-page report and write a fact-checked summary.
AFTER
Step 1: List every factual claim in the report, one per line.
Step 2: For each claim, quote the source sentence that supports it,
or write "unsupported".
Step 3: Write a 200-word summary that uses only supported claims.
ReAct-style tool use
ReAct, introduced by Yao et al. (2022), interleaves reasoning steps with actions such as a search or a lookup, then feeds each result back to the model. The authors reported that consulting an external source, a Wikipedia API in their experiments, helped overcome the hallucination and error propagation seen in chain-of-thought reasoning alone. Most model APIs now offer native tool calling, and the Model Context Protocol standardizes how tools are connected to AI apps; see what an MCP server is.
BEFORE
What is the status of order 1182?
AFTER
You can use one tool: get_order(order_id).
Repeat this loop until you can answer:
Thought: what you need to find out next
Action: get_order("1182")
Observation: [the tool result is inserted here]
Then reply with the order status and expected delivery date.
How to evaluate prompts
A prompt is good when it passes a defined test, not when a single answer looks right. Anthropic's overview starts from three prerequisites: clear success criteria, a way to test against them and a first draft to improve. OpenAI's guide advises adding representative test cases and evaluation checks before changing production prompts, and pinning production apps to a specific model snapshot so behavior does not shift unexpectedly.
A workable loop:
- Write the criteria first. For example: valid JSON on every run, the correct label on a hand-checked set, no claims missing from the source text.
- Build a test set of a few dozen real inputs, including edge cases and inputs designed to break the prompt.
- Score automatically where you can. Parse for format, exact-match labels, and grade open-ended text against a rubric, spot-checking any model grader by hand.
- Change one thing at a time and re-run the full set. Keep prompts in version control.
- Reduce randomness while comparing. A lower temperature makes outputs more repeatable.
- Re-test when the model changes. A prompt tuned for one model can behave differently on another. Compare candidates on Mindber's Model Arena leaderboard, and use the LLM cost calculator to see what a longer prompt costs at volume.
Common prompt engineering mistakes
- Vague tasks. "Make it better" gives the model nothing to aim at. Say what better means.
- Conflicting instructions. "Be thorough" and "keep it short" in one prompt force the model to guess.
- Examples that all look alike. Models copy surface features, so vary examples across the cases you care about.
- Only saying what not to do. Describe the behavior you want; Google's guide notes that positive patterns work better than anti-patterns.
- Asking for facts without a source. Models can state errors confidently, a failure known as hallucination. Supply reference text or use retrieval-augmented generation, and ask the model to say when the source does not contain the answer.
- Mixing instructions with untrusted text. Pasted emails or web pages can carry instructions of their own, a risk called prompt injection. Delimit such text and tell the model to treat it as data.
Reusable prompt templates
Copy a template, then replace the bracketed parts.
General task
Role: You are [role] helping [audience].
Task: [one-sentence instruction].
Context:
<context>
[facts, documents or data]
</context>
Constraints: [length, tone, things to avoid].
Output: [format, e.g. 5 bullets, or JSON with fields x and y].
If information is missing, say what is missing instead of guessing.
Extraction
Extract [fields] from the text inside the <doc> tags.
Return JSON only, with null for missing fields. Do not infer values.
<doc>
[text]
</doc>
Critique and revise
Review the draft below against these criteria: [criteria].
List each problem with a quoted example, then rewrite the draft to fix it.
Keep the author's facts and do not add new claims.
<draft>
[draft]
</draft>
The prompt engineering hub collects the rest of this topic. To practice, browse AI assistants on Discover, compare the profiles of Claude and DeepSeek, or describe a task in Mindber Ask to get matching tools.
Frequently asked questions
What is prompt engineering in simple terms?
Prompt engineering is writing clear instructions for an AI model so that it gives the answer you need, reliably. It covers the request, background, examples and output format, plus testing those choices on real inputs.
What are the main prompt engineering techniques?
The core techniques are zero-shot instructions, few-shot examples, role and system prompts, structured output, step-by-step reasoning, prompt chaining and ReAct-style tool use. Most production prompts combine several of them.
What is the difference between zero-shot and few-shot prompting?
Zero-shot prompting gives the model instructions only. Few-shot prompting adds a small number of worked examples inside the prompt so the model can copy the pattern. Few-shot helps most when the format or labeling rules are hard to describe in words.
Is prompt engineering still useful with reasoning models?
Yes, but the emphasis shifts. OpenAI's documentation says reasoning models generally perform better with high-level guidance than with step-by-step instructions. Clear goals, context, constraints and output formats still matter, and so does testing.
What is a system prompt?
A system prompt is a set of instructions that applies to a whole conversation, such as the assistant's role, rules and tone. OpenAI calls it the developer message, and its documentation says these instructions take priority over user messages.
Do you need to code to do prompt engineering?
No. Prompts are written in plain language and work in ordinary chat apps. Coding helps when you want to run prompts at scale, test them automatically or connect a model to tools and data.
How do you know if a prompt is good?
Define what a correct output looks like, collect a few dozen representative inputs and measure how often the prompt meets the criteria. Change one element at a time and re-run the whole set. A single good answer is not evidence.
Do the same prompts work on every model?
Mostly, but not exactly. The fundamentals transfer between assistants, yet models differ in how closely they follow formats, long instructions and examples. Re-test important prompts whenever you switch models or a vendor updates one.
Method: editorial analysis of the public documentation and research papers listed in the sources, compiled on 2026-10-18. Mindber ran no experiments for this article.
Sources
- Prompt engineering. OpenAI
- Prompt engineering overview. Anthropic
- Prompt design strategies. Google
- Language Models are Few-Shot Learners (Brown et al.). arXiv, May 2020
- Chain-of-Thought Prompting Elicits Reasoning in Large Language Models (Wei et al.). arXiv, January 2022
- Large Language Models are Zero-Shot Reasoners (Kojima et al.). arXiv, May 2022
- ReAct: Synergizing Reasoning and Acting in Language Models (Yao et al.). arXiv, October 2022