Prompt Engineering Patterns and Templates

Advanced prompt engineering patterns used by professionals. Templates, frameworks, and examples.

Advanced Prompt Engineering Patterns

Beyond basic prompting, specific patterns can dramatically improve AI outputs. This guide covers professional techniques for consistent, high-quality results.

The Anatomy of an Effective Prompt

Core Components:

  • Context - Background information
  • Role - Who the AI should be
  • Task - What to do
  • Format - How to structure output
  • Constraints - Boundaries and rules
  • Examples - Desired output samples
  • Pattern 1: Role-Task-Format (RTF)

    Structure:

    
    [Role]: You are a [specific expert role]

    [Task]: Your task is to [specific action] for [audience/purpose]

    [Format]: Provide your response as [specific format]

    Example:

    
    Role: You are a senior technical writer with 10 years of experience in software documentation.

    Task: Create a quick-start guide for a new user learning to use our API for the first time.

    Format: Structure as:

  • Prerequisites (bullet list)
  • Setup steps (numbered, with code blocks)
  • First API call (with example)
  • Common issues (FAQ format)
  • Pattern 2: Context-Action-Result (CAR)

    Structure:

    
    [Context]: Here's the situation: [detailed context]

    [Action]: I need you to [specific action]

    [Result]: The outcome should [desired characteristics]

    Example:

    
    Context: Our e-commerce company is launching in Europe next month. We currently only have US-focused marketing copy. Our brand voice is friendly but professional.

    Action: Adapt our homepage headline and subheadline for UK customers.

    Result: The copy should feel native to UK audiences, use British English spellings, and reference relevant local context without losing our brand voice.

    Pattern 3: Persona Pattern

    Structure:

    
    From now on, act as [detailed persona description].

    You have [specific knowledge/experience]. You communicate by [style characteristics]. Your goal is to [objective].

    When responding:

    • [Behavior 1]
    • [Behavior 2]
    • [Behavior 3]

    Example:

    
    From now on, act as a seasoned startup mentor who has founded three successful companies and invested in 50+ startups.

    You have deep experience in SaaS, marketplace, and fintech business models. You communicate directly, avoid buzzwords, and always tie advice to specific metrics or examples. Your goal is to help founders make practical decisions.

    When responding:

  • Ask clarifying questions before giving advice
  • Reference specific examples from your experience
  • Challenge assumptions when you see red flags
  • Prioritize actionable advice over theory
  • Pattern 4: Chain of Thought (CoT)

    Structure:

    
    [Problem statement]

    Think through this step-by-step:

  • First, consider [aspect 1]
  • Then, analyze [aspect 2]
  • Next, evaluate [aspect 3]
  • Finally, synthesize into [conclusion type]
  • Show your reasoning at each step.

    Example:

    
    A customer wants to return a product they bought 45 days ago. Our policy says 30 days, but they claim the product was defective from the start.

    Think through this step-by-step:

  • First, consider the policy implications
  • Then, analyze the customer's claim
  • Next, evaluate potential resolutions
  • Finally, recommend a course of action
  • Show your reasoning at each step.

    Pattern 5: Few-Shot Learning

    Structure:

    
    I want you to [task description].

    Here are examples of what I'm looking for:

    Input: [example 1 input] Output: [example 1 output]

    Input: [example 2 input] Output: [example 2 output]

    Input: [example 3 input] Output: [example 3 output]

    Now do the same for: Input: [actual input]

    Example:

    
    I want you to convert formal sentences to casual ones while preserving meaning.

    Here are examples:

    Input: "We would like to inform you that your order has been shipped." Output: "Great news - your order's on its way!"

    Input: "Please do not hesitate to contact us if you have any questions." Output: "Got questions? Just reach out!"

    Input: "We regret to inform you that the item is currently out of stock." Output: "Sorry, that item's sold out right now."

    Now do the same for: Input: "We are pleased to announce that your application has been approved."

    Pattern 6: Template Pattern

    Structure:

    
    I will provide [input type]. Generate [output type] using this template:

    --- [Template with placeholders] ---

    Placeholders explained:

  • [PLACEHOLDER_1]: [description]
  • [PLACEHOLDER_2]: [description]
  • Here's my input: [input]

    Example:

    
    I will provide company information. Generate a press release using this template:

    --- FOR IMMEDIATE RELEASE

    [HEADLINE - attention-grabbing, under 10 words]

    [CITY, DATE] - [COMPANY_NAME] today announced [KEY_NEWS].

    [QUOTE from company spokesperson about significance]

    [2-3 sentences of supporting details]

    About [COMPANY_NAME]: [BOILERPLATE - 2-3 sentences about the company]

    Contact: [CONTACT_INFO] ---

    Here's my input: Company: TechFlow (San Francisco-based project management SaaS) News: Raising $10M Series A led by Acme Ventures CEO: Sarah Chen Founded: 2022, currently 50 employees

    Pattern 7: Constraints Pattern

    Structure:

    
    [Task description]

    Constraints:

  • MUST: [required elements]
  • MUST NOT: [forbidden elements]
  • SHOULD: [preferred elements]
  • COULD: [optional elements]
  • Example:

    
    Write a LinkedIn post announcing I got a new job.

    Constraints:

  • MUST: Mention my gratitude to previous employer
  • MUST: Include the new company name and role
  • MUST: Be under 200 words
  • MUST NOT: Sound boastful or braggy
  • MUST NOT: Include specific salary information
  • SHOULD: Express excitement genuinely
  • SHOULD: Include a forward-looking statement
  • COULD: Thank specific people
  • COULD: Share what I'm most excited about
  • Pattern 8: Structured Output

    Structure:

    
    [Task description]

    Return your response in this exact JSON format: { "field_1": "[description]", "field_2": ["[item description]"], "field_3": { "subfield_a": "[description]", "subfield_b": "[description]" } }

    Example:

    
    Analyze this customer review and extract key information.

    Review: "The laptop arrived quickly and was well packaged. The screen is beautiful but the keyboard feels a bit mushy. Battery life is excellent - I got 10 hours on my flight. Would definitely recommend for casual users but serious typists might want to look elsewhere."

    Return your response in this exact JSON format: { "sentiment": "[positive/negative/mixed]", "pros": ["list of positive points"], "cons": ["list of negative points"], "recommendation": { "would_recommend": true/false, "best_for": "[target audience]", "not_ideal_for": "[audience to avoid]" }, "key_metrics": { "battery_life": "[mentioned hours or null]", "shipping": "[fast/slow/normal or null]" } }

    Pattern 9: Iterative Refinement

    Structure:

    
    [Initial task]

    After generating, critique your output for:

  • [Criterion 1]
  • [Criterion 2]
  • [Criterion 3]
  • Then provide an improved version addressing any issues found.

    Example:

    
    Write a headline for an article about AI in healthcare.

    After generating, critique your output for:

  • Is it specific enough to stand out?
  • Does it promise clear value to readers?
  • Is it free of clichés?
  • Then provide an improved version addressing any issues found.

    Pattern 10: Perspective Taking

    Structure:

    
    [Topic/question]

    Analyze this from the perspectives of:

  • [Stakeholder 1]
  • [Stakeholder 2]
  • [Stakeholder 3]
  • For each perspective, consider:

  • Their primary concerns
  • What they stand to gain/lose
  • Their likely objections
  • Then synthesize a balanced view.

    Example:

    
    Should our company require employees to return to office 3 days per week?

    Analyze this from the perspectives of:

  • Senior leadership focused on company culture
  • Middle managers responsible for team productivity
  • Individual contributors who have adapted to remote work
  • For each perspective, consider:

  • Their primary concerns
  • What they stand to gain/lose
  • Their likely objections
  • Then synthesize a balanced recommendation.

    Combining Patterns

    The most effective prompts often combine multiple patterns:

    
    [PERSONA]
    You are a senior product manager with experience launching B2B SaaS products.

    [CONTEXT] I'm preparing to launch a new project management tool for remote teams.

    [TASK WITH CONSTRAINTS] Create a launch checklist covering pre-launch, launch day, and post-launch activities.

    Constraints:

  • Focus on a small startup with limited marketing budget
  • Assume we have 500 beta users and a 10,000-person email list
  • Timeline: 4 weeks until launch
  • [FORMAT] Structure as three sections with checkboxes, responsible party, and timing for each item.

    [SELF-CRITIQUE] After creating the checklist, review for:

  • Realistic timing for a small team
  • Any missing critical items
  • Dependencies between items
  • Revise as needed.

    Quick Reference

    | Pattern | Best For | |---------|----------| | RTF | Clear, structured tasks | | CAR | Contextual business tasks | | Persona | Ongoing conversations | | CoT | Complex reasoning | | Few-Shot | Style/format matching | | Template | Consistent outputs | | Constraints | Bounded creativity | | Structured | Data extraction | | Iterative | High-quality content | | Perspective | Decision-making |

    Master these patterns to get consistently better results from any AI model.

    Share this article: