How to Write Better AI Prompts: 10 Practical Techniques
A practical how-to for writing better AI prompts: 10 techniques with before/after examples, plus a simple rubric-based workflow for comparing prompt variants before you rely on one.
This is a hands-on guide. If you want the definition and fundamentals first (what prompt engineering is and why it works), read What Is Prompt Engineering?. This article assumes you already use an AI assistant and want better results from it on purpose rather than by luck.
It has two parts: ten techniques, each with a before/after pair, and a short workflow for checking whether a rewrite actually helped.
About the examples: every before/after pair below is an illustrative example written for this article, not a measured result. Run them yourself; outputs vary between models and between runs of the same model.
Technique 1: State the Task and the Goal Behind It
Say what you want produced and what it is for. The purpose lets the model make sensible choices you did not spell out.
Before:
Write an email about the outage.
After:
Write an email to our customers about yesterday's 40-minute login outage.
Goal: restore trust without over-promising. They need to know what
happened, whether their data was affected (it was not), and what we
changed. Keep it under 150 words.
Anthropic's prompting guide makes the same point: explaining why an instruction matters helps the model generalize from it (Claude prompting best practices, checked 2026-11-05).
Technique 2: Specify the Output Format
If the output feeds into something else (a doc, a spreadsheet, a script), describe its shape exactly.
Before:
Analyze this customer feedback.
After:
Analyze the customer feedback below. Return:
## Summary (2-3 sentences)
## Themes (up to 5 bullets, each with a count of mentions)
## Quotes (one representative quote per theme, copied verbatim)
## Open questions (anything the feedback cannot answer)
Formats worth asking for: Markdown headings, tables, numbered steps, JSON with named fields, or "one line per item, no commentary".
Technique 3: Show Examples of Good Output
When tone or structure is hard to describe, show it. Two or three examples are often clearer than a paragraph of adjectives. Make the examples varied, or the model may copy their surface details.
Before:
Rewrite these release-note headlines to be clearer.
After:
Rewrite release-note headlines so a user knows what changed for them.
Example
Original: "Improvements to sync"
Rewrite: "Edits now sync between devices within a few seconds"
Example
Original: "Export updates"
Rewrite: "Export a project as CSV or JSON from the Share menu"
Now rewrite: "Search enhancements"
If you don't know the specific change, ask me instead of guessing.
Note the last line. Examples set a pattern, and without that line the model may invent a specific feature to fit it.
Technique 4: Set Length and Scope
Without limits, many assistants default to long answers. Give a target and say what to leave out.
Before:
Explain OAuth.
After:
Explain the OAuth 2.0 authorization code flow in about 150 words for a
frontend developer who has used login buttons but never implemented one.
Skip history and alternatives. End with the one mistake beginners make most.
Technique 5: Give the Context Only You Have
The model does not know your product, audience, constraints or prior decisions. Add the facts that change the answer, and leave out the ones that don't.
Before:
How should I price my product?
After:
I'm pricing a project-management tool for small marketing agencies
(5-20 staff). Competitors I've looked at charge roughly $15-50 per user
per month. Our differentiator is content-calendar automation. Most
prospects tell us their total tool budget is $200-500 per month.
Propose 2-3 pricing structures, the trade-off of each, and what I
should test with real prospects before choosing.
The figures here are placeholders for your own research. A model cannot verify your market for you.
Technique 6: Use Constraints, and Explain Them
Tell the model what to avoid, and why if the reason isn't obvious.
Before:
Write an intro for my blog post about remote onboarding.
After:
Write a 3-sentence intro for a post about onboarding remote engineers.
- Open with a concrete situation, not a question or a statistic
(I don't have a source for statistics).
- No "in today's world" or similar filler.
- State the post's main recommendation by the third sentence.
Technique 7: Ask for Reasoning When the Task Needs It
For multi-step decisions, ask the model to work through the factors before concluding, and to show the factors so you can check them. For simple lookups this only adds length. See the chain-of-thought prompting guide for when it helps.
Before:
Should I use serverless functions or a container for my API?
After:
Help me choose between serverless functions and a long-running container
for an API that handles about 10,000 requests a day with spiky traffic.
Work through: cost drivers for each, cold-start impact on our p95 latency
target of 300 ms, operational effort for a two-person team. Then recommend
one and list what would change your recommendation.
Technique 8: Refine in Follow-ups Instead of Starting Over
A first answer that is 70% right is often faster to fix with a targeted follow-up than to regenerate.
Cut this to half the length; keep the three recommendations.
Section 2 is too abstract. Add one concrete example.
Same content, but for a non-technical reader.
You stated the deadline as March. My notes say April. Re-check against what I pasted.
If you find yourself making the same follow-up every time, move that instruction into the original prompt.
Technique 9: Name the Audience
Audience determines vocabulary, depth and what to emphasize.
Before:
Explain Kubernetes.
After:
Explain what Kubernetes does to a finance director deciding whether to
fund a migration. Focus on what problem it solves, what it costs in
people and time, and what risks it introduces. No command examples.
Technique 10: Separate Instructions From Material
When you paste documents, data or code, mark clearly where they start and end so the model doesn't confuse your material with your instructions. Tags or headings both work.
Before:
summarize this and tell me the risks [pasted 6-page contract]
After:
<contract>
[pasted contract]
</contract>
Summarize the contract above in 5 bullets, then list clauses that
create obligations for us, with clause numbers. Quote the exact
wording for each obligation. If a clause is ambiguous, say so.
For long inputs, Anthropic recommends placing the documents near the top and the question and instructions after them (Claude prompting best practices, "Long context prompting", checked 2026-11-05). OpenAI's guide similarly recommends Markdown and XML-style delimiters to mark sections of a prompt (OpenAI prompt engineering guide, checked 2026-11-05).
Putting It Together
A prompt that combines several techniques, with each part labeled:
You are writing developer documentation for a public REST API. [role]
Document the POST /v1/sessions endpoint (user login). [task]
Readers are developers integrating our auth service; assume they
know REST and JSON but not our system. [audience]
Include: method and URL, request fields (type, required/optional),
a success response example, error codes with meanings, and a
Python example using the requests library. [format]
About 400-500 words. Markdown headers, code blocks for examples. [length]
Do not document the deprecated /v0/login endpoint. If a detail
isn't in the spec below, write "TODO: confirm" instead of
guessing. [constraints]
<spec>
[paste the endpoint spec]
</spec> [material]
How to Check Whether a Rewrite Helped
A prompt that "feels" better is not necessarily better. Before you reuse a prompt regularly or share it with a team, compare versions on the same inputs. Both Anthropic and OpenAI recommend defining success criteria and testing prompts against them before and during iteration (Anthropic prompt engineering overview; OpenAI prompt engineering guide; both checked 2026-11-05). A lightweight version of that:
1. Write a rubric before you look at outputs
Pick 3-5 criteria that matter for this task, each scored 0-2. For the customer-email prompt in Technique 1:
| Criterion | 0 | 1 | 2 |
|---|---|---|---|
| Accuracy | States something not in the brief | Vague on facts | All facts match the brief |
| Required content | Misses 2+ items | Misses 1 item | Covers what happened, data impact, changes |
| Tone | Defensive or over-promising | Mostly fine | Plain, accountable, no promises we can't keep |
| Length | Over 200 words | 151-200 words | 150 words or fewer |
Deciding criteria first stops you from rewarding whichever output you happened to read last.
2. Collect a few realistic inputs
Use 3-5 inputs that represent real use, including at least one awkward case (missing information, unusual length, a request the prompt should refuse or flag).
3. Run each variant on each input more than once
Outputs vary between runs. Two or three runs per input will show you whether a variant is reliably better or just got lucky once. Keep the model and settings the same across variants.
4. Score blind if you can
Paste outputs into a sheet without labels showing which variant produced them, then score against the rubric. If a colleague can score too, compare notes on disagreements; they usually reveal a vague criterion.
5. Keep the winner and note why
Record what changed between versions and which criteria improved. That note is what lets you (or a teammate) avoid undoing the fix later.
Where a prompt grader fits
The free HyperPrompt prompt grader is a quick structural checklist. It runs in your browser and checks your prompt text for signals such as length, a stated role, an action verb, output-format words, examples or delimiters, and placeholders, then gives a score and suggestions. It does not send your prompt to a model or look at outputs, so it cannot tell you whether the answers are accurate. Use it to catch missing pieces before you write, and use the rubric workflow above to judge results.
Common Mistakes
- Burying the actual request. If the task is in the last line of a long message, restate it clearly.
- Assuming shared context. "Make it like last time" means nothing in a new chat.
- Stacking contradictory constraints. "Be comprehensive" and "under 100 words" pull in opposite directions; pick one priority.
- Accepting confident specifics. Names, numbers, quotes and citations need checking against a source, however fluent the answer.
- Judging on one run. One good output is an anecdote; a few consistent ones are evidence.
Practice With Templates
Templates are a good way to practice these techniques, because you can see which parts are fixed and which are variables:
Frequently Asked Questions
How long should a prompt be?
Long enough that someone without your context could do the task. Anthropic's guide suggests a useful test: show the prompt to a colleague with minimal context and see if they'd be confused (checked 2026-11-05). A one-line request is fine for a simple task; a reusable workflow prompt may need several paragraphs.
Do the same techniques work across ChatGPT, Claude and other assistants?
The fundamentals (clear task, context, format, examples, separating material from instructions) appear in both OpenAI's and Anthropic's official guidance. Model-specific behavior changes between releases, so test a prompt on the model you'll actually use. See ChatGPT vs Claude prompt differences for more.
Should I always assign a role?
Not always. A role can help set tone and domain focus, but it does not replace specific instructions and context. The role-playing prompts guide covers when it helps and when it doesn't.
How do I know a prompt is good enough?
When it meets your rubric across several realistic inputs and repeated runs, not just once. See How to Check Whether a Rewrite Helped.
Where should I keep prompts that work?
Anywhere you can find them again with the notes on why they work: a document, a repository, or a prompt manager. If you want to save and reuse prompts inside AI tools, the HyperPrompt Chrome extension includes a private prompt library.
Related Articles
What Is Prompt Engineering? Definition, Core Techniques and Examples
What prompt engineering is, what it can and cannot fix, the core techniques with examples, and how practitioners test prompts, with links to Anthropic and OpenAI's official guidance.
How to Build a Custom GPT Workflow and Test It (and Plan the Move to Plugins)
Plan a Custom GPT's instructions, reference files, actions and evaluation cases, with OpenAI's current status: custom GPTs are being retired in favor of plugins, and personal accounts can no longer create new GPTs.
Coding Prompts That Work: A Workflow from Context to Verified Code
A practical workflow for AI-assisted coding: give the right context, set constraints, generate in small steps, verify with tests, review and security checks, and iterate. Links to individual coding templates for each step.