Skip to main content
skill Claude Code CX Codex Cursor

prompt-engineering-patterns — Claude Code skill: prompts

This skill helps design, test, and refine prompts for LLM applications. Use it for reusable templates, few-shot examples, and structured responses.

Install into Claude Code · Plugin marketplace All methods and platforms ↓
/plugin marketplace add wshobson/agents
/plugin install llm-application-dev@claude-code-workflows
Open on GitHub

What prompt-engineering-patterns does

prompt-engineering-patterns covers prompt design for production LLM applications. It helps clarify instructions, set model behavior, define output formats, and diagnose inconsistent results. The skill includes patterns for few-shot prompting, chain-of-thought, self-consistency, and handling edge cases.

It shows how to build templates with variables, conditional sections, and multi-turn conversations. For machine-readable results, it uses JSON mode and Pydantic schemas. Prompt work can be refined through iteration, A/B tests, and metrics such as accuracy, consistency, latency, token usage, and success rate. Detailed worked examples live in references/details.md.

The quick start uses langchain_anthropic, langchain_core, ChatAnthropic, and Pydantic. Install it if you regularly design prompts for Claude or other LLMs and need a repeatable process; for a simple one-off request, it adds more structure than necessary.

What it helps with

  • design a reusable prompt template with variables
  • select few-shot examples for a target task
  • debug inconsistent model responses
  • enforce JSON output with a Pydantic schema
  • compare prompt variants with performance metrics

Example prompts for the agent

  • Optimize this prompt and create two versions to compare.
  • Build a template with few-shot examples and a variable for the user query.
  • Explain why these responses fail the JSON schema and add a verification step.

How to install prompt-engineering-patterns

1Plugin marketplace

/plugin marketplace add wshobson/agents
/plugin install llm-application-dev@claude-code-workflows

This installs the whole llm-application-dev plugin with all its skills

2Skills CLI (Vercel)

npx skills add wshobson/agents --skill prompt-engineering-patterns -a claude-code

3Manually: put the files in place

~/.claude/skills/prompt-engineering-patterns/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/prompt-engineering-patterns/

From the same set213

The whole set →
typescript-advanced-types Seth Hobson Guides an agent through advanced TypeScript types, from generics to conditional and mapped types. Use it for typed libraries, API clients, or strict configuration objects. Claude Code CX Codex Cursor 92,169installs tailwind-design-system Seth Hobson Helps build design systems with Tailwind CSS v4, from theme tokens to component variants. Use it when a project needs shared UI patterns. Claude Code CX Codex Cursor 70,180installs brand-landingpage Travis D. Elliott This skill interviews you about the product and its visual direction, then builds a landing page through Stitch. Use it when there’s no established design yet. Claude Code CX Codex Cursor 39,476installs python-testing-patterns Seth Hobson This skill guides Python testing with pytest, fixtures and mocks. Use it when building a test suite or tracking down failing checks. Claude Code CX Codex Cursor 36,943installs python-performance-optimization Seth Hobson This skill profiles Python code to locate CPU and memory bottlenecks. Use it when an application responds slowly or consumes too many resources. Claude Code CX Codex Cursor 35,675installs nextjs-app-router-patterns Seth Hobson This skill covers Next.js App Router patterns for rendering, routing, and data fetching. Use it when starting an App Router project or moving from Pages Router. Claude Code CX Codex Cursor 32,529installs api-design-principles Seth Hobson Use this skill to plan or review REST and GraphQL APIs. It helps when writing a specification or setting API conventions for a team. Claude Code CX Codex Cursor 30,348installs code-review-excellence Seth Hobson This skill guides pull request reviews, catches logic and security issues, and helps teams give specific feedback. Use it for review standards or developer mentoring. Claude Code CX Codex Cursor 30,193installs

Similar

finnish-humanizer official github This skill removes common AI markers from Finnish writing while keeping the meaning intact. Use it for .md and .txt files with Finnish content. GitHub Copilot 9,200installs create-llms official github Creates llms.txt in the repository root and maps the project files that an LLM needs to understand. GitHub Copilot 9,200installs microsoft-skill-creator official github Builds agent skills for Microsoft technologies with Learn MCP research. Use it when you need a reusable knowledge package for Azure, .NET, M365, or VS Code. GitHub Copilot 9,000installs php-mcp-server-generator official github Generates a PHP MCP server project with tools, resources, prompts, and tests. Use it when you need a structured starting point for a PHP-based MCP server. GitHub Copilot 8,900installs workiq-copilot official github Connects GitHub Copilot to Microsoft 365 context through WorkIQ, including email, meetings, documents and Teams. Use it when a task needs current organisational information beyond the repository. GitHub Copilot 8,800installs typespec-api-operations official github Adds GET, POST, PATCH, and DELETE operations to a TypeSpec API plugin for Microsoft 365 Copilot. Use it when defining CRUD routes, parameters, and card-based responses. GitHub Copilot 8,800installs skill-creator official anthropics Creates and refines skills, then tests them with prompts, evaluations, and performance checks. Claude Code Claude.ai 414,180installs writing-for-agents Matt Pocock Guidance for writing skills and agent-facing documents. Use it when editing AGENTS.md, CLAUDE.md, or reference files reached from them. Claude Code 466,719installs

Questions about prompt-engineering-patterns

How do I install prompt-engineering-patterns in Claude Code?

Run npx skills add wshobson/agents --skill prompt-engineering-patterns -a claude-code. The skill file is placed at ~/.claude/skills/prompt-engineering-patterns/SKILL.md.

What does prompt-engineering-patterns do?

It helps design and debug prompts by selecting examples, building reusable templates, defining structured outputs, and checking response quality.

What is used in the structured-output example?

The quick start uses langchain_anthropic, langchain_core, and Pydantic. It creates ChatAnthropic, defines an SQLQuery schema, and passes it to structured output.

Source text

SKILL.md · MIT
---
name: prompt-engineering-patterns
description: >-
  This skill should be used when the user asks to "optimize a prompt", "improve prompt
  performance", "design a prompt template", "write better prompts", "debug prompt issues", "use
  chain-of-thought", "structured prompting", "few-shot prompting", or wants to apply advanced
  prompt engineering patterns for production LLM applications.
---

# Prompt Engineering Patterns

Master advanced prompt engineering techniques to maximize LLM performance, reliability, and controllability.

## When to Use This Skill

- Designing complex prompts for production LLM applications
- Optimizing prompt performance and consistency
- Implementing structured reasoning patterns (chain-of-thought, tree-of-thought)
- Building few-shot learning systems with dynamic example selection
- Creating reusable prompt templates with variable interpolation
- Debugging and refining prompts that produce inconsistent outputs
- Implementing system prompts for specialized AI assistants
- Using structured outputs (JSON mode) for reliable parsing

## Core Capabilities

### 1. Few-Shot Learning

- Example selection strategies (semantic similarity, diversity sampling)
- Balancing example count with context window constraints
- Constructing effective demonstrations with input-output pairs
- Dynamic example retrieval from knowledge bases
- Handling edge cases through strategic example selection

### 2. Chain-of-Thought Prompting

- Step-by-step reasoning elicitation
- Zero-shot CoT with "Let's think step by step"
- Few-shot CoT with reasoning traces
- Self-consistency techniques (sampling multiple reasoning paths)
- Verification and validation steps

### 3. Structured Outputs

- JSON mode for reliable parsing
- Pydantic schema enforcement
- Type-safe response handling
- Error handling for malformed outputs

### 4. Prompt Optimization

- Iterative refinement workflows
- A/B testing prompt variations
- Measuring prompt performance metrics (accuracy, consistency, latency)
- Reducing token usage while maintaining quality
- Handling edge cases and failure modes

### 5. Template Systems

- Variable interpolation and formatting
- Conditional prompt sections
- Multi-turn conversation templates
- Role-based prompt composition
- Modular prompt components

### 6. System Prompt Design

- Setting model behavior and constraints
- Defining output formats and structure
- Establishing role and expertise
- Safety guidelines and content policies
- Context setting and background information

## Quick Start

```python
from langchain_anthropic import ChatAnthropic
from langchain_core.prompts import ChatPromptTemplate
from pydantic import BaseModel, Field

# Define structured output schema
class SQLQuery(BaseModel):
    query: str = Field(description="The SQL query")
    explanation: str = Field(description="Brief explanation of what the query does")
    tables_used: list[str] = Field(description="List of tables referenced")

# Initialize model with structured output
llm = ChatAnthropic(model="claude-sonnet-5")
structured_llm = llm.with_structured_output(SQLQuery)

# Create prompt template
prompt = ChatPromptTemplate.from_messages([
    ("system", """You are an expert SQL developer. Generate efficient, secure SQL queries.
    Always use parameterized queries to prevent SQL injection.
    Explain your reasoning briefly."""),
    ("user", "Convert this to SQL: {query}")
])

# Create chain
chain = prompt | structured_llm

# Use
result = await chain.ainvoke({
    "query": "Find all users who registered in the last 30 days"
})
print(result.query)
print(result.explanation)
```

## Detailed patterns and worked examples

Detailed pattern documentation lives in `references/details.md`. Read that file when the navigation tier above is insufficient.

## Best Practices

1. **Be Specific**: Vague prompts produce inconsistent results
2. **Show, Don't Tell**: Examples are more effective than descriptions
3. **Use Structured Outputs**: Enforce schemas with Pydantic for reliability
4. **Test Extensively**: Evaluate on diverse, representative inputs
5. **Iterate Rapidly**: Small changes can have large impacts
6. **Monitor Performance**: Track metrics in production
7. **Version Control**: Treat prompts as code with proper versioning
8. **Document Intent**: Explain why prompts are structured as they are

## Common Pitfalls

- **Over-engineering**: Starting with complex prompts before trying simple ones
- **Example pollution**: Using examples that don't match the target task
- **Context overflow**: Exceeding token limits with excessive examples
- **Ambiguous instructions**: Leaving room for multiple interpretations
- **Ignoring edge cases**: Not testing on unusual or boundary inputs
- **No error handling**: Assuming outputs will always be well-formed
- **Hardcoded values**: Not parameterizing prompts for reuse

## Success Metrics

Track these KPIs for your prompts:

- **Accuracy**: Correctness of outputs
- **Consistency**: Reproducibility across similar inputs
- **Latency**: Response time (P50, P95, P99)
- **Token Usage**: Average tokens per request
- **Success Rate**: Percentage of valid, parseable outputs
- **User Satisfaction**: Ratings and feedback

© Seth Hobson · MIT · wshobson/agents

See also

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor