Dev tools
Prompt Engineering: A Practical Guide
A practical guide to prompt engineering: the parts of a good prompt, techniques that work, before-and-after examples, and templates you can reuse.
Prompt engineering is the skill of writing instructions that get useful, reliable results from AI tools like ChatGPT, Claude, and Gemini. The same model can give you a vague, generic answer or an excellent one. Often the only difference is how you asked.
You don't need to be technical to get good at it. This guide covers what makes a prompt work, the techniques worth knowing, real before-and-after examples, and templates you can copy today.
What Is Prompt Engineering?
A prompt is anything you give an AI model to respond to: a question, an instruction, a document, or examples. Prompt engineering is the practice of designing those inputs on purpose, then testing and improving them.
Think of it like briefing a very capable new colleague. They're smart and fast, but they know nothing about your project, your audience, or your standards. The better your brief, the better their work.
That's really the whole idea. Most of prompt engineering is clear communication, plus a few techniques that suit how AI models work.
Why Prompt Engineering Still Matters
You may have heard that prompt engineering is "dead" because newer models understand plain requests better. It's true that you no longer need magic phrases or tricks.
But the core problem hasn't gone away: the model can't read your mind. It doesn't know your goal, your audience, your constraints, or what "good" looks like to you unless you say so. Better models just reward clear instructions even more.
Prompting also matters more as you go beyond quick chats. If you're building a tool, automating a workflow, or reusing a prompt hundreds of times, small improvements add up.
The Anatomy of a Good Prompt
Most strong prompts are built from the same few parts. You won't need every part every time, but it helps to know them.
1. Context
Who is this for, and why? Background helps the model make good choices. "I'm writing to a customer who's upset about a late delivery" is far more useful than "write an email."
2. The task
State exactly what you want done, in one clear sentence if you can. "Summarize," "rewrite," "compare," and "list" are clearer than "help me with."
3. The material
Give the model what it needs to work with: the document, the data, the draft, or the facts. If the answer depends on information the model might not know, include it.
4. Constraints
Set the boundaries: length, tone, reading level, what to include, and what to avoid. "Under 150 words, friendly but professional, no jargon" removes a lot of guesswork.
5. Output format
Say what shape you want back: a table, a short paragraph, an email with a subject line, or a list of three options. If another program will read the output, specify the exact format.
Prompt Engineering Techniques That Work
These are the prompt engineering techniques that make the biggest difference, roughly in order of how often you'll use them.
Be specific
Vague prompts get generic answers. Compare:
- Vague: "Write a product description."
- Specific: "Write a 100-word product description for a stainless steel water bottle, aimed at hikers. Focus on durability and keeping drinks cold. Friendly, upbeat tone."
Explain the why
Telling the model the reason behind an instruction helps it apply the rule sensibly. "Keep it short, because it will be read on a phone" works better than "keep it short."
Show examples (few-shot prompting)
Few-shot prompting means including a few examples of the input and output you want. The model picks up the pattern, style, and format far more reliably than from a description alone.
Asking without any examples is called zero-shot prompting. Start there, and add examples when the output isn't quite right.
A tip: vary your examples. If all three examples are about the same topic or the same length, the model may copy those details too closely.
Ask it to think step by step (chain-of-thought prompting)
For problems that need reasoning, like math, planning, or tricky decisions, ask the model to work through the problem before giving its answer. This is called chain-of-thought prompting.
A simple version: "Think through this step by step, then give your final answer." Many newer models have built-in reasoning modes that do this automatically, but asking still helps with models that don't.
Break big tasks into steps
Instead of one giant prompt, split the job: first outline, then draft, then edit. Each step gets the model's full attention, and you can check and correct the work along the way. This is sometimes called prompt chaining.
Use clear structure
When a prompt mixes instructions with a long document, separate them clearly. Use headings, labels like "Instructions:" and "Document:", or tags such as <document> and </document>. This stops the model confusing your instructions with the material.
Give it a role, with care
"You are an experienced editor" can set a useful tone and level of expertise. But a role is no substitute for clear instructions. Specific context about the task usually matters more than the title you give the model.
Let it ask questions
For complex requests, end with: "Before you start, ask me any questions you need answered." This surfaces missing details you didn't think to include.
Allow "I don't know"
Add a line like "If you're not sure, say so instead of guessing." This reduces confident wrong answers, especially on factual questions.
Before and After: Real Prompt Examples
Here's how the techniques look in practice.
Example 1: An email
Before:
Write an email to my team about the new schedule.
After:
Write a short email to my team of six designers announcing that our weekly meeting is moving from Monday 10am to Tuesday 2pm, starting next week. The reason is to avoid clashing with the client calls on Mondays. Keep it under 120 words, friendly and clear. End by asking anyone with a conflict to reply by Friday.
Example 2: A summary
Before:
Summarize this article.
After:
Summarize the article below for a busy manager who hasn't read it. Give three bullet points on the main findings, then one sentence on what it means for a small marketing team. Only use information from the article.
Article: [paste article]
Example 3: Learning something new
Before:
Explain blockchain.
After:
Explain how blockchain works to someone with no technical background. Use one everyday analogy, keep it under 200 words, and finish with one common misconception and why it's wrong.
In each case, the "after" version answers the questions a smart colleague would ask: for whom, why, how long, and in what form.
How to Iterate on a Prompt
Your first prompt rarely gives the perfect result, and that's normal. Good prompt engineering is a loop:
- Write a clear first version.
- Run it and read the output carefully.
- Spot what's wrong: too long, wrong tone, missing details, made-up facts?
- Adjust one thing at a time, so you know what made the difference.
- Test again, ideally on a few different inputs, not just one.
You can also ask the model for help: "Here's my prompt and the output I got. The output is too formal. How should I change the prompt?" Models are often good at improving prompts.
Prompt Templates You Can Reuse
Reusable prompt templates save time and keep results consistent. Copy these and fill in the brackets.
General task template
Context: [who this is for and why]
Task: [what you want done]
Material: [paste text, data, or facts]
Constraints: [length, tone, things to include or avoid]
Format: [how the answer should be laid out]Rewrite template
Rewrite the text below for [audience].
Goal: [e.g. clearer, shorter, more persuasive].
Keep: [facts, names, or phrases that must stay].
Length: about [number] words. Tone: [tone].
Text: [paste text]Decision template
I need to decide between [option A] and [option B].
My situation: [key details].
What matters most to me: [priorities].
Think it through step by step, list the main trade-offs,
then tell me which option fits my priorities and why.Common Prompting Mistakes
- Assuming the model knows your situation. It only knows what's in the conversation.
- Asking for too much at once. Five tasks in one prompt usually means five half-done tasks.
- Saying only what not to do. "Don't be boring" is weaker than "use short sentences and one concrete example."
- Very long, rambling chats. Models can only consider so much text at once. Our guide to what a context window is explains why fresh chats sometimes work better.
- Trusting facts without checking. Clear prompts reduce errors but don't remove them.
Prompt Engineering vs Fine-Tuning and RAG
Prompting isn't the only way to improve AI results. Here's how it compares:
- Prompt engineering: changing the instructions. Fast, free, and the first thing to try.
- RAG (retrieval-augmented generation): automatically giving the model relevant documents before it answers. Best when the model needs facts it doesn't have. See our guide to what RAG is.
- Fine-tuning: further training a model on examples to change its behavior. More effort, used when prompting alone can't get there.
Prompting matters even more with smaller models, such as the ones you can run at home. Our guide on how to run an LLM locally shows how to set them up. Smaller models benefit a lot from clear, structured prompts and examples.
FAQ
Is prompt engineering a real job?
Some companies hire for roles focused on prompts, especially when building AI products. More often, prompt engineering is a skill within other jobs, like writing, marketing, development, support, and analysis. It's becoming a standard part of working with AI rather than a separate career for most people.
Is prompt engineering dead?
No, but it has changed. Tricks and magic phrases matter less as models improve. Clear communication still matters: stating your goal, giving context, setting constraints, and showing examples. Building reliable AI tools still requires careful prompt design and testing.
How can I learn prompt engineering for free?
Practice is the best teacher: take tasks you do every week and experiment with different prompts. Major AI companies, including Anthropic, OpenAI, and Google, also publish free prompting guides in their documentation.
What is the difference between zero-shot and few-shot prompting?
Zero-shot prompting means asking the model to do a task with no examples. Few-shot prompting means including a few examples of the input and output you want, which helps the model match your format and style more closely.
Do I need to know how to code for prompt engineering?
No. Everyday prompt engineering is about clear writing and thinking. Coding helps if you want to build apps, automate prompts, or test them at scale, but it isn't needed to get much better results in a chat.