1. The parts of a prompt
Every prompt is some subset of these seven parts.
1 Task
What to do, and what is true afterward, in a sentence or two.
Add a sign-up screen at /sign-up: a visitor creates an account, then lands on /welcome.
2 Context
The files, the stack and the material to read, fenced so it cannot be read as instructions.
src/features/auth/*, React 18, TypeScript, the shared Field and Button.
3 Constraints
What must hold, and what is out of scope, written as instructions.
Password 12+ characters, message "Use at least 12 characters." No social login.
4 Return
The shape of the answer: format, length, and what to leave out.
One patch, no commentary, nothing outside src/features/auth.
5 Approach
How to work: plan first, one step at a time, ask when a decision is missing.
Read the two files, plan in three bullets, ask before naming anything.
6 Example
One input and the output you want, when the shape of the answer matters.
input: a used email → output: "That email is already registered." above the field.
7 Check
How somebody will judge the answer, ideally by running something.
An empty submit shows both messages; 11 characters sends no request.
2. Which parts each task needs
| The task | Parts that carry it | What you can leave out |
|---|---|---|
| (Standard) Build a feature you can already describe | 1Task 2Context 3Constraints 4Return 5Approach 7Check | The example, unless the format of the answer matters. |
| Fix something that is broken | 1Task (the symptom) 2Context (error and environment) 3Constraints (smallest change) 7Check (the repro) | Return, Approach and Example. A diff is understood. |
| Write copy that matches what exists | 1Task (three messages) 2Context (where they appear) 3Constraints (length and limits) 6Example (two existing messages) 7Check (read beside them) | Return and Approach: the examples fix the shape, and there is nothing to plan. |
| Choose between approaches | 1Task (the question) 2Context (what is fixed) 3Constraints (no code yet) 4Return (options and tradeoffs) 7Check (your criteria) | Example, and code of any kind. |
| Understand code you did not write | 1Task (what you want to do next) 2Context (what you already know) | The other five. There is nothing to build or check. |
| A change with one right answer | 1Task 3Constraints ("nothing else") | The other five. A brief would cost more than the change. |
A part you leave out is a decision you hand over. That is fine when the decision is obvious and cheap to get right, and wrong when it is neither. The cheapest to drop are the example and the return contract. The most expensive is the check, because without it "done" becomes an opinion.
3. Compare a vague prompt with a clear one
Add a sign-up form to my app.
What the model decides for you
- SignUpForm.jsx, plain JavaScript, in the generic
src/componentsfolder - four fields, including a confirm password nobody asked for
- a password rule invented on the spot: 8+ characters, one number
- POST /signup, but the app serves
/api/session/signup - alert('Signed up!'), and no navigation away from the form
- no submitting state, so a double click creates two accounts
- placeholder labels and a
divwithonClick - no tests at all, so "done" means it looked right once
7 words · 8 decisions handed over
Task: Add a sign-up screen at /sign-up. A visitor creates an account with an email and password, then lands on /welcome. Context: <<< src/features/auth/SignUpPage.tsx and useSignUp.ts, React 18, TypeScript, the existing Field and Button, the tokens in src/ui/tokens.css. POST /api/session/signup { email, password } → 201 { userId } | 409 { problem, message } >>> Constraints: password 12+ characters, message "Use at least 12 characters." email required, message "Enter an email address." on 409, show the server's message above the form and keep what was typed. exclude social login, a confirm-password field and a strength meter. Return: one patch, no commentary, nothing outside src/features/auth. Approach: read the two files, plan in three bullets, work one step at a time, ask before naming anything new. Check: an empty submit shows both messages; 11 characters sends no request; one click sends one request; a 409 keeps the email.
What each part did
- Task fixes what "done" means, and what the visitor sees afterward
- Context names the files, the stack and the response shape
- Constraints carry both messages, and where the 409 message appears
- Return keeps the answer small: one patch, nothing else touched
- Approach makes it plan, step, and ask before inventing anything
- Check turns "looks right" into four things to run
147 words · 0 decisions left
What changed Not the length. The facts, and their order. Every block in the second prompt fills a part the first one left to the model, and panel 1 names those parts.
4. Build your prompt
The skeleton is the default: the seven parts in the order below, with the blanks left blank. Pick an example to see the same parts filled for a feature, a fault, a decision or a rename, then replace it with your own. The seven rules under the fields say why the order matters.
Nothing is filled yet. The skeleton shows the seven parts and where each one goes. Pick an example to see one filled.
Task: <what to do, and what is true afterwards> Context: <<< <files, stack, material to read> >>> Constraints: <what must hold> <what is out of scope> Return: <format, length, what to leave out> Approach: <plan first, ask, one step at a time> Example: <one input and the output you want> Check: <how the answer will be judged>
seven parts, nothing filled
The order the parts go in
- 1. Start with the task. The instruction sits above the material, before anything else. A model that reads the ask first has something to hang the context on.
- 2. Fence the context. Triple quotes or tags around pasted material. Unfenced text can be read as an instruction, and formatting alone moves accuracy by large margins.
- 3. Restate the line you cannot lose. In a long prompt the start and the end are read better than the middle, so close with the one requirement that matters.
- 4. Separate the reply from the thinking. Say what to return, not how to reason. Forcing a rigid output schema measurably costs accuracy.
- 5. Say what to do, not only what to avoid. A prohibition leaves the model guessing at the alternative.
- 6. Ask for the plan before the work. A task with steps goes better staged or split than in one instruction.
- 7. Ask for the check. An answer with something runnable beats an answer that sounds right.
5. Find the vague words
Both panels hold the same prompt. The left is what was sent and the right marks the words that contribute nothing to decision making. No two people would build the same thing from them and the model is not going to be the exception. Replace each one with a fact. The table below shows the swap.
Your prompt
as sent
What a model has to invent
6 empty words · replace each one with a fact
| What got written | What the model has to invent | What to write instead |
|---|---|---|
| "make it modern" | a color, a font, a radius, a spacing scale | the tokens in src/ui/tokens.css; no new colors, fonts or shadows |
| "add validation" | a rule, a regex, a message, a moment to fire | password 12+ characters → "Use at least 12 characters." on blur |
| "handle errors" | which errors, where they appear, what survives | 409 → the server's message above the form; the typed email is kept |
| "make it responsive" | a breakpoint, a layout, a minimum target size | single column under 600px; 24px gaps; nothing overlaps at 320px |
| "it doesn't work" | which screen, which click, which error, what you expected | clicking Submit on /sign-up with a used email leaves the form blank, with no request in the Network tab |
| "a nice loading state" | when it starts, when it ends, what it says | submitting → the button reads "Creating account..." and is disabled |
The test If two people could build different things from a sentence, it is not a detail. It is a preference. Say the path, the status, the sentence, or the number, and it becomes a requirement.
6. Before you send
What does not help
"You are a senior engineer" does not measurably improve answers, and a 2024 comparison found personas can make them worse. Use a role line for tone, if you use one at all.
Adding stakes or pleading shows small, unstable effects. It is not a substitute for a better instruction, and it costs attention you could spend on the check.
Forcing the answer into strict JSON measurably lowers accuracy on reasoning tasks. Put the shape on the reply, not on the thinking.
The takeaway Structure is the cheap part. Seven parts, one order and a check you can run is most of what the published comparisons support, and none of it needs a clever sentence.
Sources
- Formatting alone moves scores by tens of points. Quantifying Language Models' Sensitivity to Spurious Features in Prompt Design, Sclar, Choi, Tsvetkov and Suhr, ICLR 2024.
- Models read the start and end of a long prompt better than the middle. Lost in the Middle: How Language Models Use Long Contexts, Liu et al., TACL 2023.
- In-context learning, where examples began. Language Models are Few-Shot Learners, Brown et al., NeurIPS 2020.
- Demonstrations teach format more than facts. Rethinking the Role of Demonstrations: What Makes In-Context Learning Work?, Min et al., EMNLP 2022.
- The original reasoning prompt. Chain-of-Thought Prompting Elicits Reasoning in Large Language Models, Wei et al., NeurIPS 2022.
- "Think step by step" without any examples. Large Language Models are Zero-Shot Reasoners, Kojima et al., NeurIPS 2022.
- Sample several answers, keep the majority. Self-Consistency Improves Chain of Thought Reasoning in Language Models, Wang et al., ICLR 2023.
- Break a hard task into easier ones, in order. Least-to-Most Prompting Enables Complex Reasoning in Large Language Models, Zhou et al., ICLR 2023.
- Give each sub-task its own prompt. Decomposed Prompting: A Modular Approach for Solving Complex Tasks, Khot et al., ICLR 2023.
- Interleave reasoning with tool calls. ReAct: Synergizing Reasoning and Acting in Language Models, Yao et al., ICLR 2023.
- Answer, critique the answer, revise. Self-Refine: Iterative Refinement with Self-Feedback, Madaan et al., 2023.
- Strict output formats cost accuracy on reasoning. Let Me Speak Freely? A Study on the Impact of Format Restrictions on Performance of Large Language Models, Tam et al., 2024.
- Real GitHub issues as the test bed for repo-level work. SWE-bench: Can Language Models Resolve Real-World GitHub Issues?, Jimenez et al., ICLR 2024.
- A plain localise, repair, validate pipeline beats complex agents. Agentless: Demystifying LLM-based Software Engineering Agents, Xia et al., 2024.
- Expert personas do not improve answers. When "A Helpful Assistant" Is Not Really Helpful: Personas in System Prompts Do Not Improve Performances of Large Language Models, Zheng et al., Findings of EMNLP 2024.
- The survey that counts the techniques. The Prompt Report: A Systematic Survey of Prompt Engineering Techniques, Schulhoff et al., 2024.
- OpenAI's prompt guide. Prompt engineering.
- Anthropic's prompt guide. Prompt engineering overview.
- Google's whitepaper on prompting. Prompt Engineering, hosted on Kaggle.
- Microsoft's guide to prompting techniques. Prompt engineering techniques.