Prompt Patterns

Example-Driven Specification

Specifies desired model behavior through concrete examples rather than abstract rules.

Also known asFew-Shot Promptingk-Shot PromptingIn-Context Learning
Example-Driven Specification pattern diagram

Problem

Abstract instructions often underspecify format, granularity, and edge-case behavior, causing inconsistent outputs despite correct intent.

Solution

Provide examples as the primary specification so the model infers the contract from input-output patterns, boundaries, and conventions. In-context pattern induction stabilizes behavior more reliably than long abstract rules.

Example

One worked example. The book has 2–4 per technique.

Prompt
Extract action items from meeting notes. For each item include the owner, task, and deadline.

Example input:
Jordan will send the revised rollout plan by Thursday. Elena needs to update the support playbook sometime this month.

Example output:
- Jordan | Send revised rollout plan | Thursday
- Elena | Update support playbook | This month

Now extract from these notes:
Maya said we need to finalize the payroll rollout checklist by Friday. Ben will update the admin access runbook next week. Priya said she would review the audit export flow when she has time.
Response
- Maya | Finalize payroll rollout checklist | Friday
- Ben | Update admin access runbook | Next week
- Priya | Review audit export flow | Unspecified

Techniques

Concrete ways to implement Example-Driven Specification. Each technique fits a different situation.

  • 01

    Demonstration Examples

    Show complete input-output pairs so the model learns the task and expression style by continuing the demonstrated pattern.

  • 02

    Contrastive Examples

    Include both desirable and undesirable outputs for the same input so the model infers boundaries and avoids known failure modes.

  • 03

    Convention Mirroring

    Provide samples of a target tone, structure, or style so the model absorbs and continues the convention without explicit rules.

Prompt Patterns book cover

Full treatment in the book

Example-Driven Specification — the complete chapter

  • Mechanism — why this pattern works
  • 2–4 worked examples per technique
  • Placement, sequencing, and debugging rules
  • Composition with related patterns