- Home
- /Guides
- /practical AI
- /Prompt Engineering Patterns: Proven Techniques
Prompt Engineering Patterns: Proven Techniques
Master advanced prompting techniques: chain-of-thought, few-shot, role prompting, and more. Get better AI outputs with proven patterns.
TL;DR
Advanced prompting patterns improve AI outputs: chain-of-thought for reasoning, few-shot for examples, role prompting for expertise, and structured outputs for consistency.
Chain-of-Thought (CoT)
Concept: Ask AI to "think step-by-step"
Example:
- Without: "What's 15% tip on $47?"
- With CoT: "What's 15% tip on $47? Think step-by-step."
- AI: "1. Calculate 15% of $47: 0.15 × 47 = 7.05. 2. The tip is $7.05."
When to use: Math, logic, complex reasoning
Few-Shot Prompting
Concept: Provide examples before asking
Example:
Classify sentiment:
"I love this!" → Positive
"Terrible experience" → Negative
"It's okay" → Neutral
"Best purchase ever" → ?
AI: "Positive"
When to use: Classification, formatting, style matching
Zero-Shot Prompting
Concept: No examples, just ask directly
Example: "Summarize this article in 3 sentences."
When to use: General tasks, when examples are hard to provide
Role Prompting
Concept: Ask AI to adopt a persona
Example:
- "You are an expert SQL developer. Write a query to..."
- "You are a kindergarten teacher. Explain photosynthesis..."
When to use: Need domain expertise or specific tone
Constrained Output
Concept: Specify exact output format
Example:
Extract info and return as JSON:
{
"name": "",
"email": "",
"phone": ""
}
When to use: Structured data extraction, API responses
ReAct (Reasoning + Acting)
Concept: AI reasons, acts, observes, repeats
Example:
Question: What's the weather in Paris?
Thought: I need to search for Paris weather
Action: Search "Paris weather"
Observation: 15°C, cloudy
Thought: I have the answer
Answer: It's 15°C and cloudy in Paris.
When to use: Multi-step tasks, tool use
Self-Consistency
Concept: Generate multiple answers, pick most common
Process:
- Ask same question with temperature > 0
- Generate 5-10 responses
- Return most frequent answer
When to use: Critical tasks, reduce hallucinations
Negative Prompting
Concept: Tell AI what NOT to do
Example:
- "Explain AI. Don't use jargon. Don't exceed 100 words. Don't assume technical background."
When to use: Avoid common mistakes, control output
Prompt Chaining
Concept: Break complex tasks into steps
Example:
- First prompt: "List main points from this article"
- Second prompt: "For each point, provide supporting evidence"
- Third prompt: "Write a summary integrating all points"
When to use: Complex tasks, exceeding context limits
Meta-Prompting
Concept: Ask AI to improve your prompt
Example:
- "I want to write better product descriptions. Suggest a good prompt for that."
When to use: Learning, optimization
Best practices
Be specific:
- "Write a 200-word email" > "Write an email"
Provide context:
- "For a technical audience familiar with AI"
Use delimiters:
- Use
triple backticksfor code - Use """ for text blocks
Iterate:
- Start simple, add constraints
- Test and refine
Common mistakes
- Too vague ("Tell me about AI")
- Too complex (multiple tasks in one prompt)
- No examples when needed
- Assuming AI knows your context
Template example
[Role]: You are an expert [domain]
[Context]: The user is [description]
[Task]: [Specific request]
[Constraints]: [Format, length, style]
[Examples]: [If needed]
What's next
- Prompting 101 (basics)
- Evaluating AI Answers
- Advanced Prompt Optimization
Was this guide helpful?
Your feedback helps us improve our guides
Key Terms Used in This Guide
Related Guides
A/B Testing AI Outputs: Measure What Works
IntermediateHow do you know if your AI changes improved outcomes? Learn to A/B test prompts, models, and parameters scientifically.
AI API Integration Basics
IntermediateLearn how to integrate AI APIs into your applications. Authentication, requests, error handling, and best practices.
AI for Data Analysis: From Questions to Insights
IntermediateUse AI to analyze data, generate insights, create visualizations, and answer business questions from your datasets.