Fundamentals · 9 min read

How to write AI prompts: a complete framework

Learn how to write AI prompts with a 7-part framework: role, context, task, constraints, format, examples and iteration, plus before/after rewrites.

Knowing how to write AI prompts is less about magic phrases and more about briefing. A language model starts every conversation knowing nothing about you, your project or what "good" looks like to you. Everything it needs has to be in the prompt. This guide gives you a seven-part framework you can apply to any chatbot (ChatGPT, Claude, Gemini, Copilot or an open model), shows three before/after rewrites, and ends with a template you can reuse.

Why most prompts get generic answers

When an answer feels bland, the cause is usually missing information, not a weak model. A request like "write a blog post about remote work" leaves dozens of decisions open: who is reading, how long it should be, which angle to take, what tone fits, and whether you want a draft or an outline. The model fills each gap with the most average choice, and the result reads like it was written for nobody in particular.

A useful way to think about it: imagine handing the same request to a skilled freelancer who has never met you. Whatever they would need to ask before starting is exactly what your prompt is missing. The framework below turns those questions into seven short building blocks. You will rarely need all seven, but checking each one takes seconds.

BlockQuestion it answersTypical length
RoleWho should the AI act as?One sentence
ContextWhat situation, audience and material is involved?Two to six sentences
TaskWhat exactly should it produce?One sentence with a clear verb
ConstraintsWhat limits apply?A short list
FormatWhat shape should the answer take?One line
ExamplesWhat does "good" look like?Optional, one short sample
IterationHow will you refine it?Follow-up messages

Role and context: who the AI is and what it is working with

A role sets expertise and point of view. "You are a senior B2B copywriter" produces different vocabulary and priorities than "You are a high-school teacher". Keep it to one sentence and make it relevant: a role only helps when it changes how the task should be done.

Context is where most of the quality comes from. Include the facts the model cannot guess: your product, your reader, what you already tried, what you have to work with, deadlines and the purpose of the result. If you paste source material (notes, a draft, a transcript), label it clearly so the model knows it is material to use rather than instructions to follow.

Role: You are an experienced customer-support lead at a small software company.

Context: We sell a time-tracking app to freelance designers. A customer was
charged twice this month because of a billing bug we have already fixed.
She is upset and has threatened to cancel. We can refund the duplicate charge
and offer one free month.

Notice that the context answers the freelancer questions in advance: who the customer is, what went wrong, and what you are allowed to offer. Without that last sentence, the model might invent a compensation you cannot give.

Task and constraints: one clear job with clear limits

State the task as a single action with a strong verb: write, summarize, compare, rewrite, classify, plan, extract. If you need several outputs, number them. Vague verbs like "help me with" or "do something about" force the model to guess what the deliverable is.

Constraints turn a reasonable answer into the answer you can actually use. The most useful ones are length ("under 120 words"), scope ("only the pricing section"), inclusions ("mention the refund timeline"), exclusions ("do not promise future features"), and reading level ("for readers new to the topic"). Positive instructions tend to work better than long lists of prohibitions, so where you can, say what to do instead of only what to avoid.

Task: Write a reply email to this customer.

Constraints:
- Under 150 words
- Apologize once, clearly, without blaming the customer or the bank
- Confirm the refund and say it can take a few business days to appear
- Offer the free month as a thank-you for her patience
- Do not mention internal details of the bug

Format and examples: show the shape of the answer

Ask for a format explicitly: a table with named columns, a numbered list, an email with a subject line, valid JSON with given keys, or three variations to compare. Format requests also make answers easier to scan and reuse. If the output feeds another tool, describe the structure exactly, including field names.

Examples are the fastest way to communicate style. One short sample of the tone you like often does more than a paragraph of adjectives. Keep examples short and say what to copy from them ("match the tone and sentence length, not the topic"), otherwise the model may reuse their content too.

Format: Subject line, then the email body. Plain text, no Markdown.

Example of our usual tone (match the warmth and brevity, not the content):
"Hi Marco, thanks for flagging this so quickly. You're right, and it's fixed.
I've added a credit to your account. Anything else, just reply here. Ana"

Iteration: treat the first answer as a draft

Even a well-built prompt rarely produces a perfect first answer, and that is normal. The trick is to give feedback the same way you would to a person: specific and actionable. "Make it better" gives the model nothing to work with. "Cut the second paragraph, make the apology one sentence, and move the free month to the end" does.

Useful follow-ups to keep in your back pocket:

  • Ask for options: "Give me three alternative subject lines with different tones."
  • Ask what is missing: "Before you rewrite, list any information you would need to make this stronger."
  • Ask for a critique: "Review your draft against my constraints and fix anything that does not meet them."
  • Lock what works: "Keep the first paragraph exactly as it is and only rewrite the closing."

If you keep correcting the same issue, move that correction into the original prompt. Over time your prompts become reusable templates rather than one-off messages.

Before and after: three rewrites

1. A study request

Before:
Explain photosynthesis.

After:
You are a patient biology tutor. I am a first-year nursing student who
struggles with chemistry. Explain photosynthesis in under 250 words using
one everyday analogy. Then give me 3 multiple-choice questions to check my
understanding, with the answers listed at the end.

The rewrite adds a role, an audience, a length limit, a teaching method and a second deliverable. The topic did not change, but the answer becomes something you can study from.

2. A work summary

Before:
Summarize this meeting.

After:
Summarize the meeting transcript below for a manager who did not attend.
Use three headings: Decisions, Open questions, Action items (with owner and
due date if mentioned). Maximum 200 words. If something is unclear in the
transcript, say so instead of guessing.

Transcript:
"""
[paste transcript]
"""

Headings make the output predictable, the reader is defined, and the last instruction reduces invented details. The triple quotes separate material from instructions.

3. A marketing idea

Before:
Give me Instagram captions for my bakery.

After:
You write social media copy for small local businesses. My bakery in a
quiet neighborhood is launching a sourdough subscription (one loaf per week,
pick up on Saturdays). Audience: busy parents nearby. Write 5 Instagram
captions under 40 words each, friendly and a little playful, each ending with
a different call to action. Avoid the words "artisanal" and "elevate".

A reusable template and a quick checklist

Here is the framework as a fill-in template. Delete any block that does not apply.

## Role
You are [expertise relevant to the task].

## Context
[Who I am, who the result is for, background, material to use]

## Task
[One clear action verb + the deliverable]

## Constraints
- [Length]
- [Must include]
- [Must avoid]

## Output format
[Table / list / email / JSON with these keys]

## Example (optional)
[Short sample of the style you want]

Before you send a prompt, run through five quick questions: Is the task a single clear action? Did I include the facts the model cannot know? Is there at least one measurable limit? Did I name the format? Would a stranger understand what "good" means here?

You can also let our tools do part of the work. The free AI prompt generator turns a one-line idea into a structured prompt with role, context, task, requirements and format sections; its Expert mode adds an example slot and a quality check. Paste any prompt you already have into the prompt checker to get a local 0–100 score that flags missing elements such as role, audience, constraints or format. And if you want ready-made starting points, browse the prompt library. When you are comfortable with the basics, the next step is our guide to prompt engineering techniques such as few-shot examples and decomposition.

Frequently asked questions

How long should an AI prompt be?

Long enough to include the information the model cannot guess, and no longer. Simple questions can be one sentence. Tasks with an audience, constraints and a format usually land between 50 and 300 words. If you paste reference material, that can be much longer, as long as the instructions are clearly separated from it.

Do I need to start every prompt with "You are…"?

No. A role helps when expertise or point of view changes how the task should be done, for example a lawyer reviewing a contract versus a teacher simplifying it. For quick factual questions or simple edits, the role adds little and can be skipped.

Does the same prompt work in ChatGPT, Claude and Gemini?

A well-structured prompt works reasonably well in all of them, because the core information (task, context, constraints, format) is the same. Formatting preferences differ slightly; for example, Claude responds well to XML tags. Our comparison guide on ChatGPT vs Claude vs Gemini prompts covers the differences.

Why does the AI ignore some of my instructions?

Common causes are instructions that conflict with each other, constraints buried in the middle of a long block of text, or vague wording. Put key limits in a short list, remove contradictions, and ask the model to check its answer against your constraints before finishing.

Related tools