Reusable Prompt Patterns
A cookbook of patterns that work across every model.
These patterns transfer across Claude, GPT, Gemini, and local models.
Role prompting
"You are a security reviewer. Audit this code for injection risks and report findings ordered by severity."
Few-shot
Show two examples of the desired output before the real input:
"Convert these commits to changelog entries. Example: 'fix: null check in cart' β '- Fixed a crash on empty carts.' Now: 'feat: add dark mode toggle'"
Chain-of-thought
"Think step by step, then give the final answer."
(For coding, the plan-first pattern is the practical version.)
Self-critique
"Review your own solution for edge cases, then revise it."
Constraint framing
"Solve this in under 30 lines. No regex. Pure functions only."
Output formatting
"Respond with exactly: a one-line summary, then a bullet list of changes."
The "rubber duck" explainer
"Explain this to a junior developer."
Iterative refinement
"That's close. Now make it handle the case where the list is empty."
Combining them
Strong prompts stack patterns:
"You are a senior Python reviewer (role). Here are two examples of good reviews (few-shot). Find bugs, think step by step (chain-of-thought), and output a numbered list of issues with severity (format)."
The meta-pattern
When unsure, ask the model to improve your prompt:
"Rewrite this prompt to be more precise and add a definition of done: ..."
Patterns are tools, not rules. Name the pattern you're using and the model will follow it more reliably.