Prompt Engineering 101 — How to Write Better AI Prompts
The difference between a mediocre AI response and a brilliant one often comes down to how you write your prompt. Whether you're using ChatGPT, Claude, Gemini, or any other large language model, prompt engineering is the skill that separates power users from casual ones.
In this guide, you'll learn practical, battle-tested techniques to get dramatically better results from any AI model — no coding required.
What Is Prompt Engineering?
Prompt engineering is the practice of crafting instructions that guide AI models toward the output you want. Think of it as communicating with a very capable but very literal assistant — the clearer your instructions, the better the result.
A well-engineered prompt typically includes five elements:
- Role — Who should the AI act as?
- Task — What exactly should it do?
- Context — What background information does it need?
- Constraints — What rules or limits should it follow?
- Output Format — How should the response be structured?
Technique 1: Role Assignment
Starting your prompt with a role dramatically changes the quality and style of responses. Compare these two approaches:
Without role:
Review this Python code for issues.
With role:
You are a senior Python developer with 10 years of experience
in production systems. Review the following code for bugs,
security vulnerabilities, performance issues, and style
improvements. Prioritize critical issues first.
The second prompt produces significantly more detailed, expert-level feedback because the AI "adopts" the expertise of the assigned role.
Technique 2: Be Specific About Output Format
Vague prompts get vague results. Always specify exactly how you want the output structured:
Respond in the following format:
## Summary
[One paragraph overview]
## Key Findings
- Finding 1: [description]
- Finding 2: [description]
## Recommendations
1. [Action item with priority]
2. [Action item with priority]
This technique is especially powerful for getting structured data like JSON, tables, or step-by-step guides.
Technique 3: Few-Shot Examples
Providing examples of what you want (called "few-shot prompting") is one of the most effective techniques. Instead of describing the pattern, show it:
Convert these product descriptions to SEO titles.
Input: "Blue running shoes for men, size 10-13"
Output: "Men's Blue Running Shoes | Sizes 10-13 | Free Shipping"
Input: "Wireless noise-canceling headphones with 30h battery"
Output: "Wireless Noise-Canceling Headphones | 30hr Battery Life"
Input: "Organic green tea from Japan, 100 bags"
Output:
The AI learns the pattern from your examples and applies it consistently.
Technique 4: Chain of Thought
For complex reasoning tasks (math, logic, analysis), asking the AI to "think step by step" dramatically improves accuracy:
Solve this step by step, showing your reasoning at each stage:
A store has 150 items. 40% are electronics, and 25% of
electronics are on sale. How many electronics are on sale?
This forces the model to break down the problem rather than jumping to (potentially wrong) conclusions.
Technique 5: Constraints and Negative Prompting
Telling the AI what not to do can be as important as telling it what to do:
Rules:
- Do NOT use placeholder text or "lorem ipsum"
- Do NOT include comments in the code
- Keep the response under 200 words
- Use only the Python standard library
- If you're unsure, say "I'm not certain" instead of guessing
Technique 6: Iterative Refinement
Great prompts are rarely written in one shot. Use this workflow:
- Write your initial prompt
- Evaluate the response — what's missing? What's wrong?
- Add constraints or examples to fix those issues
- Repeat until the output matches your expectations
- Save the final prompt as a template for reuse
Common Mistakes to Avoid
- Being too vague — "Write something about marketing" vs. "Write a 500-word LinkedIn post about B2B SaaS content marketing trends in 2026"
- Overloading a single prompt — Break complex tasks into multiple sequential prompts
- Not providing context — The AI doesn't know your project, audience, or constraints unless you tell it
- Ignoring output format — Always specify if you want Markdown, JSON, plain text, or code
Model-Specific Tips
ChatGPT (GPT-4o)
Responds well to system prompts. Great at following complex multi-step instructions. Use "Think carefully before responding" for accuracy.
Claude (Sonnet/Opus)
Excels at long-form writing and nuanced analysis. Responds well to XML-style structured prompts. Claude tends to be more cautious — explicitly ask it to be direct if you want concise answers.
Gemini
Strong at multimodal tasks (text + images). Has the largest context window (1M tokens), so it handles very long documents well. Good for summarization of large datasets.
Build Your Prompts Faster
Use our free AI Prompt Builder to craft structured prompts with templates, variables, and one-click export.
Try AI Prompt Builder →Putting It All Together
Here's a complete, well-engineered prompt that combines all the techniques:
You are a senior technical writer with expertise in API documentation.
## Task
Write API documentation for the endpoint described below.
## Context
This is for a REST API used by mobile developers building
a social media app. The audience is intermediate developers.
## Constraints
- Include request/response examples with realistic data
- Show error responses (400, 401, 404, 500)
- Use consistent naming conventions
- Keep descriptions under 2 sentences each
## Output Format
Markdown with code blocks for examples.
## Endpoint
POST /api/v1/posts — Creates a new post with text and
optional image attachment.
Prompt engineering is a skill that improves with practice. Start applying these techniques today, and you'll see dramatically better results from any AI model you use.