Prompts are the specification of a generative-AI application. Well-written prompts make outputs more accurate, consistent and safe; vague prompts produce vague results. These techniques consistently improve quality in business applications.
1. Be explicit about the task and the audience
State what the model should do, for whom, and what “good” looks like. “Summarise this claim file for an adjuster in five bullet points, covering incident, coverage, amounts and open questions” beats “summarise this”.
2. Provide context and constraints
- Give the model the information it needs — policies, product details, retrieved documents.
- Say what to do when information is missing: “If the answer is not in the provided documents, say you don’t know.”
- Specify boundaries: topics to avoid, actions not to take, tone to use.
3. Show examples
A few high-quality input/output examples (“few-shot” prompting) are often the fastest way to get consistent format and style. Choose examples that cover tricky cases, not just easy ones.
4. Ask for structured output
When outputs feed other systems, request JSON or another defined structure and validate it. Many model APIs support structured-output or schema features that make this far more reliable.
5. Break complex tasks into steps
Instead of one giant prompt, chain smaller steps — extract, then classify, then draft — or let the model work through the problem before giving its final answer. Smaller steps are easier to test and debug.
6. Ground answers and require citations
For knowledge tasks, supply retrieved passages and ask the model to cite which passage supports each claim. Citations make answers verifiable and discourage invention.
7. Defend against prompt injection
Treat user input and retrieved content as data, not instructions. Separate system instructions from untrusted content clearly, and never rely on the prompt alone to protect sensitive actions — enforce permissions in code.
8. Manage prompts like code
- Store prompts in version control or a prompt-management tool.
- Review changes like code changes.
- Run your evaluation set on every prompt change before release.
- Record which prompt version produced each output.
A simple template
| Section | Contents |
|---|---|
| Role & goal | Who the assistant is and what it must achieve |
| Context | Relevant documents, data and definitions |
| Rules | Constraints, what to do when unsure, safety requirements |
| Examples | 2–5 representative input/output pairs |
| Output format | Exact structure required |
Our Generative AI team runs prompt-engineering workshops and builds prompt and evaluation pipelines for enterprise teams.
Frequently asked questions
What is prompt engineering?
Prompt engineering is the practice of writing and refining the instructions, context and examples given to a language model so that it produces accurate, consistent and safe outputs.
Do few-shot examples really help?
Yes. A few representative input/output examples are often the fastest way to get consistent format and style, especially for tricky cases.
Can a prompt prevent prompt-injection attacks?
Not on its own. Clear separation of instructions and untrusted content helps, but permissions and sensitive actions must be enforced in application code, not just in the prompt.