Anatomy of an outcome-based prompt
An outcome-based prompt has four parts. Write them in this order, because each one shapes the next.
Intent: what, why, for whom
Start from the outcome you already have. If you have an Integration Scenario, it names the user or system, the thread of value they experience and the point at which that value is real. If you have a story, it has a who, a what and a why, and acceptance criteria. If you have neither, you are not ready to prompt. Go and get one; the agent will not invent your intent for you, it will invent something that looks like intent, which is worse.
The intent section says what must be true when the work is done, in the language of the person who wanted it. It says why, because the why is what lets the agent (or a person) make sensible choices when the what is ambiguous, and it always is. It says for whom, because the same feature for an administrator and for a first-time customer is two different pieces of work.
What it does not say is how. If you catch yourself writing “add a column to the table” or “create a service that”, stop. Either that is a constraint (there is a mechanism you must use) and belongs in the next section, or it is a design decision you are making by accident.
Constraints: NFRs, mechanisms, standards
Constraints are the things that must be true of any solution, whichever one the agent picks. Three sources:
- Non-functional requirements, written as checks, not adjectives. Not “it must be fast” but “p95 under 300ms at 200 requests per second”. The fitness functions page explains why; the short version is that an adjective cannot fail a build.
- Architectural mechanisms: the organisation’s common solutions to common problems. Authentication goes through the identity mechanism. Events go on the event bus, in the agreed envelope. Money is a decimal, in the money type. Mechanisms are where you stop the agent reinventing what the team already has, and they are the single most effective way to keep generated code consistent with the rest of the system.
- Standards: coding conventions, the language and framework in use, security baselines, accessibility requirements, the licence policy for dependencies. Most of these should live in a file the agent reads automatically, not in every prompt. Point at it.
Constraints are also where you put the boundary of the change. “Do not change the public API.” “Do not add a dependency without saying so.” “Stay inside this module.” An agent that does not know where the edges are will find them for you, in production.
Context: the model, the code, the decisions
Context is what the agent needs to know to do the work well, that it cannot find out by itself in reasonable time. The temptation is to give it everything. Resist it. A prompt stuffed with the whole codebase and every document the team has ever written is a context dump, and it dilutes the things that matter with the things that do not. An agent, like a person, works better from a clear picture than from a pile.
What belongs:
- The model. The domain model, the Small Picture of the system, the scoping diagram. Whatever the team uses to agree what the words mean, kept in a form the agent can read as well as the team.
- The relevant code. The module being changed, the interfaces it touches and the tests that already exist. Not the whole repository.
- The decisions. Decision records that bear on this change, so the agent does not relitigate a decision the team made last year, and so it knows which of its clever ideas were already rejected and why.
- What done looks like. An example of a previous change that went through the pipeline cleanly, if you have one. Agents imitate well.
Executable acceptance criteria
This is the part that makes the practice work, and the part most people skip. The acceptance criteria of the outcome must be expressed as something that runs: a test, a scenario check, a fitness function, an evaluation, a policy. If they can only be checked by a person reading the output, the prompt is a task with a nicer introduction.
Write the checks before you generate, and write them so that they fail now. A check that passes before the work is done is not checking the work. Then give them to the agent as part of the prompt, and let it run them. A good agent will iterate until they pass. A good pipeline will refuse to merge until they do. Either way, nobody had to read a thousand lines to know whether the outcome was met.
The outcome-driven infrastructure page puts this more bluntly for the infrastructure case: if you cannot write the verify section, you do not have an outcome yet, just an aspiration. It is true of every outcome.
If the agent cannot run the check, write the check first. If you cannot write the check, you do not know what you want yet.
Related
- Fitness functions: non-functional requirements written as checks
- Architectural mechanisms: the constraints that keep generated code consistent
- A worked example, end to end: the four parts in use