TL;DR

Advanced prompting patterns improve AI outputs: chain-of-thought for reasoning, few-shot for examples, role prompting for expertise, and structured outputs for consistency.

Chain-of-Thought (CoT)

Concept: Ask AI to "think step-by-step"

Example:

  • Without: "What's 15% tip on $47?"
  • With CoT: "What's 15% tip on $47? Think step-by-step."
  • AI: "1. Calculate 15% of $47: 0.15 × 47 = 7.05. 2. The tip is $7.05."

When to use: Math, logic, complex reasoning

Few-Shot Prompting

Concept: Provide examples before asking

Example:

Classify sentiment:

"I love this!" → Positive
"Terrible experience" → Negative
"It's okay" → Neutral

"Best purchase ever" → ?

AI: "Positive"

When to use: Classification, formatting, style matching

Zero-Shot Prompting

Concept: No examples, just ask directly

Example: "Summarize this article in 3 sentences."

When to use: General tasks, when examples are hard to provide

Role Prompting

Concept: Ask AI to adopt a persona

Example:

  • "You are an expert SQL developer. Write a query to..."
  • "You are a kindergarten teacher. Explain photosynthesis..."

When to use: Need domain expertise or specific tone

Constrained Output

Concept: Specify exact output format

Example:

Extract info and return as JSON:
{
  "name": "",
  "email": "",
  "phone": ""
}

When to use: Structured data extraction, API responses

ReAct (Reasoning + Acting)

Concept: AI reasons, acts, observes, repeats

Example:

Question: What's the weather in Paris?
Thought: I need to search for Paris weather
Action: Search "Paris weather"
Observation: 15°C, cloudy
Thought: I have the answer
Answer: It's 15°C and cloudy in Paris.

When to use: Multi-step tasks, tool use

Self-Consistency

Concept: Generate multiple answers, pick most common

Process:

  1. Ask same question with temperature > 0
  2. Generate 5-10 responses
  3. Return most frequent answer

When to use: Critical tasks, reduce hallucinations

Negative Prompting

Concept: Tell AI what NOT to do

Example:

  • "Explain AI. Don't use jargon. Don't exceed 100 words. Don't assume technical background."

When to use: Avoid common mistakes, control output

Prompt Chaining

Concept: Break complex tasks into steps

Example:

  1. First prompt: "List main points from this article"
  2. Second prompt: "For each point, provide supporting evidence"
  3. Third prompt: "Write a summary integrating all points"

When to use: Complex tasks, exceeding context limits

Meta-Prompting

Concept: Ask AI to improve your prompt

Example:

  • "I want to write better product descriptions. Suggest a good prompt for that."

When to use: Learning, optimization

Best practices

Be specific:

  • "Write a 200-word email" > "Write an email"

Provide context:

  • "For a technical audience familiar with AI"

Use delimiters:

  • Use triple backticks for code
  • Use """ for text blocks

Iterate:

  • Start simple, add constraints
  • Test and refine

Common mistakes

  • Too vague ("Tell me about AI")
  • Too complex (multiple tasks in one prompt)
  • No examples when needed
  • Assuming AI knows your context

Template example

[Role]: You are an expert [domain]
[Context]: The user is [description]
[Task]: [Specific request]
[Constraints]: [Format, length, style]
[Examples]: [If needed]

What's next

  • Prompting 101 (basics)
  • Evaluating AI Answers
  • Advanced Prompt Optimization