Prompt Engineering Tips
Practical, battle-tested techniques for writing better prompts and getting dramatically more useful output from large language models.
Getting useful output from an LLM is a skill. The model you're talking to is extraordinarily capable — but it responds to what you actually say, not what you meant. Here are the techniques that consistently produce better results.
1. Be Specific About the Output Format
Vague prompts produce vague outputs. Tell the model exactly what you want.
| Instead of... | Say this |
|---|---|
| "Explain recursion" | "Explain recursion in 3 bullet points, using a file system traversal as the example, for a developer who knows JavaScript" |
| "Give me ideas" | "Give me 5 SaaS product ideas in the EdTech space, formatted as a table with columns: Name, Problem Solved, Target User, Revenue Model" |
| "Fix this code" | "This Python function is supposed to return unique values but returns duplicates. Identify the bug and show the corrected version with an explanation" |
2. Give the Model a Role
Assigning a persona dramatically changes the register, depth, and assumptions in the response.
You are a senior security engineer reviewing code for a FinTech company.
Your job is to identify vulnerabilities, explain them in plain English,
and suggest fixes. Be direct. Rank issues by severity (Critical / High / Medium / Low).
Here is the code to review:
[paste code]
The role doesn't have to be a job title. "You are a harsh but fair editor" or "You are a rubber duck" both work. The key is framing the model's stance.
3. Use Chain-of-Thought Prompting
For reasoning tasks, ask the model to think step by step before giving its answer. This dramatically improves accuracy on maths, logic, and multi-step problems.
A store sells 3 types of items. Pencils cost $0.50 each. Notebooks cost $2.00.
Pens cost $1.25 each. I bought 4 pencils, 2 notebooks, and 3 pens.
I paid with a $20 bill. How much change should I receive?
Think through this step by step before giving the final answer.
Without "step by step", models often guess. With it, they calculate.
In more capable models (GPT-4, Claude 3+), chain-of-thought is often triggered automatically. In smaller models, it remains essential.
4. Provide Examples (Few-Shot Prompting)
Examples communicate your intent more precisely than descriptions alone. This technique is called few-shot prompting.
Classify the sentiment of each review as Positive, Negative, or Neutral.
Review: "The battery life is incredible, easily lasts 3 days."
Sentiment: Positive
Review: "Arrived on time but the packaging was damaged."
Sentiment: Neutral
Review: "Completely broken on arrival. Awful experience."
Sentiment: Negative
Review: "Good product but the instructions were confusing."
Sentiment: ???
5. Use Delimiters to Separate Sections
When your prompt mixes instructions, context, and input data, use clear delimiters to prevent the model from confusing one for another.
prompt = f"""
Summarise the following article in 3 sentences.
Focus on the main argument, not the examples.
---ARTICLE---
{article_text}
---END ARTICLE---
Summary:
"""
Delimiters like ---, triple backticks, or XML tags (<article>, </article>) all work. Pick a style and be consistent.
6. Ask for Multiple Options
When you need a creative or subjective output, asking for multiple versions surfaces the model's range and lets you cherry-pick.
Write 3 different subject lines for a cold outreach email to a startup founder
about our enterprise security audit service. Vary the tone:
one professional, one conversational, one urgent.
7. Iterate and Refine
Your first prompt is a hypothesis. The model's response is data. Use it.
Common adjustments:
- Too long? → "Answer in under 150 words"
- Too vague? → "Be specific. Give exact numbers and examples"
- Wrong tone? → "Rewrite this for a technical audience / non-technical audience"
- Missing something? → "Also include the trade-offs of each approach"
8. System Prompts vs User Prompts
If you're using the API directly, understand the difference:
| Prompt type | Purpose | Example |
|---|---|---|
| System | Persistent instructions for the whole session | "You are a concise assistant. Never use bullet points." |
| User | The actual request | "Explain what a REST API is." |
| Assistant | Model's previous response (for context) | Used in multi-turn conversations |
System prompts are not foolproof — they can be overridden in sufficiently long conversations or by determined users. Don't rely on them alone for security-sensitive behaviour.
Quick Reference
✅ Good prompt anatomy:
[Role/persona] + [Task] + [Format] + [Constraints] + [Examples]
✅ For reasoning tasks: add "Think step by step"
✅ For creative tasks: ask for N variations
✅ For data tasks: specify exact output format (JSON, table, etc.)
✅ Always delimit your input from your instructions
The single biggest improvement most people can make: add one concrete example to any prompt that's producing generic output. Examples communicate more than words.