Lesson 11 of 1570
The Five-Part Prompt: Role, Context, Examples, Constraints, Format
Pro prompters follow a structure. Give the AI a role, set the context, show examples, set constraints, and pick a format. This framework alone 10x's your output quality.
Lesson map
What this lesson covers
Learning path
The main moves in order
- 1The anatomy of a serious prompt
- 2role assignment
- 3context setting
- 4few-shot examples
Concept cluster
Terms to connect while reading
Section 1
The anatomy of a serious prompt
Quick prompts work for quick tasks. But when you want something solid — a first draft of an essay, a piece of code, a study plan — you need structure. Most professional prompt engineers use some version of this five-part recipe.
Compare the options
| Part | What it does | Example phrase |
|---|---|---|
| Role | Sets the AI's persona and expertise | 'You are an experienced 8th-grade history tutor...' |
| Context | Tells the AI the situation | 'I'm preparing for a unit test on the American Revolution...' |
| Examples | Shows what good output looks like | 'Here's an example of the kind of study note I want: ...' |
| Constraints | Sets rules and limits | 'Keep each note under 50 words. Avoid jargon.' |
| Format | Defines the shape of the output | 'Output as a bulleted list with bolded terms.' |
Putting it all together
The five-part structure in action.
You are a patient middle-school math tutor who loves real-world analogies.
I'm a 7th grader studying for a test on linear equations. I understand what a variable is but I struggle with word problems.
Here's the kind of hint I find helpful:
> 'Think of x as how many apples are in the bag — your job is to figure out what number makes the sentence true.'
Constraints:
- No solving the problem for me.
- Give one hint at a time.
- Use analogies, not algebra vocabulary.
Format your response as:
**Hint:** <one sentence>
**Try this:** <one guiding question>
Here's my problem: A bookstore sells paperbacks for $8 and hardcovers for $15. They sold 12 books total and made $128. How many of each did they sell?Notice how every part has a job. The role puts the AI in tutor mode. The context tells it what you know. The example models the tone you want. The constraints stop it from spoiling the answer. The format makes the output scannable. You will get a wildly better response than 'help me with this math problem.'
Why role matters so much
When you tell the AI 'you are an experienced editor' or 'you are a skeptical scientist,' it shifts its whole voice. It pulls on different patterns from its training. This one line often changes the answer more than any other part of the prompt.
- 'You are a careful research assistant who cites sources.'
- 'You are a senior software engineer reviewing a junior's code.'
- 'You are a Socratic teacher who only asks questions back.'
- 'You are a stand-up comedian writing jokes for a school talent show.'
Key terms in this lesson
End-of-lesson quiz
Check what stuck
15 questions · Score saves to your progress.
Tutor
Curious about “The Five-Part Prompt: Role, Context, Examples, Constraints, Format”?
Ask anything about this lesson. I’ll answer using just what you’re reading — short, friendly, grounded.
Progress saved locally in this browser. Sign in to sync across devices.
Related lessons
Keep going
Builders · 22 min
Iterate, Don't Rewrite
Beginners scrap their prompt and start over. Pros keep the good parts and change only what isn't working. Here's how to iterate like a craftsperson.
Builders · 30 min
Structured Output: JSON and XML
When your prompt feeds into code, you need machine-readable output. JSON mode and XML tags make the AI's response parseable instead of loose prose.
Builders · 24 min
Prompt Templates: Write Once, Use Forever
Turn your best prompts into reusable templates with variables. This is how pros scale: one great template, thousands of runs.
