Prompt Engineering: How to Write Better Prompts
Published Updated
Prompt engineering means designing the instructions and context you give an AI model so it returns something you can use. For a work task, specify what the answer must contain, give the model the sources it needs and test the prompt on several cases. A revised prompt is ready to share when its answers meet the same checks without manual fixes.
What Prompt Engineering is
When you write a prompt in a chat, you can correct a guess on the next turn. In a business application, staff may see only a form or a search box. The app inserts their input into a prompt template and adds system instructions that apply to each request. The team has to test those instructions in advance because users will get the result without seeing the full prompt.
Newer reasoning models can often work from a clear goal without a scripted sequence of thinking steps or several examples. They still need facts they couldn’t have learnt in training, such as which version of a supplier agreement your team is reviewing. They also need the rules that determine what counts as a usable answer.
The Parts of a Good Prompt
Start with the task. If a manager needs to decide whether to renew a contract, name that decision so the model knows which terms to look for. Give it the contract excerpt and identify that excerpt as the source. Specify the fields the manager needs and how to report a missing clause. Use an example when the output format could be read more than one way.
Weak and Strong Supplier Contract Prompts
For the weak version, open a new chat with the contract excerpt and paste this instruction.
Summarise this supplier contract.
For the stronger version, open another chat and paste this prompt. Replace the bracketed field with the same excerpt. Use only text your organisation permits you to share with the tool.
Summarise the terms in the supplied contract excerpt for a procurement manager deciding whether to renew. Use only the excerpt.
Return a table with these columns: Item | What the contract says | Clause. Include rows for annual fee, renewal term and non-renewal notice. If the excerpt doesn’t state a detail, write “Not stated in the excerpt”.
For example, if a source says “3.2 Payment is due within 30 days”, the corresponding row would be “Payment deadline | 30 days | 3.2”. Use that example for format only.
Contract excerpt:
[contract excerpt]
Both prompts were run once in fresh chats on the same locally hosted model with a fictional contract excerpt. The weak response found the notice period, including “written notice at least 45 days before the end of the initial 12-month term”. It returned a bullet list without clause numbers. The stronger prompt returned a table and put “Written notice at least 45 days before the end of the initial term” beside clause 5.2.
The stronger result still needed one correction. Its “Renewal term” row said “12 months (renews automatically)”, although the excerpt gave 12 months as the initial term and left the renewal period unspecified. Split that row into initial term and length of the renewal period. The test then has a specific expected result for each one.
Prompt Engineering Techniques
Show Examples of the Output You Need
Few-shot prompting means including a few example inputs and their desired outputs. If your team marks invoices as payable, disputed or incomplete, give the model examples that illustrate the boundaries. Include an invoice with a missing purchase order if that is a common reason to mark a record incomplete. Use examples you have already checked against the rules in the prompt.
Ask for Evidence or Intermediate Results
If you need to check how an answer was reached, ask the model to show the clause, figure or calculation it used before giving its answer. For instance, ask it to identify the fees it found before it totals them. OpenAI’s reasoning model guidance recommends brief, direct instructions and advises against stock requests to think step by step. For those models, give a clear goal and ask for the evidence the reader can inspect.
Give Inputs and Outputs a Structure
Separate instructions and source material with headings or tags. For example, you can put document excerpts inside <source> tags and the task inside <task> tags. For a result a colleague will scan, specify columns and row labels. For a result passed to software, use a schema where the model API supports one and validate the fields in the app.
Break a Large Task Into Smaller Prompts
For a renewal briefing, first ask the model to extract the terms from each contract. Inspect the clause references before passing that result into a second prompt that compares the contracts. You can fix a bad extract without regenerating the whole brief.
Give the Model a Way to Mark Missing Facts
Tell it what to write when a source is silent. For a contract table, use “Not stated in the excerpt” and leave the clause field blank. Include a case with a missing answer in your tests. The instruction can reduce AI hallucinations, and a clause check can catch an unsupported claim that slips through.
How to Write and Test a Prompt
Pick a task with a result your team can inspect. Use source material approved for your tool and an owner who can judge the answer against it.
- Define the output. Write down the required fields, the source each answer must come from and what the model must report if the source leaves a gap.
- Draft the prompt. State the task and who will use the result. Attach or paste the material the model needs. A prompt template can help you capture those fields.
- Run it on several cases from the work it will handle. Include a routine case and an awkward one, such as a contract with an incomplete renewal clause. Start a fresh chat for each case.
- Compare the results against the sources and your expected format. Mark which facts, fields or clause references needed someone to fix them.
- Revise the prompt. Change the instruction that caused a failure, then run the same cases again. Keep going until the outputs pass your agreed checks without manual fixes.
- Save the tested version in a shared prompt library. Keep the task, required files, example output and prompt owner with it so a colleague can repeat the process.
Keep a small test set of approved inputs and expected results beside the prompt. Rerun it after a change to the prompt, model or tool. Give staff a way to report failures to the owner. When one occurs in ordinary work, add an approved example to the set before updating the shared version.
Common Prompt Problems and Fixes
Start by comparing the answer with the task and the source you actually supplied. That gives you a better lead than rephrasing the prompt at random.
| Symptom | What to check | What to change |
|---|---|---|
| Vague or generic output | Can you name the reader and the decision the answer will support? | Add that decision and a relevant example of the detail you need. |
| Ignored instructions | Do two instructions conflict, or does an example contradict one? | Resolve the conflict and place the requirement next to the task. |
| Invented facts | Can you find every claimed fact in the source the model received? | Give it the relevant excerpt. Require an accurate source reference or an explicit missing value. |
| Wrong format or length | Does the prompt specify the columns, fields or word limit? | Show one valid example and verify the answer against it. |
When a fact is missing from the material, provide the source or give the assistant a way to retrieve it. If the task needs a calculation over a whole spreadsheet, check that the tool can read the rows and perform the calculation. A more detailed prompt can’t supply missing rows or give a chat tool permissions it lacks.
If the answer starts drifting in a long chat, start a new chat with the current task, the governing constraints and the source excerpts you still need. Carry across the decisions you’ve already checked. Leave earlier drafts out so they don’t compete with current instructions.
Prompting ChatGPT, Claude and Copilot
OpenAI’s ChatGPT prompting guide recommends a specific request with enough context to act on it. It suggests refining the wording or context after looking at the result. In ChatGPT, use Custom Instructions for preferences you want across chats, such as Australian spelling. Use a project when related chats need the same files and instructions, such as a set of briefs for one procurement review.
Anthropic’s Claude prompting guide recommends named XML tags when instructions, examples and source documents appear in the same prompt. For work you revisit, a Claude project can hold project instructions and a knowledge base of files. Add the reference material to the project so new chats can use it.
Microsoft’s Copilot guide shows how to specify a goal, context and the source to use. In Microsoft 365 Copilot Chat, type a slash and the name of a work file or meeting to reference it where your licence and settings allow it. Select the exact source when several files have similar names.
A custom GPT in ChatGPT bundles instructions and reference material for a repeatable task. If your team already uses one, use it while you test a replacement. OpenAI is retiring custom GPTs and moving reusable workflows to plugins. For an ongoing body of work where you mainly need shared files and instructions, use a project.
Custom actions don’t transfer during the migration to a plugin. Set up and test replacement integrations before switching.
Prompts Inside Business Applications
A production assistant has system instructions for its role and rules. When someone asks a question, the application adds the specific request and may retrieve source excerpts for that turn. Keep the prompt template in version control. Before changing it, run the same test set on the current and proposed versions. Compare whether the answers use the right source, handle missing facts and fit the format the application expects.
Text from documents, webpages and tools is data the model reads. To defend against prompt injection, keep that content separate from privileged instructions and label its source. Keep secrets out of model prompts. Enforce access to documents and tool permissions in the application, where they remain in force whatever the model says. Require a human to approve sensitive actions before the application carries them out.
Use retrieval-augmented generation when the answer depends on current policies or records the model needs to look up. Add a tool when the assistant must perform a calculation or read an authorised live record. Consider fine-tuning for a repeatable behaviour, such as classifying requests, if prompting with examples still misses cases your tests measure. Choose the change that fixes the specific failure in your test set, then rerun the set before releasing it.
Related reading
Prompt Template: Reusable AI Prompts for Work
Build a prompt you can reuse at work. Enter the task, context, audience, format and limits, and get a structured prompt for ChatGPT, Claude or Copilot.
Staff AI Training: ChatGPT, Claude and Copilot
Plan AI training your staff will use: what ChatGPT, Claude and Copilot training should cover, workshop and course formats, and how to check it worked.
AI Hallucination: Causes, Examples and Fixes
Why does AI invent facts, citations and figures with confidence? What AI hallucination is, from fake case law to AI scribe errors, and how to reduce it.
What is RAG in AI? Pipelines, Uses and Limits
Retrieval-augmented generation lets an AI model answer from your own documents. A RAG pipeline has weak points, and agentic RAG helps with some of them.
embeddings
Embeddings is an Australian AI consultancy. We design, build and run AI systems inside the software, documents and data organisations already use, from offices in Perth and Melbourne.
About Embeddings