How to write a prompt: the five parts, step by step

TL;DR: To write a good prompt, give the AI five things: a role (who should answer), context (the facts it can't know), one clear task, the format you want back, and constraints (what to avoid or keep exact). Then read the answer and reply with specific corrections. The method works the same in ChatGPT, Claude and Gemini.

The five parts of a good prompt

A prompt is a brief. The model is fast and well read, but it knows nothing about your situation until you tell it. Every weak answer you have had from an AI tool traces back to a gap in the brief: it didn't know who it was writing for, what the facts were, or what a finished answer should look like. Five parts close those gaps.

The five parts of a prompt, what each does and a sample line
PartWhat it doesSample line
RoleSets the expertise, vocabulary and judgment"You are an accountant who works with freelancers."
ContextGives the facts only you know"I invoice in euros, I live in Spain, my clients are in the US."
TaskSays exactly what to produce"List the records I should keep for my tax return."
FormatDefines the shape of the answer"A checklist, grouped by month, under 150 words."
ConstraintsRules out what you don't want"If a rule depends on my situation, say so instead of guessing."

You don't need all five every time. A quick question needs a task and nothing else. But when the answer matters, or the first reply missed, walk through the list and add the part that is missing. Context is the one that changes results most, and the one people skip most.

How to write each part

1. Role: say who should answer

One sentence is enough. "You are a senior recruiter" or "Act as a patient maths tutor" tells the model which knowledge to draw on and what tone fits. Make the role match the job, not a fantasy: "world's greatest copywriter" adds nothing that "an experienced B2B copywriter" doesn't. Roles help most for specialist tasks and least for simple ones. Our guide to role prompting covers when they help and when they don't.

2. Context: give the facts it can't know

This is where most of the quality comes from. Ask yourself what a smart new colleague would need to know before doing this task well. Usually that means:

  • Who the output is for. "Clinic owners who are not technical" gives a very different email than "our customers".
  • The real facts. Prices, dates, names, numbers, what happened. If you leave them out, the model fills the gap with plausible inventions.
  • Why you are asking. "I'm sending this to the board on Friday" explains how careful and how formal to be.
  • Source material. Paste the document, the email thread or the data. Mark where it starts and ends, for example with a line that says "Notes:" before it.

Anthropic's prompting guide makes the same point with a useful test: show your prompt to a colleague who knows little about the task. If they would be confused, the model will be too.

3. Task: ask for one clear thing

Use a precise verb: write, summarize, compare, rewrite, list, critique, extract. "Help me with my presentation" is not a task. "Write speaker notes for slides 3 to 6" is. If you have two jobs, ask for them in order across two messages, or number them in one prompt. When a task has several stages, splitting it into separate prompts usually works better; that is called prompt chaining.

4. Format: describe the answer you want back

Say the length, the structure and the tone. Numbers beat adjectives: "under 120 words" is easier to hit than "short", and "three bullet points" is clearer than "brief". If you will paste the result somewhere, say where: an email, a slide, a spreadsheet, a Slack message. If you have an example of what good looks like, paste it. One example often does more than a paragraph describing your style.

5. Constraints: set the limits

Constraints are the rules that stop the answer from going wrong in ways you can predict. The most useful ones are about facts: "use only the information above", "keep every number exactly as written", "if something is missing, put it in [brackets] instead of guessing". Add style limits too if you know your pet hates, such as words you never want to see. Keep the list short. Two or three constraints that matter beat ten that compete.

A worked example: from weak prompt to strong

Here is one prompt built up a part at a time, so you can see what each part adds. The job: tell existing customers about a price increase. The token count under each version is measured with the GPT-5 tokenizer, so you can see how small even the full version is.

Version 1: the task alone (8 tokens)
Write an email about our price increase.

What you get: a generic, cheerful email for an imaginary company, with made-up numbers and a vague reason for the change. It could be about anything, so it is useful for nothing.

Version 2: add a role (20 tokens)
You are a customer success manager at a small software company. Write an email about our price increase.

Better tone and a more customer-minded structure. Still no facts, so the model still invents them. A role alone rarely fixes a weak prompt.

Version 3: add context (86 tokens)
You are a customer success manager at a small software company.

Context: We sell scheduling software to independent physiotherapy clinics. On 1 March our Standard plan goes from $39 to $49 a month. It is our first price rise in three years. In that time we added online booking, SMS reminders and a second calendar view. Customers on annual plans keep their current price until renewal.

Write an email about our price increase.

This is the big jump. Now the email mentions the real price, the real date, the features that justify it and the annual-plan exception. Most of the improvement in the whole example happens here.

Version 4: a precise task and a format (132 tokens)
You are a customer success manager at a small software company.

Context: We sell scheduling software to independent physiotherapy clinics. On 1 March our Standard plan goes from $39 to $49 a month. It is our first price rise in three years. In that time we added online booking, SMS reminders and a second calendar view. Customers on annual plans keep their current price until renewal.

Task: Write the email that tells current Standard customers about the change.

Format: A subject line, then the email. Under 180 words. Plain, warm tone. The new price and the date go in the first two sentences. End with one clear next step.

Now it is the right length, it leads with what readers need, and it ends with an action. "New price and date in the first two sentences" stops the model from burying the news under three paragraphs of warm-up.

Version 5: add constraints (179 tokens)
You are a customer success manager at a small software company.

Context: We sell scheduling software to independent physiotherapy clinics. On 1 March our Standard plan goes from $39 to $49 a month. It is our first price rise in three years. In that time we added online booking, SMS reminders and a second calendar view. Customers on annual plans keep their current price until renewal.

Task: Write the email that tells current Standard customers about the change.

Format: A subject line, then the email. Under 180 words. Plain, warm tone. The new price and the date go in the first two sentences. End with one clear next step.

Constraints: Don't apologize more than once. Don't say "exciting" or "thrilled". Don't invent features, discounts or numbers that are not above. If you need a detail I haven't given, put it in [brackets].

The constraints remove the two most common problems with this kind of email: over-apologizing and invented details. The bracket rule means that if the model wants to mention, say, a support contact you didn't give, you see a blank to fill in rather than a fake phone number.

The final prompt is 179 tokens, about 140 words. Length is not the goal: every line in it carries a fact or a rule. Paste your own prompts into our token counter to see how long they really are.

How to iterate on an answer

Your first prompt rarely gets a perfect answer, and it doesn't need to. The fastest path is usually a short, specific follow-up in the same chat, not a new prompt from scratch. The model still has all your context, so you only need to say what is wrong.

What to reply when the answer misses
If the answer is...Reply with something like
Too long"Cut this to 100 words. Keep the price, the date and the next step."
Too generic"This could be any company. Use the details I gave and mention the SMS reminders by name."
Wrong tone"Too formal. Write it the way a friendly account manager would talk on the phone."
Factually off"The annual-plan rule is wrong. They keep the old price until renewal, not for a year."
Badly structured"Put the change first, the reasons second, and the next step last."
Missing something"Add one sentence on how to switch to annual billing."

Three habits make iteration faster:

  1. Name the specific problem. "Make it better" gives the model nothing to aim at. "The second paragraph repeats the first" does.
  2. Say what to keep. When you ask for a change, list what must stay the same, or a good part may disappear in the rewrite.
  3. Fold fixes back into the prompt. If you correct the same thing twice, add it to your saved prompt as a constraint, so next time the first answer is right.

When the conversation has gone through many rounds and the answers start to drift, start a new chat with the improved prompt. A clean prompt with everything in it beats a long thread of patches.

Let the model ask you first

If you are not sure what context matters, make the model find out. Add one line to the end of any prompt: "Before you start, ask me up to five questions about anything you need to know to do this well." The questions it asks are a checklist of the gaps in your brief. Answer them, and the next reply is usually far more specific.

A prompt that collects its own context
I need to [task, for example: write a job ad for a part-time bookkeeper]. Before you write anything, ask me up to five questions, one at a time, about the details you need to do this well. When I have answered, write it.

Does this work in ChatGPT, Claude and Gemini?

Yes. OpenAI, Anthropic and Google publish their own prompting guides, and the core advice lines up: be clear and specific, give context, say what format you want, and show examples when the format matters. The five parts are plain instructions, not tricks for one model, so the same prompt will work in all three. The differences show up in defaults. One model may write longer answers, another may add more headings. Adjust with a format line or a follow-up rather than rewriting the prompt for each tool.

What does change between tools is where you can save instructions so you don't retype them. In ChatGPT, preferences you want in every chat go in custom instructions. For one-off tasks, keep everything in the prompt.

Common mistakes when writing prompts

  • Describing the topic instead of the task. "Something about our Q3 results" is a topic. "A five-bullet summary of Q3 for the sales team" is a task.
  • Leaving the reader out. The same facts need different words for a CEO, a customer and a new hire.
  • Asking for several unrelated things at once. One part gets done well and the rest gets rushed.
  • Relying on adjectives. "Professional, engaging, concise" means different things to everyone. Give a length, an example or a reader instead.
  • Not saying what to do with gaps. Without a rule, the model guesses. Tell it to ask or to leave a [blank].
  • Starting over after every bad answer. A precise follow-up is faster and keeps what was already right.

A template you can reuse

Copy this, fill in the brackets, and delete any line you don't need. For dozens of finished prompts built on the same pattern, see our prompt examples.

Five-part prompt template
You are [role, for example: an experienced HR manager].

Context: [who it is for, the facts, why you need it, any source material].

Task: [one clear instruction with a precise verb].

Format: [length, structure, tone, where it will be used].

Constraints: [what to avoid, what must stay exact, and: if you need information I haven't given, ask me or put it in brackets].

Let the right experts write your prompt

Prompt Expert is an AI prompt generator that brings the right experts to every job. They ask a few questions, read your website and files, and write the prompt for ChatGPT, Claude or Gemini with your real facts, working together when a job needs more than one.

See how it works

Questions

What is the best way to write a prompt?

Give the AI a role, the context it can't know, one clear task, the format you want and a few constraints. Then improve the answer with specific follow-ups instead of starting over.

How long should a prompt be?

As long as the context needs and no longer. A simple question can be one line; a task that depends on your facts may take 100 to 300 words. Cut politeness and repetition, keep facts, examples and format rules.

What are the five parts of a prompt?

Role, context, task, format and constraints. The role says who should answer, the context gives the facts, the task says what to produce, the format defines the shape of the answer, and the constraints set the limits.

Should I say please and thank you to ChatGPT?

It does no harm, but it is not what improves answers. Specific context, a clear task and a defined format matter far more than politeness.

Why does the AI make things up in my answers?

Usually because the prompt left a gap and the model filled it with something plausible. Give it the real facts, tell it to use only the information provided, and ask it to mark anything missing in brackets instead of guessing.

Do I need a different prompt for ChatGPT, Claude and Gemini?

No. A clear prompt with role, context, task, format and constraints works in all of them. You may adjust the length or tone after the first answer, because each model has slightly different defaults.

Sources