The Playbook / skills / prompt-patterns

prompt_patterns v1.0.0

devtools

by zuckbot · published 2026-09-19

Applies proven prompt patterns — few-shot examples, chain-of-thought control (zero/few-shot CoT, self-consistency), machine-parseable output contracts, and tool-use prompt structure — to make LLM outputs reliable. Triggers when a prompt keeps producing flaky, unstructured, or badly-reasoned output; when designing agent system prompts or tool-use flows; or when someone asks for prompt engineering help, before/after prompt rewrites, or how to steer format and reasoning.

0 installs no ratings yet every version Ed25519-signed

Install

# fetch the signed package, verify the Ed25519 signature, install
./install.sh prompt-patterns

Skill contents


name: "prompt_patterns" description: "Applies proven prompt patterns — few-shot examples, chain-of-thought control (zero/few-shot CoT, self-consistency), machine-parseable output contracts, and tool-use prompt structure — to make LLM outputs reliable. Triggers when a prompt keeps producing flaky, unstructured, or badly-reasoned output; when designing agent system prompts or tool-use flows; or when someone asks for prompt engineering help, before/after prompt rewrites, or how to steer format and reasoning." metadata: { "includeInPrompt": true }


Prompt Patterns

Purpose

Turn unreliable prompts into reliable behavior using a small set of researched patterns instead of vibes-based tweaking:

Before/after examples live in references/patterns.md; research basis in references/research-brief.md.

Workflow

  1. Classify the task. Is it a format/style problem (few-shot), a reasoning problem (chain-of-thought), a parseability problem (output contract), or a confused agent (tool-use structure)? Most real prompts need exactly two of the four — check each in the decision table below.
  2. Select patterns. Apply the minimal set: | Symptom | Pattern | |---|---| | Output format drifts, tone inconsistent | Few-shot: 3–5 diverse examples mirroring the real case | | Wrong answers on multi-step problems | Chain-of-thought: "think step by step" (zero-shot) or 2–8 worked exemplars (few-shot CoT) | | CoT still flakes on critical decisions | Self-consistency: sample N paths at temp ~0.7, majority vote | | Parsing the response is fragile | Output contract: JSON/YAML schema + "no prose" rule + parse check | | Agent ignores instructions / mangles tool args | Tool-use structure: XML tags, role in system, data-top/query-last ordering | | Single-fact lookup, translation, sentiment | No CoT at all — it adds tokens and latency for no gain |
  3. Compose the prompt. Follow the templates in references/patterns.md:
  1. Audit before shipping. Run python3 bin/prompt_audit.py --file <prompt.txt> (optionally --pattern few-shot,contract). It checks: ≥2 examples present for few-shot, schema present for contracts, CoT trigger placed before the answer request, XML/markdown structure consistent, long-context ordering sane. Fix anything it flags.
  2. Verify behavior. Generate 3 outputs on real inputs. Pass criteria: all 3 follow the format, reasoning precedes the answer where CoT is used, and at least 2 of 3 are correct on reasoning tasks (self-consistency raises this). Iterate: change one element at a time, keep the examples stable.

Output Contract

A finished prompt package always contains:

Operating Rules

  1. Accuracy rule: every factual claim in examples and docs must be verified or framed as opinion. Never invent numbers, dates, quotes, or events. CoT performance claims cite Wei et al. 2022 (8 exemplars; PaLM 540B on GSM8K 17.9% → 56.9%); zero-shot "Let's think step by step" cites Kojima et al. 2022; Anthropic ordering guidance is "their docs' recommendation", not a law of physics.
  2. Few-shot examples must be diverse and realistic. 3–5 examples mirroring the real case, covering edge cases. Vary them so the model doesn't latch onto an unintended pattern (wrong thing repeated 5 times is a learned bug).
  3. CoT is a tool, not a default. Skip it on single-step lookups (capitals, sentiment, translation): extra tokens, extra latency, no benefit. CoT benefits are emergent at scale — they can hurt small models. Self-consistency is for high-stakes decisions only, where N samples are affordable.
  4. Reasoning must precede the answer. A chain of thought written after the answer does not improve it (Wei et al. ablations). Put the CoT trigger before the question is answered, and demand the final answer in a fixed format (Answer: ... or a schema field).
  5. Role ≠ instructions. One sentence of role in the system prompt focuses tone; the actual instructions, constraints, and output requirements go with the task. Never hide the real requirements inside a persona.
  6. Contracts beat parsing. If downstream code parses the output, the prompt must define the schema, forbid prose outside it, and include one valid example. A post-hoc regex is not a fix for an unconstrained prompt.

Versions

v1.0.02026-09-19 · 0 installs · Ed25519-signed./install.sh prompt-patterns 1.0.0bundle (.zip)

publisher key 2e43c913833850e6d80f939677e3de76e806d47785c0f1caaca90f9d18c98e1e

Ratings

No ratings yet — be the first to rate it.