Tutorials4 min read
Prompting Techniques That Work: A Practical Guide
Seven prompting techniques that reliably improve AI answers — context, roles, examples, format, steps, sources and testing — with before-and-after prompts.
In short
- Give context and the goal. Explain who the result is for, what it will be used for and what good looks like.
- Set a role. Tell the model which expertise and perspective to adopt for the task.
- Show examples. Include two to five varied examples of the input and the output you want.
- Specify the format. State the structure, length, tone and any sections or fields the answer must have.
- Break the task into steps. Split complex work into stages and ask the model to work through them in order.
- Provide source material. Paste the documents the answer must be based on and allow the model to say it does not know.
- Test and iterate. Run the prompt on several real cases, note the failures and refine one thing at a time.
A prompt is everything you give a model: your question, instructions, examples and documents. The model knows nothing about your situation beyond what you put there, so the quality of the prompt largely decides the quality of the answer.
The good news is that “prompt engineering” is mostly clear communication. The official guides from Anthropic, OpenAI and Google agree on the same core practices. Here are the seven that make the biggest difference.
1. Give context and the goal
Write the prompt as if briefing a smart colleague who has just joined and knows nothing about the project. Say who the result is for, what it will be used for and what a good result looks like.
Before: “Write a product description for our headphones.”
After: “Write a product description for our wireless headphones for an online shop aimed at runners aged 25–45. The goal is to convince them the headphones stay put during a run. Mention the 30-hour battery and sweat resistance. Around 120 words, energetic but not over the top.”
The second prompt removes a dozen guesses the model would otherwise have to make.
2. Set a role
Telling the model which expertise to use focuses vocabulary, priorities and level of detail: “You are an experienced employment lawyer reviewing a contract for a small business owner.” A role works best combined with context — it is a lens, not a substitute for information.
3. Show examples
Examples are often clearer than descriptions. Include two to five examples of the input and the exact output you want — this is called few-shot prompting. Make them varied, or the model may copy details you did not intend, such as length or particular words.
Classify each customer message as BILLING, TECHNICAL or OTHER.
Message: "I was charged twice this month." → BILLING
Message: "The app crashes when I upload a photo." → TECHNICAL
Message: "Do you have an office in Madrid?" → OTHER
Message: "My invoice shows the wrong VAT number." →
4. Specify the format
Say exactly what shape the answer should take: a table with given columns, a bulleted list, JSON with named fields, three options with pros and cons, a maximum length. If you need to paste the result somewhere else, describe that destination. Separating parts of a long prompt with clear headings or tags (for example <document> … </document>) also helps the model tell instructions from material.
5. Break the task into steps
Complex requests produce better results when split up. You can do this inside one prompt (“First list the main risks. Then rate each from 1 to 5. Then propose a fix for the top three.”) or as a chain of separate prompts, each using the previous output.
Current models also reason internally before answering. You still help by asking for the steps that matter, such as listing assumptions or checking the final answer against the original requirements.
6. Provide source material — and allow “I don’t know”
When an answer must be factual, give the model the document, data or page it should rely on, and instruct it to answer only from that material. Add: “If the answer is not in the text, say so.” Asking for direct quotes to support each point makes unsupported claims easy to spot. This is the most effective way to reduce hallucinations.
7. Test and iterate
For a one-off question, read the answer and ask for changes. For a prompt you will reuse — in a template, an automation or an app — test it on several real cases, including awkward ones. Change one thing at a time and keep the version that performs best. For anything important, keep a small set of test cases (an eval) and rerun it whenever you change the prompt or the model.
A complete example
You are a customer-support lead at an online bookshop.
Context: we are replying to customers whose order is delayed by the courier.
Goal: a reply that apologises, gives the new delivery date and offers a 10% discount code.
Write the reply in British English, warm but brief (under 100 words).
Use the order details below. If the new delivery date is missing, say we will
email it within 24 hours instead of guessing.
<order>
Customer: Jamie
Order: #48213, two books
New delivery date: Friday 9 October
Discount code: SORRY10
</order>
It has a role, context, a goal, format rules, source material and an explicit instruction for missing information — the techniques above working together.
Common mistakes
- Vague goals (“make it better”) — say better in what way and for whom.
- Hidden constraints — if there is a word limit, a tone or a forbidden topic, write it down.
- Contradictory rules piled up over time — reread long prompts and remove what no longer applies.
- Trusting the first output for important work — check facts and test on more than one case.
Frequently asked questions
Do I need special phrases or “magic words”?
No. Modern models respond best to clear, specific instructions written as you would brief a capable colleague. Tricks that worked on older models matter much less now.
Should prompts be short or long?
As long as needed to give the model the context it lacks, and no longer. A long prompt full of relevant detail beats a short vague one; a long prompt full of irrelevant rules does not.
Do these techniques work in ChatGPT, Claude and Gemini?
Yes. All three providers recommend essentially the same practices: clear instructions, context, examples, explicit format and breaking down complex tasks.


