Prompt engineering

How to write prompts that get the answer you meant, not the average answer on the internet. The short version: tell the model what a colleague would need to know.

The six parts of a prompt

Almost every strong prompt is made of the same components. You rarely need all six, but checking each one is the fastest way to find out why a prompt is underperforming.

  1. Task. One explicit instruction with a verb. “Summarise this contract for a non-lawyer.”
  2. Context. Facts, source material, background, and who the output is for.
  3. Role. A perspective that sets vocabulary and depth. See role prompting.
  4. Format. The shape and length of the answer.
  5. Constraints. What to avoid, what must be included, boundaries.
  6. Examples. One or more samples of good output. See few-shot prompting.

Build a prompt, watch the answer change

Switch components on and off. The right-hand side shows the kind of answer a chat model typically gives for that prompt. The answers are illustrative, written to show the pattern you’ll see in practice.

Prompt (1 of 6 parts)

Write a product description for our trail running shoe.

Typical answer

Introducing the ultimate trail running shoe! Designed for comfort and performance, it features advanced cushioning and a durable outsole. Perfect for runners of all levels. Experience the difference today!

Task on: The model knows what to produce, but everything else is a guess.

Notice that the biggest single jumps come from context (facts replace inventions) and from the example (voice gets copied). Role and rules refine; format makes the result usable. That ordering matches what both OpenAI’s and Anthropic’s prompting guides emphasise. Seeing each piece switch on is the quickest way to make it stick, and if you like learning this way, ahaboo has narrated, interactive explainers of how everyday things really work.

Five habits that matter more than tricks

  • Be specific about the output. “3 bullet points, under 15 words each” beats “keep it brief”.
  • Separate instructions from material. Put pasted text under a heading, in triple quotes, or in XML tags so the model doesn’t treat it as instructions. The Claude generator does this with tags.
  • Say what to do, not only what not to do. “Write in plain English at a 9th-grade level” works better than “don’t be too technical”.
  • Break big tasks into steps. Ask for an outline, approve it, then ask for the draft. Or ask the model to reason first: chain-of-thought prompting.
  • Iterate one change at a time. Change one component, compare outputs, keep what helped. Save winners in your prompt library.

Techniques

Beyond the basics, a handful of named techniques are worth knowing: zero-shot, few-shot, chain-of-thought, role prompting, prompt chaining, self-consistency and more. The prompt engineering techniques page compares them with when to use each.

Image and video prompts are different

Image models don’t follow instructions; they match descriptions. Instead of “please create a picture of…”, describe the scene: subject, setting, medium, light, camera, mood. Midjourney and Stable Diffusion add their own syntax: parameters, (weights:1.2) and negative prompts.

A quick checklist

  • Could a smart new colleague do this task from the prompt alone?
  • Is the output format and length stated?
  • Is there anything the model will have to invent because you didn’t say it?
  • Would one example make the target clearer?

Run your own prompt through the prompt optimizer to check it against these points automatically, or start fresh with the AI prompt generator.

Questions

What is prompt engineering?

Prompt engineering is the practice of writing and refining the instructions you give an AI model so it produces the output you need reliably. It covers what you say (task, context, examples), how you structure it (sections, delimiters, order) and how you test and iterate.

Is prompt engineering still useful with newer models?

Yes, though it has shifted. Newer models need fewer tricks, but they still cannot read your mind. Clear tasks, relevant context, explicit formats and good examples matter as much as ever, and system prompts for products and agents are more important than before.

What is the best prompt formula?

A reliable formula is Role + Task + Context + Format + Constraints + Example. Not every prompt needs all six, but checking each one catches most weak prompts. The CraftPrompts generator is built around that formula.

How do I learn prompt engineering?

Read the official guides from OpenAI, Anthropic and Google, then practise: write a prompt, look at the output, change one thing, and compare. Save prompts that work as templates. The technique pages on this site each include an interactive explainer.