Learn · Module 08 · Prompting and context · Lesson 1 of 6
Anatomy of a prompt
A good prompt isn't clever wording. It's a complete brief: who the model is, what to do, what to work from, and what to hand back.
- A prompt is a brief: role, task, context, examples, format and constraints.
- Say what to do when information is missing, or the model will make it up.
- Mark the material clearly with tags so it can't be confused with instructions.
In plain words
A model only knows what's in its context window. If your prompt leaves something out, the model fills the gap with a guess. Most bad outputs are missing information, not a bad model.
Think of the prompt as a brief for a capable new colleague who knows nothing about your company. A complete brief has six parts.
| part | what it answers |
|---|---|
| Role | Who are you, and who is this for? |
| Task | What exactly should be done? |
| Context | What material should you work from? |
| Examples | What does a good answer look like? |
| Format | What shape should the answer have? |
| Constraints | What must you never do, and what if you're unsure? |
Worked example: fixing a vague prompt
A support team wants ticket summaries. Here is the first attempt.
Summarise this ticket.
{ticket}The model has to guess the length, the reader, what matters, and the layout. Each run will guess differently. Now add the missing parts one at a time.
- 1Role and task
Say who the summary is for and what it's used for. That alone decides what's worth including.
You write summaries of support tickets for engineers who must decide what to fix next.
- 2Format
Name the fields and the length, so every summary looks the same.
Reply with three lines: Problem: one sentence. Impact: who is affected and how badly. Next step: one action.
- 3Constraints
Say what to do when the information isn't there. Without this, the model invents it.
Use only what the ticket says. If the impact isn't stated, write "Impact: not stated".
- 4Context, clearly marked
Put the ticket inside tags, so the model can't mistake the customer's words for your instructions.
<ticket> {ticket} </ticket>
You write summaries of support tickets for engineers who must decide what to fix next.
Reply with three lines:
Problem: one sentence.
Impact: who is affected and how badly.
Next step: one action.
Use only what the ticket says. If the impact isn't stated, write "Impact: not stated".
<ticket>
{ticket}
</ticket>A prompt says: 'Classify this review as positive or negative.' The model sometimes answers 'Mixed' or writes a paragraph. Which part is missing?
What to remember in practice
Most chat models take a system prompt and user messages. Put the lasting brief (role, format, constraints) in the system prompt, and the material for this request in the user message.
Examples are the strongest tool you have. Two or three input and output pairs teach tone and format better than a paragraph of description. Choose varied examples, or the model will copy the one you gave too closely.
When output is wrong, don't add 'be accurate' or capital letters. Ask what information the model was missing, and add that.
Common mistakes
- Writing vague instructions like 'be concise' instead of saying exactly what the output should contain.
- Judging a prompt on two or three examples you tried by hand instead of a test set.
- Burying the most important instruction in the middle of a long prompt.
Answer in your own words, out loud or on paper, before you open the model answer.
How do you approach writing a prompt for a new task?
I start by writing down what a good output looks like, with a few real example inputs and the answers I'd want, including tricky cases. Then I write the prompt in parts: the role and the task, the context the model needs, clear rules including what to do when it can't answer, the exact output format, and one or two examples if the format is unusual. I keep instructions specific, so 'reply in under 80 words with the order number first' rather than 'be brief'. Then I run it on a small evaluation set, look at the failures, and change one thing at a time. Once it's good, those examples become regression tests for future changes.
- A prompt works on your examples but fails for users. How do you debug it?
- What goes in the system prompt versus the user message?
Go further
- DocsPrompt engineering overviewClaude Docs
- DocsPrompt engineering guideOpenAI
- ArticlePrompt EngineeringLilian Weng