What Are Prompting Patterns
Prompting patterns are proven techniques that reliably improve model output across different tasks and domains. They are not magic words. They are structural approaches grounded in how language models work. Once you know these patterns, you can combine them to solve almost any prompting problem.
Think of them like design patterns in software engineering. Just as certain patterns (observer pattern, factory pattern, decorator pattern) solve recurring problems in code, certain prompting patterns solve recurring problems in getting good AI results. This chapter teaches you four core patterns that cover the majority of use cases.
You do not need to choose just one pattern. You can combine multiple patterns in a single prompt. For example, you might use role-playing, few-shot examples, and chain-of-thought reasoning all together. The key is using the right combination for your specific task.
Pattern 1: Role-Playing (Character Adoption)
How It Works
In role-playing prompts, you ask the model to adopt a specific persona or role. Instead of asking "Summarize this technical paper," you ask "You are a researcher writing this for a general audience. Summarize this technical paper." The model anchors to that role and adjusts its language, depth, and perspective accordingly.
Role-playing works because it aligns the model's output with a specific context and perspective. Different roles have different communication styles, knowledge levels, biases, and priorities. By specifying a role, you narrow the infinite possibilities down to one that matches what you need.
When to Use Role-Playing
Use role-playing when you want output in a specific voice or perspective. Examples: teaching a complex concept to beginners (adopt the role of a teacher), generating business-focused advice (adopt the role of a consultant), creating creative content (adopt the role of a writer in that genre), technical problem-solving (adopt the role of an experienced engineer).
Role-Playing Examples
Example 1: Educational Explanation
"You are a computer science professor teaching this concept to undergraduate students who have not taken calculus. Explain neural networks without using mathematical notation."
Example 2: Business Advice
"You are a venture capitalist with 20 years of startup experience. What are the top three risks with this business plan?"
Example 3: Creative Writing
"You are a science fiction author known for hard science and realistic worldbuilding. Write a 500-word scene where humans encounter an alien species for the first time."
Pattern 2: Few-Shot Learning (Learning by Example)
How It Works
Instead of just describing what you want, you provide a few examples of the desired behavior. The model learns the pattern from your examples and applies it to new cases. This is called "few-shot" because you only need a few (typically 2-5) examples.
Few-shot learning is powerful because patterns are often easier to understand from examples than from description. A single example of well-formatted output is often worth a thousand words of explanation.
When to Use Few-Shot Learning
Use few-shot learning when the task is easier to show than describe. Examples: formatting (how should the output be structured?), classification (how should similar items be categorized?), transformation (how should this type of input be converted?), style replication (what tone or voice do you want?), or domain-specific tasks.
Few-Shot Learning Examples
Example 1: Format Specification
Example 1:
Input: "The laptop is fast but runs hot and the battery only lasts 3 hours"
Output: Pros: Fast | Cons: Runs hot, short battery life
Example 2:
Input: "Love the design, hate the keyboard, price is reasonable"
Output: Pros: Good design, reasonable price | Cons: Poor keyboard
Now convert this review: "Amazing screen quality, heavy to carry, no USB-C"
Example 2: Classification Pattern
Example 1:
Ticket: "My account is locked and I can't access my data"
Classification: Critical
Example 2:
Ticket: "How do I change my password?"
Classification: Low
Example 3:
Ticket: "The app crashes when I click the export button"
Classification: High
Classify this: "The UI looks different since the update, is it a bug?"
Pattern 3: Chain-of-Thought (Explicit Reasoning)
How It Works
Chain-of-thought prompting asks the model to show its reasoning step-by-step before providing a final answer. This simple change dramatically improves accuracy, especially on tasks that require reasoning, logic, math, or complex analysis. By making the reasoning explicit, the model has space to catch its own errors.
The power of chain-of-thought comes from forcing the model to work through the problem rather than jumping to a conclusion. This is similar to how humans solve complex problems: we work through steps rather than intuiting the answer.
When to Use Chain-of-Thought
Use chain-of-thought for: complex reasoning, multi-step problems, mathematical or logical analysis, decision-making with multiple factors, situations where accuracy is critical, or problems where you want to understand the model's thinking process.
Chain-of-Thought Examples
Example 1: Math Problem
Example 2: Analysis Decision
Example 3: Bug Diagnosis
Pattern 4: Step-by-Step Instructions (Process Decomposition)
How It Works
Instead of asking for a final output directly, you ask the model to generate output in a specific series of steps. This pattern works well for tasks that naturally decompose into stages. By specifying the steps, you ensure the model covers all necessary ground and produces complete output.
Step-by-step instructions are different from chain-of-thought. Chain-of-thought asks the model to show its reasoning before answering. Step-by-step instructions specify the actual process the model should follow to create the output.
When to Use Step-by-Step
Use step-by-step for: multi-stage processes, comprehensive content generation, structured workflows, tasks where completeness matters, or situations where you want to guide the model through a process.
Step-by-Step Examples
Example 1: Content Creation
Step 1: Write a compelling headline
Step 2: Write an engaging introduction
Step 3: Develop three main points (one section each)
Step 4: Write a conclusion that summarizes and provides actionable advice
Step 5: Review and improve any section that feels weak
Example 2: Project Planning
Step 1: Define success metrics and goals
Step 2: Identify stakeholders and their concerns
Step 3: Create a timeline with milestones
Step 4: Identify risks and mitigation strategies
Step 5: Plan for launch day activities
Step 6: Plan for post-launch monitoring
Combining Multiple Patterns
The real power comes from combining patterns. Here is a complex prompt that uses multiple patterns:
You are an experienced user experience researcher. You conduct user interviews and synthesize insights.
// FEW-SHOT (format example)
Interview notes format example:
User: "Product is confusing"
Insight: Navigation is non-intuitive
Quote: "I couldn't find the settings menu"
// STEP-BY-STEP (process)
Analyze these interview notes following this process:
1. Extract key themes from all interviews
2. Identify the strongest signal (most mentioned issues)
3. For each major theme, provide supporting quotes
4. Assess impact: how many users were affected?
5. Recommend one high-impact improvement
// CHAIN-OF-THOUGHT
For the recommendation, explain your reasoning.
Pattern Matching: Choosing the Right Pattern
How do you choose which pattern to use? Ask yourself these questions:
Do I need a specific perspective or voice? Use role-playing.
Is the task easier to show than describe? Use few-shot learning.
Does the task require complex reasoning or logic? Use chain-of-thought.
Does the task have multiple stages? Use step-by-step instructions.
Most complex prompts use multiple patterns. For instance, you might use role-playing to set perspective, few-shot to show format, and chain-of-thought to ensure reasoning is sound.
Key Takeaway
These four patterns cover the vast majority of prompting needs. Role-playing anchors perspective. Few-shot provides examples. Chain-of-thought enables reasoning. Step-by-step ensures completeness. Master these patterns and you have the building blocks to engineer prompts for almost any task.
The best prompts rarely use just one pattern. They combine patterns strategically to get exactly the output they need. Start by learning to use each pattern individually, then experiment with combinations.
Practice Exercises
Exercise 1: Take a task you do regularly. Write two prompts: one using role-playing and one using few-shot. Compare the results.
Exercise 2: Write a prompt that uses all four patterns in combination. Notice how each pattern contributes to the overall quality.
Exercise 3: Take a prompt that is producing mediocre results. Identify which patterns are missing and add them.