What are prompt engineering best practices?

Updated 2026-07-15Asked across Reddit, Quora & Google· prompt engineering and LLM
Short answer

Best practices: write clear, specific instructions and put the key ask first; give the model context and reference text instead of relying on memory; show examples for tricky tasks (few-shot); ask it to reason step by step; specify the output format; and test and iterate. OpenAI and Anthropic both stress clarity, examples, and structured, evaluated prompts.

Why — the first-principles explanation

Every best practice traces back to one fact: the model only has the text you give it and predicts the most likely continuation. So the practices are really techniques for reducing ambiguity and supplying the right patterns, clear instructions cut guessing, examples show the target, reference text supplies facts, and format specs pin down the shape of the answer.

Structure matters because models weight position and delimiters. Putting the main instruction first, separating sections (Anthropic favors XML tags; OpenAI favors clear headings), and stating constraints explicitly all help the model parse what you want. Asking for step-by-step reasoning improves multi-step tasks by giving the model room to work.

The meta-practice is iteration. Neither OpenAI nor Anthropic promises a perfect first prompt; both frame the work as testing against clear success criteria and refining. A good prompt is discovered, not guessed, one edit at a time.

An example that makes it click

Good prompting is like writing instructions for a new babysitter. Vague, 'take care of the kids,' invites bad guesses. Specific, 'dinner at 6, no screens after 7, bedtime at 8, emergency number on the fridge,' gets exactly the evening you wanted. Leaving a note that says 'here's what worked last time' (an example) helps even more.

And you don't nail the perfect note on the first try; you adjust it next week based on how things went. LLM prompts work the same way: specific, structured, exemplified, and refined.

How to do it

  1. Put the most important instruction first and state the task clearly.
  2. Give context and paste reference text rather than relying on the model's memory.
  3. Show one or two examples of the desired output for tricky or stylistic tasks (few-shot).
  4. Specify the output format and length explicitly (list, table, or JSON with named keys).
  5. For multi-step problems, ask the model to reason step by step before answering.
  6. Separate sections with clear delimiters (headings or XML tags) and state constraints explicitly.
  7. Test multiple versions against real inputs, compare, and iterate.

Key facts

Infographic: What are prompt engineering best practices — short answer and key facts
Visual summary — What are prompt engineering best practices?
▶ The 60-second explainer (script)

What are the best practices for prompt engineering? They all come from one fact: the model only knows the text you give it, and it fills any gap with its best guess. So, first, be specific, state the task clearly and put the most important instruction first. Second, give it context and paste in reference text instead of trusting its memory, which cuts down on made-up facts. Third, show one or two examples of what a good answer looks like; for tricky or stylistic tasks, examples beat description. Fourth, spell out the format, a five-bullet list, a table, JSON with certain keys. Fifth, for anything with reasoning, ask it to think step by step. Structure helps too: separate sections with clear headings or XML tags, the way Anthropic recommends. And finally, don't expect a perfect first draft, both OpenAI and Anthropic treat prompting as test-and-iterate. Specific, structured, exemplified, and refined: that's the whole game.

What authoritative sources say

OpenAI – Prompt engineering guideofficial — OpenAI's strategies include clear instructions, reference text, splitting complex tasks, and giving the model time to think. source ↗
Anthropic – Prompt engineering overviewofficial — Anthropic recommends clarity, examples, reasoning, XML tags, roles, prefill, and prompt chaining, in roughly that order. source ↗
DigitalOcean – Prompt engineering best practicesmedia — Best practices emphasize specificity, context, examples, and clear output formats. source ↗

People also ask

What's the number one best practice?

Specificity, clearly state the task, format, and constraints so the model doesn't guess. Everything else builds on that.

Should I use XML tags or headings?

Either works to separate sections. Anthropic favors XML tags; OpenAI favors clear headings. Consistency matters more than the choice.

How many examples should I include?

Usually one to a few, enough to show the pattern without bloating the prompt. Add more only if the model keeps missing the style.

Do best practices differ by model?

The fundamentals are shared, but each model has quirks. Check the provider's own guide and test your prompt on the specific model you'll use.

Related questions