Prompt Patterns That Consistently Work with LLMs
Prompt engineering is about patterns, not tricks. Use repeatable structures to steer LLMs toward useful, concise, and controllable outputs across tasks and models.
- TL;DR: use explicit role, constraints, examples, and output format.
- Prefer few-shot + clear instructions for new tasks; zero-shot for simple queries.
- Iterate with targeted tests and evaluation metrics to refine behavior.
Try this quick interactive idea: open a text editor, paste a template from “Ready-to-use templates”, and swap the {{INPUT}} tokens to experiment with tone and length.
Quick answer — 1-paragraph summary
Use a clear role statement, desired format, and constraints: “You are a
Why these patterns still work
LLMs are statistical text generators that respond best to strong contextual signals. Role statements set an implicit prior, format/spec constraints narrow the model’s token distribution, and examples anchor behavior. Together, these elements reduce ambiguity and align outputs with user intent.
Concretely, patterns work because they:
- Provide a clear distribution of expected tokens (format)
- Reduce open-endedness (constraints and length limits)
- Offer demonstrations that the model can imitate (few-shot)
Core prompt patterns to use
Below are concise, reusable patterns. Replace angle-bracket tokens with your content.
- Role + Task + Format
You are a {role}. Given: {input}. Output: {result type} in {format}. Constraints: {constraints}. - Instruction + Example (few-shot)
Instruction: {task}. Example 1: Input: {i1} → Output: {o1}. Example 2: Input: {i2} → Output: {o2}. Now: Input: {input} → - Step-by-step decomposition
Step 1: {analysis}. Step 2: {plan}. Step 3: {final output}. - Constraint-first (for safety/format)
Do not include: {forbidden}. Must include: {required}. Return only: {machine-friendly format}.
Match patterns to tasks
Choose patterns based on task complexity and risk.
| Task type | Recommended pattern | Why |
|---|---|---|
| Simple Q&A | Role + Task + Format | Quick, minimal context needed |
| Summarization | Instruction + Examples + Constraints | Limits length, style, and accuracy |
| Code generation | Constraint-first + Examples | Enforce syntax and return only code |
| Creative writing | Role + Step-by-step | Guide tone and structure while allowing creativity |
Adapt patterns for new models
Different models vary in temperature, context window, and instruction-following fidelity. Start by tuning a few parameters and prompts:
- Lower temperature for factual or deterministic outputs; raise for creativity.
- Shorten examples if context window is limited; prefer single-shot with strong constraints.
- Run calibration prompts: same prompt across models to compare consistency and adjust instructions accordingly.
When switching models, validate on representative inputs and measure differences in hallucination rate, length variance, and response time.
Ready-to-use templates (copy/paste)
Replace tokens like {{INPUT}}, {{LENGTH}}, and {{TONE}}.
- Concise summary
You are an expert summarizer. Summarize the following text: {{INPUT}}. Output: one paragraph, max {{LENGTH}} words, neutral tone. Do not add new facts. - Customer email rewrite
You are a professional customer success writer. Rewrite this email for a {{TONE}} tone and keep key facts: {{INPUT}}. Output only the rewritten email. - Bug-to-ticket converter
You are a product triage assistant. Given: {{INPUT}}. Produce a ticket with fields: Title, Severity (low/med/high), Steps to reproduce, Expected result, Actual result, Attachments summary. - SEO meta generator
You are an SEO specialist. From this page content: {{INPUT}}, generate: 1) Title (<=60 chars), 2) Meta description (<=155 chars), 3) 5 focus keywords. Output as JSON only.
Test, evaluate, and refine prompts
Systematic testing is essential. Use small, repeatable experiments and track metrics.
- Define evaluation criteria: accuracy, brevity, format correctness, hallucination rate.
- Use a test set of 50–200 representative inputs for statistical reliability.
- Automate checks: regex or schema validation for structured outputs, and human reviews for nuance.
- Iterate: change one variable at a time (e.g., add example, tighten constraint) and measure impact.
Common pitfalls and how to avoid them
- Vague instructions — Remedy: add role, output format, and explicit constraints.
- Overlong context — Remedy: prune irrelevant info, summarize or provide pointers to external content.
- Model drifting (inconsistent style) — Remedy: include style examples and post-process normalization.
- Hallucinations — Remedy: require source citations or mark "I don't know" when unsure; validate with retrieval or grounding.
- Too-strict templates that block creativity — Remedy: allow a short "creative" section after constrained output.
Implementation checklist
- Define role, task, and required output format for each prompt.
- Create 2–3 concise examples for complex tasks.
- Add explicit constraints and forbidden content lists.
- Set evaluation criteria and build a test set.
- Run A/B tests across model parameters and iterate.
- Integrate validation (regex/schema) before downstream use.
FAQ
Q: How many examples should I include?
A: Start with 1–3 high-quality examples. Too many can crowd context; too few may be ambiguous.
Q: When should I use step-by-step prompts?
A: Use them for multi-step reasoning or when you want the model to expose intermediate steps for verification.
Q: How do I reduce hallucinations?
A: Ground outputs with sources, enforce "cite" constraints, or add a fallback response like "I don't know" for unverifiable claims.
Q: Are templates reusable across domains?
A: Yes, with small adaptations to domain vocabulary and examples. Validate on domain-specific test cases.

