The anatomy of a prompt: instruction, context, input and output
Write a structured prompt with labelled instruction, context, input and output sections.
Four parts of a well-structured prompt
Most effective prompts contain the same four ingredients, whether or not they are labelled:
| Part | Answers | Example |
|---|---|---|
| Instruction | What should the model do? | "Classify each piece of feedback as praise, complaint or suggestion." |
| Context | What background does it need? | "Feedback comes from a weekend cookery course for beginners." |
| Input data | What material should it work on? | The pasted feedback comments |
| Output specification | What should the answer look like? | "A table with columns: Comment, Category, One-line reason." |
Not every prompt needs every part — a quick question may be only an instruction — but when an output disappoints, the missing or unclear part is usually one of these four.
Order and labels
A dependable layout is:
## Task
(instruction)
## Context
(background, audience, purpose)
## Input
"""
(the material to work on)
"""
## Output format
(exact shape of the answer)
Labels help you as much as the model: you can see at a glance what is missing, and you can swap the input while keeping everything else — the first step towards a reusable template (Module 9).
For long inputs, many practitioners put the material first and repeat the key instruction at the end, so it is close to where the model starts writing. If a model ignores your instruction after a long document, try that.
Delimiters keep data separate from instructions
Delimiters are markers that show where pasted material begins and ends: triple quotes ("""), triple backticks, XML-style tags such as <email> … </email>, or headings. They matter because:
- the model can tell your instructions apart from the text it is analysing;
- you can refer to parts precisely ("Summarise only the text inside ");
- they reduce the chance that instructions inside the pasted text are followed (this lowers, but does not eliminate, prompt-injection risk).
Worked example
Unstructured: "here are some reviews can you tell me what people think and what we should fix, they're for our café"
Structured:
## Task
Identify the three most common complaints and the two most praised features in the customer reviews below.
## Context
We run a small café. The owner will use your analysis to decide what to change first. Be specific — quote short phrases from the reviews as evidence.
## Input
<reviews>
(paste reviews here, with names removed)
</reviews>
## Output format
1. "Top complaints" — a numbered list of 3, each with a one-line description and 1–2 quoted phrases.
2. "Most praised" — a numbered list of 2, same format.
3. "Not enough evidence" — mention any issue raised only once.
Do not suggest causes that are not supported by the reviews.
This version tells the model what to do, why, with what, and exactly how to report it — including what to do when evidence is thin.
When the structure is overkill
For a one-off question ("What does 'amortisation' mean? Two sentences.") a single line is fine. Use the full structure when the task matters, when the input is long, or when you will reuse the prompt.
Practice exercise
Write a structured prompt for a real task of yours (or use: "analyse ten pieces of anonymised feedback about an event").
Submit:
- The full prompt with labelled Task, Context, Input (with delimiters) and Output format sections.
- One sentence explaining why you chose your delimiter.
- If you ran it: one thing in the output that the structure improved, and one thing you would still change.