A good AI prompt has four parts: a role, the context, the task and its output format, and the constraints. Name those four parts, fill each one in a single line, and almost any vague request turns into a reliable one in about five minutes. The structure is model-agnostic. It works the same whether you type into ChatGPT, Claude, Gemini, or an API call, because all of these models reward the same thing: specific input that leaves little to guess.
Most prompting advice buries this skeleton under 200-prompt listicles and acronym soup. The transferable idea is small enough to memorize. This guide gives you the four-part frame, before-and-after rewrites you can copy, and the failure modes that quietly wreck otherwise-decent prompts.
You don't have a bad model. You have a thin prompt. Fix the prompt before you blame the model.
The four-part skeleton of a good AI prompt
A good AI prompt has four slots, filled in order: role, context, task and format, and constraints. You do not need every slot for every task, but naming them is what stops you sending a one-line request and getting a one-line disappointment.
- Role: who the model should act as. 'You are a senior tax accountant.' This sets vocabulary, tone, and depth.
- Context: the facts the model needs and cannot infer. Who the output is for, the source material, the situation, the prior decisions.
- Task and format: the single thing you want done, plus the exact shape of the answer. 'Summarize this in five bullet points' beats 'summarize this.'
- Constraints: the boundaries. Length, what to exclude, tone, reading level, words to avoid, the rule the answer must not break.
This maps cleanly onto what the major vendors publish. OpenAI's best-practices guidance tells you to be specific and descriptive about context, outcome, length, format, and style, and to leave as little to interpretation as possible. Anthropic's prompting best-practices docs cover the same ground: be clear and direct, name the task explicitly, give the model a role, and be specific about the desired output format. The four-part frame is just those instructions wearing a name you can recall under pressure.
The fast diagnostic: if you reread your prompt and cannot point to all four parts, the missing one is usually where the model went wrong.
Part 1: Role sets the lens
A role tells the model what expertise and tone to load before it reads your task. Compare two prompts. 'Explain compound interest' and 'You are a high-school math teacher. Explain compound interest to a 15-year-old' produce noticeably different answers. The second one constrains vocabulary, pacing, and the examples the model reaches for, because a teacher aiming at a 15-year-old picks simpler numbers and everyday analogies on its own.
Roles are most useful when the same facts could be written for very different readers. A role of 'patent attorney' and a role of 'science journalist' summarizing the same document will weight precision versus readability differently. The attorney version hedges and cites; the journalist version cuts to the takeaway. Skip the role only when the task is so mechanical that tone does not matter, such as reformatting a list or extracting dates from a block of text.
Pair the role with the audience: 'You are a pediatrician writing for new parents.' The audience often shapes the output more than the role does, and naming both removes two layers of guessing at once.
Part 2: Context is the part people skip
Context is the single biggest lever, and the one people drop first. The model knows nothing about your project, your last three decisions, or the document on your screen unless you paste it in. Grounding the request in real source material is one of the most reliable ways to get accurate answers, because the model draws from what you supplied instead of filling gaps with plausible-sounding invention.
Good context answers the questions a competent stranger would ask before starting. What is this for? What already exists? What tone or stack or brand rules apply? A useful test: imagine handing the task to a sharp new hire who has never seen your work. Every fact you would have to tell them out loud is a fact the model needs in the prompt. When you paste reference text, separate it from your instructions with a clear marker so the model knows which part is data and which part is the order. OpenAI's guidance recommends putting instructions first and fencing the source material with triple quotes or a heading.
- Weak context: 'Write a cold email to a prospect.'
- Strong context: 'Write a cold email. The recipient is a CFO at a 200-person logistics firm. We sell route-optimization software that cut fuel cost 12 percent for a comparable client. We have never spoken. Goal: a 15-minute call.'
The strong version is not better because it is longer. It is better because every clause closes a question the model would otherwise answer for you, usually wrong. Without the firm size it guesses an industry; without the result it invents a benefit; without the goal it writes a closing line that asks for the wrong thing.
Part 3: Task and format, stated as one thing
Name one task and the exact shape of the answer. Vague verbs like 'help with' or 'look at' invite the model to wander. 'Rewrite the paragraph below to half its length, keeping the two statistics' tells it precisely what done looks like. If a request really contains several tasks, split them or number the steps; bundling four asks into one sentence is how outputs drift.
Format is the highest-return, lowest-effort instruction you can add. Stating the output shape, a numbered list, a three-row markdown table, a JSON object, two plain paragraphs, locks the model into that structure from the first token and makes the result easier to scan, paste, or parse. Anthropic's docs emphasize controlling the format of responses and being specific about the desired output, and they note that showing one or two examples is one of the most reliable ways to steer that format. The practical move is to ask for the format you actually need downstream, not the one that happens to come out.
If you will reuse the output in a spreadsheet or code, say so: 'Return a markdown table with columns Name, Role, Email.' Asking for the destination format saves a manual cleanup pass every single time.
Part 4: Constraints draw the boundaries
Constraints tell the model what not to do and where the edges are. Length caps, banned words, reading level, tone, the requirement to cite only the pasted source, the instruction to ask before assuming. Constraints are where you encode the judgment a human editor would apply. They also prevent the two most common annoyances: answers that are too long and answers that confidently include something you did not want.
- Length: 'Under 150 words.' 'Exactly five bullets.'
- Exclusions: 'Do not mention pricing.' 'Avoid jargon a non-engineer would not know.'
- Tone and level: 'Plain English at an eighth-grade reading level.' 'Formal, no exclamation marks.'
- Honesty rails: 'If the source does not contain the answer, say so instead of guessing.'
A constraint the model can check itself, like a word count or a required column, is worth more than a vague one like 'keep it concise.' Concrete limits are enforceable; adjectives are negotiable.
Before and after: the whole frame in action
Here is a typical weak prompt and its four-part rewrite. The rewrite is longer, but not because it is padded. It is longer because each added clause removes a guess the model would otherwise make for you.
- Before: 'Write some social posts about our new feature.'
- After: 'Role: you are a B2B social copywriter. Context: we shipped offline mode for our note app; it lets users edit notes with no internet and sync later. Audience is busy professionals on LinkedIn. Task and format: write three LinkedIn posts, each under 60 words, each ending with a question. Constraints: no hashtags, no emoji, do not use the word game-changer, keep claims to what offline editing actually does.'
Run that and you get usable drafts on the first try. Run the 'before' version and you get generic filler you then have to coach into shape over several rounds, correcting the length, the platform, and the made-up claims one reply at a time. The four-part frame just front-loads that coaching into the first message.
Where examples fit in
Few-shot prompting means showing one or two examples of the output you want. It layers on top of the four-part frame rather than replacing it. When a format is hard to describe in words, a sample is faster than a paragraph of instructions. The structure stays the same; you are just demonstrating the format slot instead of specifying it. Rule of thumb: if you can describe the format in one sentence, specify it; if you keep failing to describe it cleanly, show a sample instead. For a full walkthrough of when examples beat instructions, see the dedicated guide on few-shot prompting.
Common failure modes
Most bad outputs trace back to a thin prompt, not a weak model. Here are the recurring patterns:
- All task, no context: the model invents the facts it was not given.
- No format: you get a wall of prose you have to restructure by hand.
- Stacked tasks: four requests in one sentence, so the model does two well and forgets the rest.
- Vague constraints: 'professional and concise' means different things to the model than to you. Quantify them.
- One-shot perfectionism: expecting the first prompt to nail it instead of refining. Vendors describe prompting as iterative for a reason.
| Prompt part | Vague version | Four-part version |
|---|---|---|
| Role | (none) | You are a UX writer for a banking app. |
| Context | (none) | Users see this error after a failed transfer; tone must reassure, not alarm. |
| Task and format | Write an error message. | Write one error message under 20 words, plus a one-line next step. |
| Constraints | (none) | No jargon, no blame language, do not promise a refund timeline. |
Why this frame keeps working
Here is what most prompting guides will not tell you: the 200-prompt packs and 'ultimate template' threads are selling you the opposite of the actual skill. Memorizing other people's prompts keeps you dependent on the next list. Learning the four slots once makes every prompt you will ever write your own. The role, context, task and format, constraints model has held across model generations and vendors, which is a strong signal that it is structural, not a trick tuned to one release. Coursera's 2026 ChatGPT-prompts guide reaches the same destination with a modular approach, breaking a prompt into a role or persona, the task or goal, the context and constraints, and an output specification. The labels differ; the underlying slots do not.
Stop retyping the same context every time
Of the four parts, context is the one you rebuild over and over: the same project facts, brand rules, and source documents, retyped into prompt after prompt. The role you can recall in a phrase, the task changes each time, and constraints are short. Context is the heavy, repetitive slot, and it is the one that decays fastest when you are moving quickly. That repetition is where a memory layer helps. MemX is a consumer AI memory app, an external memory over your own documents, photos, notes, and chats across Android, iOS, and WhatsApp. It lets the relevant context travel with you so the context slot is already filled instead of pasted fresh each time. MemX is private by architecture, with per-user keys, encryption at rest, and an on-device first pass over your data.
A five-minute checklist
- Did I give the model a role or audience when tone matters?
- Did I paste or state every fact it cannot know? Fence source text clearly.
- Is there exactly one task, and did I name the output format?
- Are my constraints quantified, with limits the model can check itself?
- If the first output misses, refine one slot rather than rewriting from scratch.
01how do you write a good prompt for AI
Build it from four parts: a role for the model to play, the context and facts it cannot infer, one task with an explicit output format, and clear constraints like length and exclusions. Naming all four slots turns a vague request into a specific, reliable one in minutes.
02what are the parts of a good AI prompt
Role, context, task and format, and constraints. Role sets tone and expertise, context supplies the facts, task and format define exactly what to produce and in what shape, and constraints draw the boundaries. You do not need all four every time, but missing context is the most common cause of bad output.
03does the same prompt structure work for ChatGPT, Claude, and Gemini
Yes. The role, context, task and format, constraints frame is model-agnostic because every major model rewards specific, well-scoped input. OpenAI, Anthropic, and Coursera all publish the same core advice under different names, so the skeleton transfers across tools and across model versions.
04why is context the most important part of a prompt
Context is the facts the model cannot infer: your project, prior decisions, the document on your screen. It is the biggest lever and the part people drop first. Grounding a request in real source material you supply is one of the most reliable ways to get accurate answers instead of plausible-sounding invention.
05why does specifying an output format improve AI responses
Stating the format, such as a five-bullet list or a three-row table, locks the model into that structure from the first token, so the answer is easier to scan, paste, or parse. Vendor docs consistently recommend specifying the exact output format because it improves usability and makes the result easier to reuse.
