Short answer
Prompt engineering is the practice of writing and structuring instructions for an AI model so it gives accurate, useful and consistent answers. The most effective techniques are simple: be specific about the goal, give context and examples, say what format you want, break big tasks into steps, and let the model think before it answers. Good prompting is the cheapest way to improve AI results, and it should be tried before RAG or fine-tuning.
Why prompts matter
A large language model generates text by predicting what is most likely to come next given everything in its context window. Your prompt is the main thing that shapes that prediction. A vague prompt leaves the model guessing about your audience, purpose, length and format, so it falls back on generic answers. A clear prompt removes the guesswork.
A useful mental model: write the prompt as if you were briefing a smart new colleague who knows nothing about your project.
12 prompt engineering techniques
1. Be specific about the task
- Weak: "Write about GPUs."
- Better: "Write a 300-word explanation of why GPUs are faster than CPUs for training neural networks, for readers with no technical background."
2. Give context and the reason behind the request
Explain who the output is for and why. "This summary will go to our finance team to decide whether to rent or buy GPUs" leads to a very different answer than a bare "summarise this".
3. Assign a role
"You are an experienced data center hardware engineer" helps the model choose the right vocabulary, depth and priorities. Roles work best combined with specific instructions.
4. Show examples (few-shot prompting)
Give one to five examples of the input and the output you want. Models copy patterns very well, so examples are often the fastest way to get a consistent style or format.
Classify each GPU as "data center" or "consumer".
H100 -> data center
RTX 4090 -> consumer
B200 ->5. Specify the output format
Ask for exactly what you need: a table with named columns, a bulleted list, JSON with specific keys, or a maximum length. "Return JSON with keys name, vram_gb and price_usd" is far more reliable than "give me the data".
6. Separate instructions from content
When you paste a document, mark clearly where it starts and ends, for example with XML-style tags: <document> ... </document>. This stops the model confusing your material with your instructions.
7. Let the model think step by step
For maths, logic, coding and analysis, ask the model to reason before answering ("Work through this step by step, then give the final answer"). This chain-of-thought approach improves accuracy on multi-step problems. Reasoning models do this automatically.
8. Break complex tasks into steps
Instead of one giant prompt, chain smaller ones: first extract the key facts, then outline, then draft, then check. Each step is easier for the model and easier for you to verify.
9. Tell it what to do, not only what to avoid
"Write in short, plain sentences" works better than "Don't be wordy". Positive instructions give the model a target.
10. Allow "I don't know"
Add "If the answer is not in the provided text, say you don't know." This reduces hallucinations, especially when answering from documents.
11. Ask for sources or quotes
"Quote the sentence from the document that supports each claim" makes answers easier to check and keeps the model grounded.
12. Iterate
Treat the first answer as a draft. Tell the model what to change ("make it shorter", "add a comparison table", "the tone is too formal") rather than starting over. Save prompts that work well as templates.
A reusable prompt template
Role: You are a [expert type].
Task: [What you want, in one or two sentences].
Context: [Who it is for, why it matters, background].
Input: <material> [paste text, data or code] </material>
Requirements:
- [Length, tone, audience]
- [Must include / must avoid]
Output format: [table / bullets / JSON with keys ...]
If information is missing, say so instead of guessing.Prompting for different tasks
| Task | What helps most |
|---|---|
| Writing and editing | Audience, tone, length, an example of the style you like |
| Summarising | The purpose of the summary and the desired length or format |
| Coding | Language, framework versions, error messages, expected behaviour, tests |
| Data extraction | An exact output schema (JSON or table) and examples |
| Research questions | Ask for sources and to separate facts from opinions |
| Image generation | Subject, style, composition, lighting, aspect ratio |
For image models such as Stable Diffusion and FLUX, prompts describe the scene and style instead of giving instructions. See What is a diffusion model?.
Prompt engineering vs RAG vs fine-tuning
| Prompt engineering | RAG | Fine-tuning | |
|---|---|---|---|
| Changes | The instructions | The information supplied | The model's weights |
| Cost and effort | Minutes, no extra cost | Days to build retrieval | Days to weeks, needs GPUs |
| Best for | Behaviour, format, tone | Up-to-date or private knowledge | Consistent style at scale, narrow tasks |
Start with prompting. Add RAG when the model lacks knowledge, and fine-tuning when you need behaviour that prompting cannot deliver reliably.
From prompt engineering to context engineering
As AI moves from single questions to AI agents that work for many steps, practitioners increasingly talk about context engineering: deciding everything the model sees, including instructions, retrieved documents, tool results, memory and examples, and keeping that context relevant and within limits. Tools connected through MCP are part of that context too.
Frequently asked questions
Is prompt engineering still useful with smarter models?
Yes. Newer models need fewer tricks, but they still cannot read your mind. Clear goals, context, examples and output formats remain the biggest drivers of quality.
Is prompt engineering a real job?
Some companies hired dedicated prompt engineers when generative AI took off. Today it is more often a core skill for developers, writers, analysts and anyone who works with AI, rather than a separate role.
Do long prompts work better?
Longer is better only when it adds relevant detail. Irrelevant text can distract the model and costs more tokens.
Do prompts work the same on ChatGPT, Claude and Gemini?
The core techniques work across all major models, but each responds a little differently. Test important prompts on the model you will actually use.
Sources and further reading
- Anthropic, Prompt engineering overview
- OpenAI, Prompt engineering guide
- Brown et al., Language Models are Few-Shot Learners (2020)
- Wei et al., Chain-of-Thought Prompting Elicits Reasoning in Large Language Models (2022)




Leave a Reply