How to write better prompts for LLMs?
Write better prompts by being specific: state the task, the context, the format you want, and any constraints. Add examples for tricky tasks, ask the model to reason step by step, and give it reference text instead of relying on its memory. Then test and refine, prompting is iterative. Clarity beats cleverness every time.
Why — the first-principles explanation
An LLM can't read your mind; it only sees the words you send. It fills any gap you leave with its most statistically likely guess, which is often not what you meant. So the core of a good prompt is removing ambiguity, telling the model exactly what you want, in what form, and with what boundaries.
Models also respond strongly to structure and examples. Showing one or two examples of the desired input and output (few-shot) is often more powerful than describing it in words, because the model pattern-matches. Likewise, asking for reasoning before the answer improves multi-step tasks, and giving reference text stops the model from inventing facts.
Finally, prompting is empirical. The first draft rarely wins; you compare versions, keep what works, and cut what doesn't. Both OpenAI and Anthropic frame prompt engineering as iterative testing against clear success criteria, not one perfect sentence.
An example that makes it click
Think of a prompt like an order at a busy deli. Say 'a sandwich' and you'll get whatever the cook guesses, maybe not what you wanted. Say 'a turkey sandwich on rye, toasted, mustard not mayo, cut in half,' and you get exactly your lunch. The extra words aren't fussy; they remove the guesses.
And if you add 'like the one I got last time,' pointing to an example, the cook nails it even faster. LLMs are the same: specific instructions plus an example get you what you actually wanted.
How to do it
- State the task plainly and put the most important instruction first.
- Give context: who it's for, the goal, and any background the model needs.
- Specify the output format and length (for example, a 5-bullet list, or JSON with named keys).
- Add one or two examples of the desired output for tricky or stylistic tasks (few-shot).
- For reasoning tasks, ask the model to think step by step before answering.
- Provide reference text instead of relying on the model's memory, and tell it to say 'I don't know' if the answer isn't there.
- Test a few versions, compare outputs, and keep refining, prompting is iterative.
Key facts
- LLMs act only on the text you provide and fill gaps with likely guesses, so specificity is the biggest lever.
- OpenAI's core guidance includes writing clear instructions, providing reference text, splitting complex tasks, and giving the model time to think.
- Anthropic recommends clarity, examples, XML structuring, role prompting, and letting the model reason, applied in roughly that order.
- Few-shot examples often steer output better than verbal descriptions alone.
- Both OpenAI and Anthropic treat prompt engineering as iterative testing against defined success criteria.
▶ The 60-second explainer (script)
Want better answers from AI? Write better prompts, and it comes down to one idea: the model only knows what you tell it, and it fills every gap with a guess. So your job is to remove the guessing. Start by stating the task clearly and putting the most important instruction first. Add context, who it's for and what the goal is. Then specify the format: a five-bullet list, a table, JSON with certain keys. For tricky or stylistic tasks, show one or two examples of what good looks like, examples often work better than description. For anything with reasoning, ask the model to think step by step. And if facts matter, paste in reference text and tell it to say 'I don't know' when the answer isn't there, so it doesn't make things up. Finally, don't expect the first draft to be perfect. Both OpenAI and Anthropic treat prompting as iteration: try a few versions, compare, keep what works. Clarity beats cleverness.
What authoritative sources say
People also ask
What's the single most important thing in a prompt?
Specificity. Clearly state the task, the desired format, and any constraints so the model doesn't have to guess your intent.
Are examples better than instructions?
Often, yes, for stylistic or tricky tasks. One or two examples (few-shot) let the model pattern-match to what you want.
Should I tell the model to 'act as' an expert?
Role prompting can help set tone and focus, but it's less important than clear instructions, reference text, and examples.
Why isn't my prompt working?
Usually it's ambiguous or missing context, format, or examples. Add specifics, test a couple of versions, and refine.