A Practical Formula for Better AI Prompts
Use five clear parts—goal, context, boundaries, a way to verify completion, and response format—to give an AI model the information it needs.
A useful prompt gives an AI model five things: the goal, the relevant context, the boundaries, a way to check that the work is done, and the format you want back. This is a practical checklist, not a formula proven to be best for every task. The right amount of detail depends on the model, the work, and the information it can access.
The Prompt Report reviewed 1,565 papers and catalogued 58 text-based prompting techniques. Its authors also compared human-written and automatically optimized prompts on a particular benchmark. A human spent about 20 hours refining a prompt and reached an F1 score of 0.53 on development data; an automated method reached 0.548 on the test set. Those figures describe one experiment, not a universal contest between people and prompt optimization. The report found that the best results came from combining human judgment with automated search.
That is a useful way to think about prompting: there are many techniques, but no universal incantation. A clear request helps the model understand what to do; a repeatable check tells you whether the result worked. For a one-off chat, the five parts can fit in a few sentences. For a code change, each may need a little more detail.
The five-part skeleton
Use this as a starting point
1. GOAL — what is wrong or what result do you need?
2. CONTEXT — which files, data, examples, or functions matter?
3. BOUNDARIES — what must stay unchanged?
4. DONE — what evidence will show the result works?
5. RESPONSE — what should the model show you?Each part is explained below with a weak version and a more useful one. The coding examples are patterns to adapt to your own project.
1. Goal: describe the symptom, not just the topic
Weak: “Fix the login bug.” That names a feature but says nothing about what failed or when. An agent may inspect many unrelated files or fix a plausible problem that is not the one users reported.
More useful:
Users report that sign-in stops working after their session expires.
Start with the authentication flow in src/auth/, especially token
refresh. First write a failing test that reproduces the reported
behavior, then make the smallest change that fixes it.A symptom and a way to reproduce it give the model a narrower problem to investigate. If you have an error message, request ID, or example input, include it.
2. Context: point to the relevant place
A folder or function can reduce unnecessary searching. An existing implementation can be an even clearer reference: the model can read the project’s current conventions instead of guessing from a prose description.
Example:
Look at the widgets on the home page. HotDogWidget.php is a good
example of the project’s conventions.
Use the same approach to build a calendar widget with month selection
and year navigation. Do not add a library that is not already in the
project.Use a representative file, not just a file with a similar name. If the example is outdated or intentionally different, say so.
3. Boundaries: say what must remain intact
When a request leaves important limits unstated, a coding agent may add files, dependencies, or abstractions that the task does not need. State the boundaries that matter and tell the agent what to do if they are insufficient.
Example:
Create POST /api/orders.
Create files only inside Features/Orders/. Do not change Program.cs
except to register the new route. Do not add packages.
Do not introduce an abstraction for a single call. If the task cannot
be completed within these boundaries, explain why before editing.The last sentence gives the agent a way to raise a genuine conflict instead of quietly crossing a boundary or stopping without an explanation.
4. Done: define evidence the model can check
“Make it faster” or “make it look right” is hard to verify without a measurement or visual reference. A concrete acceptance check gives the model evidence to work against.
Example:
GET /api/products takes more than 3 seconds with 1,000 records.
The target is a P99 response time below 200 ms under the same test.
Investigate N+1 queries, missing indexes, and unnecessary change
tracking. First propose changes and their expected effect. Do not edit
until I approve the proposal.For a visual task, use the actual page and a reference screenshot. Ask the agent to capture the result, compare the relevant layout and spacing, list the remaining differences, and correct them. A code diff alone does not show whether the rendered page matches a design.
5. Response: ask for evidence, not just a success claim
A short report is easier to review when it includes the command output or other evidence used to check the work.
Example:
When finished, show:
- the files changed and why;
- the exact verification commands you ran;
- the relevant test or build output;
- any check you could not run and why.
Do not describe a check as passing unless you ran it.The model’s summary is not a substitute for the underlying output. Showing the evidence makes it faster to spot a missed check.
Does “think step by step” improve every answer?
No single wording helps every task. A 2025 meta-analysis of chain-of-thought prompting found larger average benefits on symbolic reasoning, mathematics, and logic benchmarks than on other task groups. Results depend on the task and model. OpenAI’s current guidance says reasoning models usually work well with direct instructions; explicitly asking them to “think step by step” may add little and can sometimes get in the way. State the goal, constraints, and desired output clearly, then evaluate the result.
Sources: ICLR 2025 chain-of-thought meta-analysis and OpenAI reasoning best practices.
The meta-analysis combined results from more than 100 papers with new evaluations across 20 datasets and 14 models. In its task groups, the reported average gain was largest for symbolic reasoning (14.2 percentage points), followed by mathematics (12.3) and logical reasoning (6.9). For the remaining task groups, the aggregate scores were 56.8 with chain-of-thought and 56.1 without it. Those are benchmark averages across the study’s selected tasks; they are not a promise that a phrase will improve a particular answer.
For coding and research, replace a vague request to “think more” with the information the agent needs: what it should inspect, what limits apply, and how to verify its work. If the task involves a difficult proof or multi-step calculation, ask for a concise explanation or intermediate results when that helps you review the answer.
Should you assign the model an expert role?
A role can help set tone or audience, but it does not reliably raise factual accuracy by itself. In one study of 162 personas and 2,410 factual questions across four model families, persona instructions did not improve average accuracy over a no-persona baseline. The result is specific to that study; it does not show that roles never help with style, domain framing, or a particular task.
If you use a role, pair it with the work you need and the evidence it should use. “Act as a senior security reviewer” is less useful on its own than “review these routes for object-ownership checks; cite the file and line for each finding.” Read the persona-prompting study.
The study examined 162 personas and 2,410 factual questions across four model families. The average result did not improve over a prompt with no persona. Choosing the most helpful persona after seeing each question did improve scores, but that is different from knowing in advance which role will help. Other research finds mixed, task-dependent effects. A role is most useful when it communicates the audience, point of view, or voice you need—not when it stands in for missing context or evidence.
Tips, threats, and capital letters
Studies of reward and threat language do not provide a dependable rule that works across tasks and models. One Wharton study found no strong general effect from those prompt variations. Use ordinary, clear language and avoid adding pressure as a substitute for context or a success criterion.
Capital letters are not automatically harmful either. Anthropic’s published Claude Code guidance says emphasis can sometimes improve adherence. Reserve it for a genuinely important requirement and keep the instruction specific. Wharton’s study of tips and threats; Anthropic’s Claude Code best practices.
That means you do not need to ban emphasis or politeness from every prompt. Keep the wording readable and test changes against the same task. A prompt that says “IMPORTANT: preserve the database schema” may be appropriate when that boundary matters. Repeating “CRITICAL” in every paragraph makes it harder to tell which instruction is actually important.
Examples help set the shape of an answer
Examples can show the model what an input looks like, which labels or cases matter, and what structure you want in the output. They do not guarantee that the model will copy the reasoning behind an example. In one 2022 study, randomly changing demonstration labels had little effect on several classification and multiple-choice tasks, while examples still conveyed useful information about the label space, input distribution, and output format. That finding is tied to those tasks and models.
When an exact format matters, first describe it directly. Add a few representative examples when they clarify edge cases, tone, or structure that words alone do not capture. Min et al., “Rethinking the Role of Demonstrations”.
For example, if you need JSON with a fixed set of fields, name those fields and show one valid object. If a classification task has several labels, list the labels and explain what distinguishes them. If you want a particular voice, give an example that demonstrates its sentence length and level of formality. An example should clarify the shape of the result; it should not quietly introduce facts the model is supposed to copy.
Keep prompt formatting consistent when comparing results
Changing headings, separators, spacing, or capitalization can affect a model’s output. An ICLR 2024 study found large accuracy changes from semantically equivalent formatting variations in specific few-shot setups. That does not mean every production prompt is equally fragile. It does mean that when you compare two prompts, keep their structure the same and change one thing at a time.
Read the ICLR study on prompt-format sensitivity.
In one tested few-shot setup, equivalent prompt formats produced accuracy differences as large as 76 percentage points on Llama 2 13B. That is a result from a specific model and benchmark, not a likely swing for every business prompt. The practical lesson is narrower: when you evaluate a wording change, keep headings, separators, examples, and order stable so you can tell which change affected the result.
Strict output formats can trade flexibility for consistency
Structured output is useful when another system needs predictable fields. But some research has found that tight output constraints can hurt reasoning in particular model and task setups. Do not generalize those results to every model’s native JSON or schema mode. If reasoning quality matters, compare the constrained approach with a two-step option: solve the task first, then convert the result to the required format and validate it.
See the EMNLP Industry study on constrained output formats.
A strict format can still be the right choice. It can reduce parsing errors when the next step is software, and it can help a classification task by narrowing the allowed answers. The concern is whether the format restriction interferes with reasoning on your model and task. Measure both correctness and whether the output parses; do not assume one metric tells the whole story.
Long context: test where important information appears
In the 2023 “Lost in the Middle” study, some language models answered questions more accurately when relevant information appeared at the beginning or end of a long input than when it was buried in the middle. The exact results came from older models and benchmark tasks, so they should not be treated as a rule for every current model. For long documents, label sections, keep the question easy to find, and test whether rearranging the material changes the answer.
For GPT-3.5 Turbo in one multi-document question-answering setup, accuracy was 75.8% when the relevant document came first, 53.8% when it was in the middle, and 63.2% when it was last; the closed-book score was 56.1%. The comparison illustrates why position can matter in that benchmark, but it does not establish that every modern model will ignore the middle of every prompt. Put source material in clearly labeled sections, keep the question distinct, and try a small order comparison if the answer is important.
“Check your answer” needs an external signal
Asking a model to review its own answer without new evidence does not guarantee improvement. An ICLR 2024 study found that intrinsic self-correction could reduce reasoning accuracy on some tasks. A test suite, compiler, type checker, database constraint, or independent reference gives the model a signal it can use to find a real error.
Read the study on the limits of intrinsic self-correction. For a three-part prompt focused on goal, questions, and an example, see The Prompting Pyramid.
On one GSM8K mathematics experiment, GPT-4 scored 95.5% before self-correction, then 91.5% after one round and 89.0% after a second. Treat those numbers as a result for that model, benchmark, and procedure. The general point is that asking the same model to reconsider an answer is not the same as checking it against new evidence. If it can run tests, compare against a trusted source, or use a calculator, give it that feedback instead.
Checklist: review a prompt before sending
- The goal names the symptom or the result you need.
- The relevant folder, file, function, data, or example is identified.
- Important boundaries are explicit, with instructions for conflicts.
- “Done” is tied to a test, measurement, screenshot, or other observable check.
- The task asks for evidence and says which checks were actually run.
- Long inputs are clearly labeled, and the placement of key information has been tested when it matters.
- The prompt uses roles or examples only when they help with the task, audience, tone, or output structure.
Start with these five parts, then adjust one instruction at a time based on the results. For another practical framework, read The Prompting Pyramid: Goal, Questions, and an Example.