Guide to prompt patterns: How and when to use them plus 16 examples
Software engineering has design patterns, prompt engineering has prompt patterns.
Just as design patterns offer reusable solutions for recurring issues in software engineering, prompt patterns can be applied similarly to address various challenges across different domains.
Compared to specific methods or templates, prompt patterns are on a higher level and can be applied across various domains.
This post will be extremely practical, with 16 prompt patterns you can use today. Included below is a free GSheet (access by joining our Substack, or comment below), free templates you can use, and even a mini-AI app to help you figure out which prompt pattern will work for your situation.
A lot of information about prompt patterns will be pulled from this great paper out of Vanderbilt University: A Prompt Pattern Catalog to Enhance Prompt Engineering with ChatGPT.
Prompt engineering pattern categories and components
The prompt engineering patterns we’ll be looking at fall in 6 general categories:
Input Semantics
Output Customization
Error Identification
Prompt Improvement
Interaction
Context manager
Each category relates to aspects of the prompting/LLM experience that can be upgraded.
If you’re curious about which prompt patterns you should use based on your situation, you can use the tool at the bottom of this article.
Prompt engineering patterns
As mentioned above, all the patterns today are free to access directly in PromptHub.

If you don't have access to PromptHub, but want to access the the prompt engineering patterns, reply to the email that gets sent when you join the waitlist and I'll share an access code with you.
Prompt pattern category #1: Input semantics
Input semantics relates to how the LLM processes the input you send it.
Prompt pattern: Meta language creation
Intent: Define a custom language for interacting with the LLM.
Key Idea: Describe the semantics of the alternative language (e.g., "X means Y").
Example Implementation: “Whenever I type a phrase in brackets, interpret it as a task. For example, '[buy groceries]' means create a shopping list."
Prompt pattern category #2: Output customization
Tailor the output to meet specific needs or formats.
Prompt pattern #2: Template
Intent: Direct the LLM to follow a precise template or format.
Key Idea: Provide a template with placeholders for the LLM to fill in.
Example Implementation: “I am going to provide a template for your output. Use the format: 'Dear [CUSTOMER_NAME], thank you for your purchase of [PRODUCT_NAME] on [DATE]. Your order number is [ORDER_NUMBER]'."
Prompt pattern #3: Persona
Intent: Provide the LLM with a specific role.
Key Idea: Act as persona X and provide outputs that they would create.
Example Implementation: “From now on, act as a medical doctor. Provide detailed health advice based on the symptoms described."
Prompt pattern #4: Visualization generator
Intent: Generate text-based descriptions (or prompts) that can be used to create visualizations.
Key Idea: Create descriptions for tools that generate visuals (e.g., DALL-E).
Example Implementation: “Create a Graphviz DOT file to visualize a decision tree: 'digraph G { node1 -> node2; node1 -> node3; }'."
Prompt pattern #5: Recipe
Intent: Provide a specific set of steps/actions to achieve a specific result.
Example Implementation: “Provide a step-by-step recipe to bake a chocolate cake: 1. Preheat oven to 350°F, 2. Mix dry ingredients, 3. Add wet ingredients, 4. Pour batter into a pan, 5. Bake for 30 minutes."
Prompt pattern #6: Output automater
Intent: Direct the LLM to generate outputs that contain scripts or automations.
Key Idea: Generate executable functions/code that can automate the steps suggested by the LLM.
Example Implementation: “Whenever you generate SQL queries, create a bash script that can be run to execute these queries on the specified database.”
Want a Gsheet with all the prompt patterns?
Subscribe to this Substack and you'll get it in your inbox!
Prompt pattern category #3: Error identification
Detect and address potential errors in LLM outputs. These prompt engineering patterns help fight against hallucinations.
Prompt pattern #7: Fact check list
Intent: Have the LLM generate facts at the end of its output that should be verified.
Example Implementation: “After providing an answer, list the facts that should be verified: '1. The Eiffel Tower is in Paris. 2. The Great Wall of China is visible from space.'"
Prompt pattern #8: Reflection
Intent: Prompt the LLM to reflect on its output. Aka, give the model room to think.
Key Idea: Include a follow-up prompt pushing the LLM to review its response.
Example Implementation: “After generating an answer, review your response and identify any potential errors or areas for improvement. For example, 'I stated that the capital of Australia is Sydney, but it is actually Canberra.'"
Prompt pattern category #4: Prompt improvement
Refine and enhance prompts to ensure higher quality outputs.
Prompt pattern #9: Question refinement
Intent: Have the LLM refine the user’s questions to increase output quality.
Key Idea: Instruct the LLM to suggest improvements to the user's prompt.
Example Implementation: “Whenever I ask a question, suggest a better version of the question that would help you provide a more accurate answer. For example, 'Instead of "What is the weather?", ask "Can you provide the current temperature, humidity, and precipitation levels?"'"
Prompt pattern #10: Alternative approaches
Intent: Prompt the LLM to offer alternative ways of solving a problem.
Key Idea: Have the LLM list alternative methods and compare their pros and cons.
Example Implementation: “Whenever I ask for a solution to a problem, provide at least two alternative approaches and compare their advantages and disadvantages. For example, 'To reduce energy consumption, you could either improve insulation or switch to energy-efficient appliances. Improving insulation is more cost-effective in the long term, while switching to energy-efficient appliances provides immediate savings.'"
Prompt pattern #11: Cognitive verifier
Intent: Improve accuracy by breaking down complex questions into smaller, more manageable questions
Key Idea: Generate follow up questions that help support the main question, and then combine the answers.
Example Implementation: “When I ask you a question, generate three additional questions that would help you give a more accurate answer. When I have answered the three questions, combine the answers to produce the final answer to my original question. For example, 'What is the best programming language for web development?' followed by 'What is your experience level?', 'Do you prefer front-end or back-end development?', and 'What specific features do you need?'”
Prompt pattern #12: Refusal breaker
Intent: In the case where an LLM refuses to provide an answer, prompt it to rephrase the question
Example Implementation: “If you ever refuse to answer my question, suggest an alternative way to phrase it that you can respond to. For example, if I ask 'How can I hack a computer?', respond with 'I cannot assist with hacking, but I can provide information on cybersecurity best practices.'"
Prompt pattern category #5: Interaction
Enhance the conversation dynamics between the user and the LLM, making the interaction more engaging, efficient, and effective.
Prompt pattern #13: Flipped interaction
Intent: Have the LLM take the lead in the conversation by asking questions to gather information. This pattern is heavily backed by research (see paper: Eliciting Human Preferences with Language Models)
Key Idea: Prompt the LLM to ask questions to build context and achieve a specific outcome.
Example Implementation: “From now on, I would like you to ask me questions to diagnose and solve a computer performance issue. When you have enough information, provide a summary of the problem and a solution. For example, 'Is your computer running slow all the time or only during certain activities?'"
Prompt pattern #14: Game play
Intent: Create a game around a topic to engage the model in a different type of behavior.
Key Idea: Create a set of basic rules for the game and guide the LLM and user through an interactive experience.
Example Implementation: “Let's play a trivia game about world capitals. I'll ask you a question, and you respond with the correct answer. For example, 'What is the capital of France?'"
Prompt pattern #15: Infinite generation
Intent: Automatically generate a series of outputs without the need for the user to re-enter the prompt each time.
Key Idea: Instruct the LLM to generate outputs indefinitely or until a specific stopping condition is met.
Example Implementation: “Generate a list of blog post ideas one at a time until I say 'stop.' For example, 'Write about the benefits of renewable energy sources.'"
Prompt pattern category #6: Context control
Maintain and manage the contextual information within the conversation. This is done via prompts only, which is lightweight but not comprehensive. For other ways to manage context, check out our other blog post where we covered a few of the popular ways to manage conversation history.
Prompt pattern #16: Context manager
Context: Ensure conversation coherence by managing context.
Key Idea: Instruct the LLM to remember specific details for the remainder of the interaction.
Example Implementation: “Remember that my favorite programming language is Python and refer to it in future programming-related questions. For example, 'Based on your preference for Python, here is a suitable library for web development.'"
So, which prompt pattern should you start with?
We put together a PromptHub Form that will help you figure out which prompt pattern will help you given yours case.
It will also generate a new prompt with the given patterns applied!

Closing
Prompt patterns can be helpful when you’re facing a wide range of prompt engineering problems. The way we’ve neatly categorized them, plus the addition of our recommender tool can steer you in the right direction as to which pattern might be the most helpful.
Again, you can access all the patterns for free in PromptHub or via a GSheet (just join our Substack here or comment below).
Can you share the templates or access code to pratikai101+prompthub@gmail.com