Skip to content

Latest commit

 

History

History
59 lines (42 loc) · 6.01 KB

File metadata and controls

59 lines (42 loc) · 6.01 KB

📋 Prompt Engineering Patterns — Quick Reference Cheatsheet

Use this as a scannable reference when you know what you need but want to quickly find the right pattern.


🧱 Foundational Patterns

# Pattern One-Line Description When To Use Difficulty
🔗 01 Chain-of-Thought Force the model to show its reasoning before concluding Multi-step reasoning, math, complex analysis Beginner
🎯 02 Few-Shot Examples Show 2-3 examples of desired output to set quality bar Consistent tone, format, or style across outputs Beginner
🎭 03 Role Assignment Give the model a specific expert persona and behavioral traits Need domain expertise or specific communication style Beginner
📋 04 Output Formatting Define exact schema/structure for model output Parsing outputs programmatically or comparing results Beginner
🪜 05 Step-by-Step Decomposition Break complex task into sequential subtasks in one prompt Task too complex for one pass but doesn't need a pipeline Beginner

⚡ Intermediate Patterns

# Pattern One-Line Description When To Use Difficulty
🔄 06 Self-Consistency Checking Analyze from multiple frameworks, then synthesize High-stakes decisions where wrong answers have consequences Intermediate
🚧 07 Constraint Setting Add explicit boundaries on length, scope, tone, and content Model goes off-track in predictable, repeatable ways Intermediate
🚫 08 Negative Examples Show what NOT to do with annotated bad examples Persistent failure modes that instructions alone can't fix Intermediate
📐 09 Context Window Management Structure long inputs to prevent "lost in the middle" failures Working with large documents or many data points Intermediate
🌡️ 10 Temperature & Sampling Match randomness parameters to task type Outputs too repetitive (temp too low) or chaotic (too high) Intermediate

🔬 Advanced Patterns

# Pattern One-Line Description When To Use Difficulty
🏗️ 11 System Prompt Architecture Multi-section system prompt with identity, capabilities, boundaries Building any persistent AI application or chatbot Advanced
🛡️ 12 Adversarial Guardrails Defense-in-depth against prompt injection and misuse User-facing prompts with untrusted input Advanced
✅ 13 Chain of Verification Model verifies its own claims against source material Factual accuracy matters and hallucination is a real risk Advanced
⛓️ 14 Prompt Chaining Pipelines Multi-prompt pipeline with code logic between stages Task needs different models, validation, or branching Advanced
🎲 15 Dynamic Few-Shot Selection Programmatically choose examples based on input similarity Large example bank, limited context, varying input types Advanced

🏭 Production Patterns

# Pattern One-Line Description When To Use Difficulty
📊 16 Evaluation-Driven Iteration Systematic scoring framework replacing gut-feel tuning Moving from "works in testing" to "works at scale" Advanced
🧪 17 Regression Testing Automated test suite that catches prompt regressions Prompts in production where changes could break things Advanced
🔀 18 Multi-Model Routing Route requests to optimal model by complexity and cost Balancing quality, latency, and API spend Advanced
🔄 19 Graceful Degradation Fallback hierarchy when AI fails: cache → template → error User-facing system where downtime impacts real people Advanced
📦 20 Prompt Versioning Track, compare, and roll back prompt versions like code Prompts are core product and changes need auditability Advanced

Quick Decision Guide

"My output is wrong" → Start with Chain-of-Thought (#1) + Self-Consistency (#6)

"My output format is inconsistent"Output Formatting (#4) + Few-Shot Examples (#2)

"My output tone is off"Role Assignment (#3) + Negative Examples (#8)

"I'm going to production"System Prompt Architecture (#11) + Adversarial Guardrails (#12) + Evaluation (#16)

"I need to optimize costs"Multi-Model Routing (#18) + Context Window Management (#9)