Generative AI
Prompting as Interface Engineering
Design prompts as versioned model interfaces and evaluate their clarity, robustness, and interaction with application controls.
By the end you can
- Structure prompts around task, context, constraints, output contract, and uncertainty behavior
- Distinguish prompt instruction from application authorization and validation
- Identify ambiguity, conflicting instructions, hidden assumptions, and prompt brittleness
- Develop prompts through evaluation rather than intuition and anecdotal examples
Example
The prompt is an interface contract with an unreliable compiler
A finance assistant receives “Review this contract and flag anything important.” It returns a polished summary but misses the renewal clause that the legal team actually cares about. Three documents later the team agrees the prompt works and ships it.
That approval procedure cannot tell a working prompt from a lucky one. Hold the task, the model and the examples fixed, change only the order the few-shot examples are presented in, and the score moves anyway. Lu and colleagues ran that experiment and reported it at ACL 2022: “We demonstrate that the order in which the samples are provided can make the difference between near state-of-the-art and random guess performance: essentially some permutations are “fantastic” and some not.” The models were GPT-3-family. Good orderings did not transfer between them, so the permutation that made one model look near state-of-the-art was no guide to the next. Their entropy-based selection method recovered a 13% relative improvement across eleven text classification tasks.
A prompt approved on three self-chosen documents rests on exactly the evidence base that cannot separate the prompt from the permutation.
- Undefined task: “Important” has no operational meaning or prioritized risk taxonomy.
- Missing evidence: The prompt does not identify governing policy, jurisdiction, or comparison template.
- Unbounded output: No schema distinguishes clause text, interpretation, severity, and uncertainty.
- No abstention rule: The model fills gaps instead of marking unreadable or ambiguous sections.
- No acceptance test: The team approves the prompt after three documents its author chose. That sample cannot separate a prompt that works from an example ordering that happened to be fantastic — ordering alone spans near state-of-the-art to random guessing.
Specific instructions reduce ambiguity but do not enforce reality
A prompt can define roles, priorities, terminology, and response structure. It can also tell the model to distinguish source text from instructions found inside that source. The model may still misread evidence, ignore a condition, or follow injected content. Permissions, source filtering, schema validation, and transaction controls must remain outside prompt prose.
There are two ways in, and NIST names both in its Generative AI Profile. In the direct case, “attackers might craft malicious prompts and input them directly to a GAI system”. Indirect prompt injection instead “occur[s] when adversaries remotely (i.e., without a direct interface) exploit LLM-integrated applications”. Greshake and colleagues demonstrated the indirect case against real deployed applications in 2023. Such applications blur the line between data and instructions, and an attacker can compromise one by planting a prompt in data the system will later retrieve.
It is no longer only a research demonstration. On 11 June 2025 Microsoft published CVE-2025-32711, “M365 Copilot Information Disclosure Vulnerability”, and described it in a single line: “Ai command injection in M365 Copilot allows an unauthorized attacker to disclose information over a network.” The record classifies the flaw CWE-74. Microsoft rates it CVSS 3.1 base score 9.3, Critical (AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:L/A:N), while recording it as not publicly disclosed, not exploited, and already fully mitigated with no action for users of the service. The National Vulnerability Database carries the identical description and republishes that 9.3 as a secondary metric. But NIST's own primary CVSS 3.1 assessment is 7.5, High (AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N). Two competent parties scored one shipped assistant's injection flaw and did not agree on how bad it is. That is a reason to build the boundary in code, not a reason to argue about the number.
Comparison
Prompt quality is visible in the behavior it makes testable
A longer prompt is not automatically a stronger interface. Wording is not even the largest source of variation. Change the formatting of a few-shot prompt without changing its meaning, and the score moves. Sclar and colleagues measured how far and reported it at ICLR 2024: “We find that several widely used open-source LLMs are extremely sensitive to subtle changes in prompt formatting in few-shot settings, with performance differences of up to 76 accuracy points when evaluated using LLaMA-2-13B.” Format performance was only weakly correlated between models, so a formatting choice validated on one model carries no promise to the next. Their response was not a better format but a better report. They released FormatSpread, which gives a performance interval instead of a single number.
That is why the useful comparison is not short against long but untestable against testable. A vague request is short and easy to demo. It relies on the model to infer hidden goals and constraints, so task interpretation comes out inconsistent, objective evaluation is difficult, and unsupported completion is encouraged. An overloaded instruction — many rules, exceptions and tasks in one block — appears comprehensive instead. It creates conflicts and priority ambiguity, it is hard to debug after a failure, and it may waste context and attention. A testable contract separates task, evidence, constraints, schema and fallback. It supports component-level diagnosis, enables structured evaluation, makes missing evidence visible, and works with deterministic controls.
Only the third kind can be given an interval at all. The first two report a single number with a 76-point neighbourhood nobody has looked at.
Vague request
Relies on the model to infer hidden goals and constraints.
- Short and easy to demo
- Produces inconsistent task interpretation
- Difficult to evaluate objectively
- Encourages unsupported completion
Overloaded instruction
Combines many rules, exceptions, and tasks in one block.
- Appears comprehensive
- Creates conflicts and priority ambiguity
- Hard to debug after failure
- May waste context and attention
Testable contract
Separates task, evidence, constraints, schema, and fallback.
- Supports component-level diagnosis
- Enables structured evaluation
- Makes missing evidence visible
- Works with deterministic controls
Analogy
An API description can be clear without controlling the caller
An API contract describes accepted input, desired output, and expected error behavior. A prompt does that work for a probabilistic system, which is why teams can version and test prompts the way they version an interface. Nothing enforces this contract. Natural language remains ambiguous and the model can depart from what the contract describes, so validation and authorization cannot be delegated to it.
The analogy breaks in a second place, and that one is measurable. An API schema is inert: naming a field does not change what the service computes. A response schema handed to a model is not inert. In JSON mode, 100% of GPT-3.5-Turbo responses emitted the ‘answer’ key before the ‘reason’ key. The model commits to its answer before producing the reasoning that was meant to produce it, which turns zero-shot chain-of-thought into direct answering. Tam and colleagues found this and reported it at EMNLP 2024. The cost was not a parsing artefact: “the parsing error rate for the Last Letter task in JSON format is only 0.148%, yet there exists a substantial 38.15% performance gap”, measured on Last Letter with LLaMA-3-8B.
Key order belongs to the contract. A schema that validates has not thereby been evaluated.
Write prompts so failures are observable, then enforce critical boundaries in code and policy.
Key idea
The system prompt is not a secret policy engine
System instructions can steer behavior. But user content, retrieved documents, and tool outputs can contain conflicting or malicious instructions, and the model cannot reliably separate trusted from untrusted text by wording alone. Two independent security bodies now say so in print. Neither expects that to change.
The UK's National Cyber Security Centre said it on its blog on 8 December 2025. “As there is no inherent distinction between ‘data’ and ‘instruction’, it’s very possible that prompt injection attacks may never be totally mitigated in the way that SQL injection attacks can be,” wrote Dave Chismon. His argument is that LLMs are “inherently confusable”, so design protections must focus on deterministic, non-LLM safeguards. OWASP reaches the same conclusion from the practitioner side. Prompt injection is LLM01:2025, the number-one risk in the OWASP Top 10 for LLM Applications 2025, and the entry states that “it is unclear if there are fool-proof methods of prevention”. What it prescribes instead is privilege control, output validation in deterministic code, and human approval for high-risk actions.
Treat prompts as one control among several. Sensitive operations require least privilege, input boundaries, output validation, external authorization, and a traceable record of what ran. The same list, arrived at twice, by an agency and by a top-ten entry.
Prompt hierarchy guides the model; it does not replace security architecture.
Steps
Develop prompts with an eval-driven loop
Treat each change as a release candidate rather than a clever phrase. Write the task contract first: success, evidence, exclusions and failure behavior. Build representative cases spanning ordinary, rare, ambiguous, adversarial and out-of-scope inputs. Establish a simple baseline with direct instructions before adding elaborate scaffolding. Then change one mechanism at a time, adding examples, decomposition or context only in response to a measured failure.
Scoring, the fifth step, has a documented ceiling. A strong model judge agrees with human preferences about as often as humans agree with each other. Zheng and colleagues showed that at NeurIPS 2023, alongside MT-Bench and Chatbot Arena and a release of 3K expert votes and 30K human-preference conversations: “Our results reveal that strong LLM judges like GPT-4 can match both controlled and crowdsourced human preferences well, achieving over 80% agreement, the same level of agreement between humans.” That single sentence is both the case for automated scoring and its limit. The same work documents position, verbosity and self-enhancement biases in LLM judges. That is why the judge must not be the model whose own variants are being ranked, and why human inspection of disagreements and tails stays in the loop.
Versioning, the sixth step, is no longer house style. It is written into two published baselines, and they ask for the same thing: “Developers should ensure that they have an audit log of changes to system prompts or other model configuration (including prompts) that affect the underlying working of the systems.” That is provision 8.3 of the UK DSIT Code of Practice for the Cyber Security of AI, published 31 January 2025, under Principle 8, “Document your data, models and prompts”. The matching provision 5.2.4-3 of ETSI TS 104 223 V1.1.1, April 2025, carries the same requirement with a standard number attached. Release prompt, model, tools, schemas and evaluation results together, and log the change. A reader who is asked why can now hand over a provision number instead of a preference.
1. Write the task contract
Define success, evidence, exclusions, and failure behavior.
2. Build representative cases
Include ordinary, rare, ambiguous, adversarial, and out-of-scope inputs.
3. Establish a simple baseline
Start with direct instructions before adding elaborate scaffolding.
4. Change one mechanism
Add examples, decomposition, or context only for a measured failure.
5. Score and inspect
Use automated checks plus human review of disagreements and tails.
6. Version the interface
Release prompt, model, tools, schemas, and evaluation results together.
A prompt is good when the task becomes diagnosable
The best prompt is not the most literary or the longest. It makes intended behavior, evidence, and failure visible enough to test.
The menu of things you could add instead is larger than it looks. Schulhoff and colleagues surveyed it in The Prompt Report in June 2024: “We present a detailed vocabulary of 33 vocabulary terms, a taxonomy of 58 LLM prompting techniques, and 40 techniques for other modalities.” They identify conflicting terminology and a fragmented ontology as the field's core problem. So the catalogue cannot simply be worked through from the top, and one technique may reach you twice under two names.
The next lessons focus on demonstrations, decomposition, and reasoning workflows. With 58 catalogued text-only techniques on offer, each technique should address a diagnosed problem rather than become ritual prompt decoration.
Key takeaways
- A production prompt should expose task, evidence, constraints, output contract, and failure behavior.
- Wording is not the largest variable: meaning-preserving formatting changes alone produced differences of up to 76 accuracy points on LLaMA-2-13B, and format performance correlates only weakly between models.
- The output schema is part of the behavior, not a description of it: 100% of GPT-3.5-Turbo JSON-mode responses put the answer key before the reason key, a 38.15% performance gap on Last Letter against a 0.148% parsing error rate.
- Vague and overloaded prompts fail differently and both hide the same thing — an example ordering that alone spans near state-of-the-art to random-guess accuracy.
- Prompt injection and authorization require controls outside natural-language instructions: the NCSC says it may never be totally mitigated the way SQL injection can be, OWASP ranks it LLM01:2025, and CVE-2025-32711 shows one instance rated 9.3, Critical by its own vendor.
- Prompt changes should be driven by representative evals — automated judges reach over 80% agreement with humans but carry position, verbosity and self-enhancement biases — and released with an audit log, as provision 8.3 of the UK DSIT Code of Practice and provision 5.2.4-3 of ETSI TS 104 223 V1.1.1 both require.