Skip to content

Prompt Engineering Patterns

Lets your agent write, test and refine prompts using proven techniques like few-shot examples and chain-of-thought.

Repository
wshobson/agents
Stars
42,095
Licence
MIT
Files
10 files

What it does

When installed, the agent gains a playbook of prompt-writing methods for building reliable AI features: giving worked examples, asking for step-by-step reasoning, requesting structured JSON output, reusable templates, and system prompt design. It can also help diagnose why a prompt gives inconsistent answers and suggest fixes. It includes a sample template library and a Python script that can A/B test prompt variants against a test suite and track accuracy, latency and token use.

Great for

  • Developers building LLM-powered features who need consistent, parseable outputs
  • Teams maintaining a library of prompt templates that should be tested and versioned
  • Anyone debugging a prompt that works sometimes but not reliably

Skip it if

  • Casual one-off questions where a plain prompt is enough; the patterns add overhead
  • Running the optimization script on untrusted test data or against paid API keys without review, since it executes code and calls a model endpoint

Try asking

  • “Optimize this customer-support prompt so it returns consistent JSON with a category and urgency field”
  • “Write a reusable prompt template with variables for summarizing meeting notes”
  • “Help me add few-shot examples to my classifier prompt and explain how to pick them”
  • “Design a system prompt for a SQL assistant that refuses destructive queries”
Step-by-step guide: how to use Prompt Engineering PatternsInstall, first run, examples, tips and FAQs

Install in 3 steps

  1. 1

    Download the skill

    The ZIP contains the 10 original files, the MIT licence and an attribution note.

    prompt-engineering-patterns.zip
  2. 2

    Add it to your agent

    Claude Code (all projects)

    mkdir -p ~/.claude/skills && unzip prompt-engineering-patterns.zip -d ~/.claude/skills/

    Claude Code / Agent SDK (this project only)

    mkdir -p .claude/skills && unzip prompt-engineering-patterns.zip -d .claude/skills/

    Claude apps (web/desktop): Settings → Capabilities → Skills → Upload skill, and choose the ZIP.

  3. 3

    Ask for the task

    No special command needed — the agent reads the skill's description and loads it when your request matches. Try one of the prompts above.

Get better results

  • Ask the agent to write a test suite of representative inputs before optimizing, so improvements are measurable
  • Review scripts/optimize-prompt.py and its LLM client before running it, and use a low-cost model or small test set first
  • Provide your current prompt and a few failing examples so the agent can diagnose specific issues

What's inside

  • assets/few-shot-examples.json
  • assets/prompt-template-library.md
  • references/chain-of-thought.md
  • references/details.md
  • references/few-shot-learning.md
  • references/prompt-optimization.md
  • references/prompt-templates.md
  • references/system-prompts.md
  • scripts/optimize-prompt.py
  • SKILL.md

Redistributed unmodified from wshobson/agents under the MIT licence. The assessment was drafted with AI from the skill's files on 2026-10-29. Skills can instruct your agent to run code — read SKILL.md and any scripts before installing.