Prompt engineering is the practice of writing instructions that get an AI model to produce the output you actually want. The official guides from OpenAI, Google and Anthropic agree on the basics: be clear and specific, give the model the context it needs, show examples of good output, structure long prompts, and test and iterate. Below is a reusable template, before-and-after examples, and the mistakes that waste the most time.
Start before the prompt: define "good"
Anthropic's guide opens with a step most people skip. Before you tweak wording, have three things: a clear definition of success for your use case, a way to test against it, and a first draft prompt to improve.
In practice, write down what a good answer looks like ("a 120-word product description, friendly tone, mentions the warranty, no superlatives") and keep 3–5 real inputs to test every version of your prompt against. Anthropic also notes that not every problem is a prompt problem: sometimes latency or cost improves more by choosing a different model.
The five habits the official guides share
1. Be clear and specific
Google's Gemini guide calls clear and specific instructions "an effective and efficient way to customize model behavior." Say what you want, for whom, and in what form.
OpenAI adds a useful nuance. Its GPT models do best with precise, explicit instructions, while its reasoning models generally do better with high-level guidance. OpenAI compares a reasoning model to a senior co-worker you can give a goal to, and a GPT model to a junior co-worker who needs specific direction.
2. Add constraints and the output format
Google recommends stating constraints (length, what to do and not do) and specifying the response format: a list, a table, a sentence. You can even start the answer yourself and let the model continue in that pattern.
3. Give context
Both OpenAI and Google recommend including the information the model doesn't have: a document, your product details, your policies. Google notes that grounding answers in provided text gives more specific responses. OpenAI suggests placing that context near the end of the prompt.
4. Show examples (few-shot)
Google's guide goes as far as recommending that you always include few-shot examples, because prompts without them are likely to be less effective. OpenAI suggests showing a diverse range of inputs with the desired outputs. Google adds two cautions: keep the examples' formatting consistent, and don't use so many that the model overfits to them.
5. Structure long prompts and iterate
OpenAI recommends Markdown headings and lists to separate sections, and XML tags to mark where supporting content begins and ends. A typical structure, in OpenAI's words, covers identity, instructions, examples and context. Google suggests breaking complex work into smaller prompts or chained steps, and expects iteration: rephrase, reorder, or reframe the task.
A reusable prompt template
# Role
You are a [role] helping [audience].
# Task
[What to produce, in one or two sentences.]
# Rules
- Length: [e.g. under 150 words]
- Tone: [e.g. friendly, plain English]
- Must include: [facts, terms]
- Must avoid: [claims, words, topics]
# Format
[e.g. a title line, then 3 bullet points]
# Examples
<example>
Input: ...
Output: ...
</example>
# Context
<context>
[Paste the document, data or details here.]
</context>
Use only the sections you need. For a quick question, the first three lines are plenty.
Before and after
Before:
Write a product description for our water bottle.
After:
You write product copy for a small outdoor-gear shop. Write a description of our 750 ml steel water bottle for the product page. Rules: 90–120 words, plain and friendly, second person. Mention that it keeps drinks cold and fits car cup holders. Don't use words like "best" or "ultimate." Format: one short headline, then one paragraph. Here is an example of a description we like:
…
The second prompt tells the model who it is writing for, what must be in it, what to avoid, the format, and what "good" looks like.
Another example (summaries):
- Before: "Summarize this."
- After: "Summarize the meeting notes below for a manager who wasn't there. Give 3 decisions, then action items as a list with owner and due date. If something is unclear, say 'unclear' instead of guessing.
… "
Common mistakes
- No definition of success. You can't improve what you haven't defined.
- Vague asks. "Make it better" gives random results. Say better how.
- Too many instructions at once. Split big tasks into steps or separate prompts.
- Examples that contradict the rules. The model often follows the example.
- Never testing on real inputs. A prompt that works on one input may fail on the next.
- Judging by a single run. Run important prompts several times and compare.
For people building with AI
If you run prompts inside an app, the OpenAI guide adds production advice: pin specific model snapshots so behavior stays consistent, build evals to measure performance as you change prompts or models, keep production prompts in your code, and put reusable content at the start of the prompt to benefit from prompt caching. These habits matter a lot for AI agents, where one weak instruction repeats at every step of a loop.
Where to practice
Try the same prompt in two or three assistants, such as ChatGPT, Claude and Gemini, and compare. The differences teach you a lot. For image models, the same principles apply: be specific about subject, style and format. Browse chat assistants or image tools on ToolDrop, or search the whole directory. If you're looking for options beyond the big names, see our list of ChatGPT alternatives.
FAQ
Is prompt engineering still useful with newer models?
Yes. Newer models need less hand-holding, and OpenAI notes that its reasoning models work best with high-level goals, but context, constraints, examples and a clear definition of success still change the results.
Should I use XML tags or Markdown?
Both work. OpenAI suggests Markdown for sections and XML tags to wrap supporting content like documents and examples, so the model can tell instructions from material.
How many examples should I include?
A few diverse ones usually beat many similar ones. Google warns that too many examples can make the model overfit to them.
Do these tips work for image prompts too?
The core ideas carry over: be specific, state the format and style you want, and iterate. Each image tool has its own conventions, so check its documentation.