Free Resource

Prompt Engineering
Cheat Sheet

A concise, printable reference covering 12 essential prompting techniques, system prompt structure, sampling parameters, and common patterns.

12 Prompting Techniques at a Glance

From foundational patterns to advanced strategies — master every technique to get better AI outputs.

# Technique Level What It Does Example Snippet
1 Zero-Shot Basic Direct instruction with no examples. Relies on the model's pre-trained knowledge. Classify this review as positive or negative.
2 Few-Shot Basic Provides 2–5 examples before the actual task to steer output format and reasoning. Review: "Great!" → Positive
Review: "Awful" → Negative
Review: "Decent" → ?
3 Chain-of-Thought (CoT) Inter Asks the model to reason step-by-step before giving a final answer. Think step by step before answering.
4 Role Prompting Basic Assigns a persona or expertise to frame the model's behaviour and tone. You are a senior security engineer…
5 Structured Output Inter Constrains output to JSON, YAML, Markdown tables, or other machine-readable formats. Return valid JSON: { "sentiment": "…", "score": 0.0 }
6 Self-Consistency Adv Samples multiple CoT paths and picks the majority answer for higher accuracy. Generate 5 independent reasoning paths, then vote on the answer.
7 ReAct (Reason+Act) Adv Interleaves reasoning traces with tool-use actions (search, code exec, API calls). Thought → Action → Observation → … → Answer
8 Tree-of-Thought Adv Explores branching reasoning paths, evaluates each, and prunes weak branches. Propose 3 approaches, evaluate each, then select the best.
9 Iterative Refinement Inter Multi-turn prompting where you critique and refine the output progressively. Good start. Now make it more concise and add data.
10 Prompt Chaining Inter Breaks complex tasks into sequential sub-prompts, piping output forward. Step 1: Extract → Step 2: Analyse → Step 3: Format
11 Constraint Setting Basic Defines boundaries: word limits, forbidden topics, required sections. Answer in ≤100 words. Do not mention competitors.
12 Meta-Prompting Adv Uses the AI to generate or improve prompts itself — prompting about prompting. Write the best prompt to accomplish [task]. Explain why each element matters.

🏗 System Prompt Structure — Quick Reference

A well-structured system prompt is the foundation of reliable AI behaviour. Follow this anatomy for consistent results.

System Prompt Template
┌─ ROLE ──────────────────────────────────────────────────────┐
You are [Expert Title] specialising in [Domain].
├─ CONTEXT ───────────────────────────────────────────────────┤
Background: [Relevant context the AI needs to know]
Audience:   [Who will read the output]
Goal:       [What the output should achieve]
├─ INSTRUCTIONS ──────────────────────────────────────────────┤
## Rules
1. [Specific instruction]
2. [Format requirement]
3. [Quality standard]
## Constraints
- Do NOT [forbidden action]
- Always [required behaviour]
├─ OUTPUT FORMAT ─────────────────────────────────────────────┤
Respond in [format: JSON / Markdown / bullet list]
Include:    [required fields or sections]
├─ EXAMPLES (Optional) ──────────────────────────────────────┤
Input:  "Example input"
Output: "Example output"
└────────────────────────────────────────────────────────────┘

✅ Do

  • Be specific about the role and expertise level
  • Define the output format upfront
  • Include 1–3 examples for complex tasks
  • Set explicit constraints and guardrails
  • Separate concerns with clear section headers

❌ Don't

  • Use vague instructions like "be helpful"
  • Overload with 20+ rules (aim for 3–7)
  • Contradict yourself between sections
  • Skip the output format specification
  • Assume the model remembers previous chats

🌡 Temperature & Top-P Settings Guide

Sampling parameters control the randomness and creativity of outputs. Lower = more deterministic, higher = more creative.

Temperature Scale

0.0 Deterministic Code gen, data extraction, classification
0.3 Focused Summarisation, Q&A, analysis
0.7 Balanced General writing, emails, explanations
1.0+ Creative Brainstorming, poetry, fiction, ideation

Top-P (Nucleus Sampling)

Parameter
Recommendation
Use Case
Top-P = 0.1
Very narrow token pool — highly predictable
Factual extraction, code completion
Top-P = 0.5
Moderate diversity — good default
Business writing, documentation
Top-P = 0.9
Wide token pool — varied and creative
Creative writing, brainstorming
Top-P = 1.0
Full vocabulary considered
Maximum creativity (use with low temp)

💡 Pro Tip: Pick One

Adjust either Temperature or Top-P, not both simultaneously. Start with Temperature = 0.3 for most tasks and only increase when you need more variety.

🧩 Common Prompt Patterns

Copy-paste these battle-tested patterns as starting points for your prompts.

1 — Few-Shot Classification

# Classify customer support tickets

Examples:
"I can't log in"Account Access
"Charge me twice"Billing
"App crashes on upload"Bug Report
"How do I export data?"Feature Question

Now classify: "My invoice shows the wrong amount"

2 — Chain-of-Thought Reasoning

Question: A store sells apples for £1.20 each.
If I buy 7 apples and pay with a £10 note, how much change?

Instructions:
1. Calculate the total cost step-by-step
2. Show your working clearly
3. State the final answer on its own line prefixed with "Answer:"

Think step by step.

3 — Structured JSON Output

Task: Extract product details from the following description.

Output format (strict JSON):
{
  "name":        // string — product name
  "price":       // number — price in GBP
  "features":    // string[] — key features (max 5)
  "category":    // enum: "electronics"|"clothing"|"home"|"other"
  "confidence":  // number 0-1 — extraction confidence
}

Description: """
The UltraClean Pro 3000 is a cordless vacuum priced at £249.99.
Features include HEPA filtration, 60-min battery, and LED headlights.
"""

4 — Role Prompting with Constraints

System:
You are a senior technical writer at a SaaS company.

## Rules
- Write at a Year 9 reading level (Flesch-Kincaid ≥ 60)
- Use active voice exclusively
- Maximum 150 words per response
- Include a TL;DR at the top
- Format with Markdown headings and bullet points

## Do NOT
- Use jargon without defining it
- Include marketing language or superlatives
- Make claims without citing a source

5 — Meta-Prompt (Prompt Generator)

Task: Write the optimal prompt for the following goal.

Goal: [Describe what you want the AI to accomplish]

Requirements for the generated prompt:
1. Include a clear role definition
2. Provide 2 few-shot examples
3. Specify the output format
4. Add 3 constraints to prevent common mistakes
5. Explain why each element was chosen

Output: The complete prompt wrapped in a code block,
followed by a brief explanation of design decisions.

🎯 Quick Decision Matrix

Choose the right technique based on your task type.

Task Type Recommended Technique Temperature Key Tip
Classification Few-Shot + Constraint 0.0 – 0.2 Provide balanced examples for each class
Code Generation Role + Structured Output 0.0 – 0.3 Specify language, framework, and style guide
Creative Writing Role + Iterative Refinement 0.7 – 1.0 Set tone and audience before generating
Data Extraction Structured Output + Constraint 0.0 Provide the exact JSON schema expected
Maths / Logic Chain-of-Thought + Self-Consistency 0.0 – 0.2 Always require step-by-step working
Research / Analysis ReAct + Prompt Chaining 0.3 – 0.5 Break into gather → analyse → synthesise steps
Summarisation Constraint + Zero-Shot 0.2 – 0.4 Specify max length and key points to include
Prompt Improvement Meta-Prompting 0.3 – 0.5 Ask the AI to critique and rewrite your prompt