Prompt Engineering Fundamentals
Beginner 7 min Module 4 of 6
Module 4 of 6

Prompt Patterns and Templates

Every experienced prompt engineer reuses a small library of patterns. The same six structures, remixed for different tasks, cover the vast majority of real-world use cases. This module gives you all six, with ready-to-use templates for each.

By the end of this module you will be able to

Why Patterns Matter

A pattern is a reusable structure that solves a recurring type of problem. Prompt patterns work the same way: once you have identified the structure that works for a class of task, you can apply it reliably across hundreds of different instances of that task without having to think from scratch each time.

Patterns also make prompts easier to test and improve. When an output is not what you wanted, a pattern gives you specific components to adjust rather than requiring you to rewrite the whole thing from nothing.

The key insight Most tasks you want AI to do fall into a small number of categories: explain something, analyze something, produce structured output, compare options, challenge an assumption, or refine a draft. Each category has an optimal prompt structure.

The Six Core Patterns

01 The Expert Persona

Set a specific role before giving the task. The role activates relevant vocabulary, depth, and framing from training data. Works best when you need domain-specific knowledge or a particular professional perspective.

You are a [specific expert role] with [N] years of experience in [domain]. [Task].

Example in use:

You are a senior UX researcher with 12 years of experience in B2B software. Review the following user interview transcript and identify the top three usability problems. Explain each one in terms a product manager would understand.

[paste transcript]
02 The Step-by-Step

Ask the model to break the task into numbered steps. Useful for processes, instructions, plans, and any output where sequence matters. Also triggers chain-of-thought reasoning for complex tasks.

Break this into numbered steps. [Task].

Example in use:

Break this into numbered steps. How would a startup validate a new product idea before building anything? Include at least one way to test demand without writing a single line of code.
03 The Structured Output

Specify the exact format of the output: JSON, a table, a specific set of fields, or a defined structure. Critical for any use case where the output feeds into another system or needs to be processed programmatically.

Return your answer as a JSON object with keys: [list keys]. [Task].

Example in use:

Return your answer as a JSON object with keys: "sentiment" (positive/negative/neutral), "confidence" (high/medium/low), and "key_phrase" (the phrase that most drove the sentiment). Analyze the following customer review:

"The onboarding took longer than expected but the support team was genuinely helpful and the product does exactly what it promises."
04 The Comparison

Ask the model to compare two or more options across a defined set of dimensions. Forces structured thinking and prevents the model from giving a vague "it depends" answer when you need specific tradeoffs.

Compare [A] and [B] across these dimensions: [list]. Format as a table with one row per dimension.

Example in use:

Compare PostgreSQL and MongoDB across these dimensions: query flexibility, horizontal scaling, consistency guarantees, and ease of schema changes. Format as a table with one row per dimension and a column for each database. Add a one-line recommendation at the end.
05 The Devil's Advocate

Ask the model to argue both sides. Forces a balanced view and surfaces objections you may not have considered. Useful for decision-making, preparing for challenges, and stress-testing ideas.

Give me the strongest argument AGAINST [position]. Then give the strongest argument FOR it. Keep each argument to two paragraphs.

Example in use:

Give me the strongest argument AGAINST building a custom AI model for our company instead of using a hosted API. Then give the strongest argument FOR it. Keep each argument to two paragraphs. Assume we are a 200-person software company with a dedicated ML team of four people.
06 The Iterative Refinement

Give the model a draft and ask it to critique and rewrite. Produces better output than asking it to write from scratch, because the draft anchors the direction and the critique makes the weaknesses explicit before rewriting.

Here is my [draft/code/plan]:

[content]

Identify three specific weaknesses. Then rewrite to fix all three. Show the original and improved versions side by side.

Combining Patterns

You can stack patterns in a single prompt. The most powerful combinations pair Expert Persona with any other pattern, since the role shapes the perspective of whatever structure you add.

You are a senior financial analyst with 15 years of experience in SaaS companies. [Expert Persona]

Here is our Q3 revenue summary: [content]

Identify three specific weaknesses in our revenue mix. Then rewrite the summary to position these as manageable risks rather than structural problems. [Iterative Refinement]

Format your response as: (1) Weaknesses, (2) Rewritten summary. [Structured Output]

This prompt uses three patterns at once. The Expert Persona frames the analysis. The Iterative Refinement drives the critique and rewrite. The Structured Output makes the response easy to copy directly into a document.

Practice: You want consistent JSON output from an API integration. Which pattern is the right choice?
Structured Output (Pattern 3). Define the exact JSON keys you need and describe each field's expected values. This gives you reliable, parseable output across every API call, without needing to post-process variable formats.
Knowledge check
You need to write an argument and then argue against it to stress-test your reasoning. Which pattern fits?
Correct. Devil's Advocate asks the model to argue both sides, which surfaces objections and stress-tests your position before you commit to it.
Not quite. The Devil's Advocate pattern (Pattern 5) is designed exactly for this: argue both sides to surface weaknesses and objections.
Which pattern should you use to get reliable structured data you can process programmatically?
Correct. Structured Output specifies the exact format, such as a JSON object with defined keys, so every response is parseable without further processing.
Not quite. Structured Output (Pattern 3) is the right choice. It defines the exact JSON keys or table structure you need, giving you consistent, parseable output every time.
Can you use more than one pattern in a single prompt?
Correct. Stacking patterns is one of the most powerful moves available. Expert Persona + Structured Output + Iterative Refinement in one prompt is a common and effective combination.
Patterns are designed to be combined. Expert Persona + Structured Output + Step-by-Step in one prompt gives you role, format, and structure all at once.
Before you go
Reflection: Pick one of the six patterns and write a prompt using it for a task in your own work. Test it, then try adding a second pattern to the same prompt.
You might also like
Was this module helpful?
← Module 3: Zero-Shot, Few-Shot, CoT Module 5: Avoiding Bad Outputs →