# Anatomy of a good prompt: role, context, task, constraints
Type "write me a post about coffee" into ChatGPT and you get something forgettable: a generic blurb that opens with "Coffee is one of the world's most beloved beverages." It's not wrong. It's just useless.
Now try this instead:
> You are a copywriter for a small specialty coffee roaster. Write a 120-word Instagram caption for our new Ethiopian single-origin beans. Audience: home brewers who care about flavor, not jargon. Tone: warm and a little playful. End with a soft call to actioncall to actionA button, link, or message that prompts users to take a specific action such as sign up, buy, download, or learn more.Voir la définition complète → to visit our shop.
The second prompt produces something you could actually publish: a specific voice, the right length, a clear ending. Same model, wildly different result. The only thing that changed was the prompt (the instructions you give the AI).
That difference is not luck. It comes from four ingredients you can add to any request.
1. Role: who the AI should act as.
2. Context: the background and audience it needs.
3. Task: the specific thing you want done.
4. Constraints: the limits and format.
You don't always need all four, but when an output disappoints, a missing piece is usually why. Let's take them one at a time.
A role sets the perspective and vocabulary the model uses. "You are a tax accountant" and "you are a stand-up comedian" will explain the same topic in completely different ways.
Examples you can drop in:
The role is a quick way to aim the tone and depth. Without it, the model defaults to a bland, average voice.
Context is everything the AI can't guess: who the output is for, what came before, what matters to you.
Compare:
The second version gives the model facts to work with, so it stops inventing and starts helping. A simple test: if a new freelancer couldn't do the task with the info you gave, the AI can't either.
The task is the verb: summarize, draft, compare, rewrite, brainstorm, translate. Be specific about the deliverable.
One prompt, one clear job. If you need several things, list them as numbered steps rather than cramming them into one sentence.
Constraints shape the final form. They include:
Constraints are where most people leave value on the table. "Keep it to two sentences a customer could understand" turns a wall of text into something usable.
Here is the template as a fill-in-the-blank:
> Role: You are a [role].
> Context: [background, audience, relevant facts].
> Task: [the specific thing to produce].
> Constraints: [length, format, tone, things to avoid].
A worked example for a real scenario, writing a job description:
> You are an experienced HR manager. We're a 12-person bakery hiring our first delivery driver. The role is part-time, mornings, local routes only. Write a job posting that feels warm and human, not corporate. Keep it under 250 words, use short paragraphs, and include a bulleted list of 4 requirements.
Notice you can read off all four parts. That structure is the whole trick.
A common myth: longer prompts are always better. Not true. A focused 4-line prompt beats a rambling paragraph. You're not trying to write *more*, you're trying to remove guesswork.
Think of it like ordering at a restaurant. "Food, please" forces the kitchen to guess. "A medium-rare burger, no onions, side salad instead of fries" gets you exactly what you want. The four parts are just a way to order clearly.
🎬 [VIDEO: "How to Write Better ChatGPT Prompts" - youtube.com - a short, beginner-friendly walkthrough of structuring prompts with roles, context, and constraints]
The same template works on every major assistant, with small differences in flavor.
The mindset to carry across all three: you are the director, the model is the actor. It will perform whatever role you assign with whatever context you provide. Vague direction, vague performance.
For more structured examples to copy, the OpenAI prompt examples library is free and a useful place to see patterns.
If you ever call a model through an APIAPIApplication Programming Interface: a standardised interface that lets applications communicate and exchange data without knowing each other's internal workings.Voir la définition complète → (a way for programs to talk to the AI directly), the four parts show up as clean, separate fields. This Python snippet uses the OpenAI library, but the structure is identical to what you'd type by hand:
from openai import OpenAI
client = OpenAI()
response = client.chat.completions.create(
model="gpt-5.1",
messages=[
# Role + Constraints often live in the "system" message
{"role": "system", "content":
"You are a friendly nutritionist, not a doctor. "
"Keep answers under 100 words. Avoid medical jargon."},
# Context + Task go in the "user" message
{"role": "user", "content":
"I'm a busy parent who skips breakfast. "
"Suggest 3 quick, healthy breakfast ideas under 5 minutes."},
],
)
print(response.choices[0].message.content)You don't need to code to use the template. But seeing it laid out this way shows that "system" (role and rules) and "user" (context and task) are the same four ingredients, just sorted into boxes.
Vérification des acquis
1. According to the lesson, what are the four ingredients of a strong prompt?
2. In the lesson, what role does the 'Role' component primarily play in shaping the output?
3. The lesson notes you don't always need all four parts. When does a missing piece usually become apparent?
4. Select ALL correct answers. Based on the coffee caption example, which elements were specified in the strong prompt?
Sélectionnez toutes les réponses correctes.
5. Select ALL correct answers. According to the lesson, which statements about Context in prompts are accurate?
Sélectionnez toutes les réponses correctes.
Mistake: Asking for everything at once.
"Write a business plan, a logo idea, a tagline, and a budget." Break it into separate prompts. The model does each better when it focuses.
Mistake: No audience.
"Explain inflation." For whom? Add "to a 10-year-old" or "to a finance student." Audience is the fastest quality boost you can add.
Mistake: Forgetting the format.
If you wanted a table and got paragraphs, you didn't ask. Add "as a table with columns for X and Y."
Mistake: Accepting the first draft.
The prompt is a conversation starter, not a one-shot. Follow up: "Make it shorter," "More casual," "Add an example." Iterating is normal and expected.
Take any real task on your plate right now. Fill in the four blanks:
Paste it into ChatGPT, Claude, or Gemini. Then do the lazy version ("write me X") and compare. The gap you see is exactly the value of this lesson.