Prompting Fundamentals
Common Prompting Patterns
3 min read
These proven patterns will help you get better results from AI in various situations.
1. Few-Shot Learning
Show the AI examples of what you want:
Convert these sentences to formal language:
Casual: "Hey, can you send me that file?"
Formal: "Would you please forward the document at your earliest convenience?"
Casual: "Thanks a bunch!"
Formal: "Thank you for your assistance."
Casual: "I can't make it to the meeting tomorrow"
Formal: [AI completes this]
3-5 examples usually work best.
2. Chain of Thought
Ask the AI to think step-by-step:
Solve this problem step by step:
A store has 50 apples. They sell 30% in the morning and 40% of what's left in the afternoon. How many apples remain?
Think through each step before giving the final answer.
This improves accuracy on complex reasoning tasks.
3. Self-Consistency
Get multiple perspectives, then synthesize:
I need to decide whether to learn Python or JavaScript first.
First, argue the case for Python.
Then, argue the case for JavaScript.
Finally, give your balanced recommendation based on both perspectives.
4. Tree of Thought
Explore multiple solution paths:
I want to improve my website's performance.
List 3 different approaches:
1. Quick wins (implement today)
2. Medium-term improvements (this month)
3. Long-term optimizations (this quarter)
For each approach, list specific actions.
5. Persona Pattern
Create consistent character behavior:
You are Alex, a senior software architect with 15 years of experience. You:
- Prioritize maintainability over cleverness
- Always consider scalability
- Prefer simple solutions when possible
- Give direct, honest feedback
Review this code architecture decision...
6. Template Pattern
Use fill-in-the-blank structures:
Generate a product description using this template:
[Product Name] is a [category] designed for [target audience].
Key features include [feature 1], [feature 2], and [feature 3].
Unlike [competitor/alternative], it [unique value proposition].
Perfect for anyone who [use case].
Product: Wireless noise-canceling earbuds
7. Iterative Refinement
Build on previous outputs:
Draft 1: Write a tagline for a fitness app
[AI responds]
Draft 2: Make it more energetic and action-oriented
[AI refines]
Draft 3: Now make it appeal to busy professionals
[Final refinement]
Quick Pattern Selection Guide
| Goal | Pattern |
|---|---|
| Show examples | Few-Shot |
| Complex reasoning | Chain of Thought |
| Decision making | Self-Consistency |
| Multiple options | Tree of Thought |
| Consistent voice | Persona |
| Structured output | Template |
| Polish results | Iterative Refinement |
Combining Patterns
The most effective prompts often combine multiple patterns. For example: Few-Shot + Chain of Thought + Template can produce highly accurate, well-structured outputs.
:::