Prompt Engineering Patterns
Unverified●31/40Claude Code◐PartialHas SKILL.md but declares no allowed-tools — Claude Code will ask for permission each time
Cursor◐PartialPlain prose you can paste in — but no Cursor rules file
Codex◐PartialPlain prose you can paste in — but no AGENTS.md
Gemini CLI◐PartialPlain prose you can paste in
Copilot◐PartialPlain prose you can paste in — but no Copilot instructions file
npx agentalley add prompt-engineering-patternsWho is stuck, and on what
>- 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.
The whole source
Frontmatter — 2 properties
| 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. |
| 1 | --- |
| 2 | name: prompt-engineering-patterns |
| 3 | description: >- |
| 4 | This skill should be used when the user asks to "optimize a prompt", "improve prompt |
| 5 | performance", "design a prompt template", "write better prompts", "debug prompt issues", "use |
| 6 | chain-of-thought", "structured prompting", "few-shot prompting", or wants to apply advanced |
| 7 | prompt engineering patterns for production LLM applications. |
| 8 | ---A5 — No allowed-tools declared — no way to tell what this skill may touch |
| 9 | |
| 10 | # Prompt Engineering Patterns |
| 11 | |
| 12 | Master advanced prompt engineering techniques to maximize LLM performance, reliability, and controllability. |
| 13 | |
| 14 | ## When to Use This Skill |
| 15 | |
| 16 | - Designing complex prompts for production LLM applications |
| 17 | - Optimizing prompt performance and consistency |
| 18 | - Implementing structured reasoning patterns (chain-of-thought, tree-of-thought) |
| 19 | - Building few-shot learning systems with dynamic example selection |
| 20 | - Creating reusable prompt templates with variable interpolation |
| 21 | - Debugging and refining prompts that produce inconsistent outputs |
| 22 | - Implementing system prompts for specialized AI assistants |
| 23 | - Using structured outputs (JSON mode) for reliable parsing |
| 24 | |
| 25 | ## Core Capabilities |
| 26 | |
| 27 | ### 1. Few-Shot Learning |
| 28 | |
| 29 | - Example selection strategies (semantic similarity, diversity sampling) |
| 30 | - Balancing example count with context window constraints |
| 31 | - Constructing effective demonstrations with input-output pairs |
| 32 | - Dynamic example retrieval from knowledge bases |
| 33 | - Handling edge cases through strategic example selection |
| 34 | |
| 35 | ### 2. Chain-of-Thought Prompting |
| 36 | |
| 37 | - Step-by-step reasoning elicitation |
| 38 | - Zero-shot CoT with "Let's think step by step" |
| 39 | - Few-shot CoT with reasoning traces |
| 40 | - Self-consistency techniques (sampling multiple reasoning paths) |
| 41 | - Verification and validation steps |
| 42 | |
| 43 | ### 3. Structured Outputs |
| 44 | |
| 45 | - JSON mode for reliable parsing |
| 46 | - Pydantic schema enforcement |
| 47 | - Type-safe response handling |
| 48 | - Error handling for malformed outputs |
| 49 | |
| 50 | ### 4. Prompt Optimization |
| 51 | |
| 52 | - Iterative refinement workflows |
| 53 | - A/B testing prompt variations |
| 54 | - Measuring prompt performance metrics (accuracy, consistency, latency) |
| 55 | - Reducing token usage while maintaining quality |
| 56 | - Handling edge cases and failure modes |
| 57 | |
| 58 | ### 5. Template Systems |
| 59 | |
| 60 | - Variable interpolation and formatting |
| 61 | - Conditional prompt sections |
| 62 | - Multi-turn conversation templates |
| 63 | - Role-based prompt composition |
| 64 | - Modular prompt components |
| 65 | |
| 66 | ### 6. System Prompt Design |
| 67 | |
| 68 | - Setting model behavior and constraints |
| 69 | - Defining output formats and structure |
| 70 | - Establishing role and expertise |
| 71 | - Safety guidelines and content policies |
| 72 | - Context setting and background information |
| 73 | |
| 74 | ## Quick Start |
| 75 | |
| 76 | ```python |
| 77 | from langchain_anthropic import ChatAnthropic |
| 78 | from langchain_core.prompts import ChatPromptTemplate |
| 79 | from pydantic import BaseModel, Field |
| 80 | |
| 81 | # Define structured output schema |
| 82 | class SQLQuery(BaseModel): |
| 83 | query: str = Field(description="The SQL query") |
| 84 | explanation: str = Field(description="Brief explanation of what the query does") |
| 85 | tables_used: list[str] = Field(description="List of tables referenced") |
| 86 | |
| 87 | # Initialize model with structured output |
| 88 | llm = ChatAnthropic(model="claude-sonnet-5") |
| 89 | structured_llm = llm.with_structured_output(SQLQuery) |
| 90 | |
| 91 | # Create prompt template |
| 92 | prompt = ChatPromptTemplate.from_messages([ |
| 93 | ("system", """You are an expert SQL developer. Generate efficient, secure SQL queries. |
| 94 | Always use parameterized queries to prevent SQL injection. |
| 95 | Explain your reasoning briefly."""), |
| 96 | ("user", "Convert this to SQL: {query}") |
| 97 | ]) |
| 98 | |
| 99 | # Create chain |
| 100 | chain = prompt | structured_llm |
| 101 | |
| 102 | # Use |
| 103 | result = await chain.ainvoke({ |
| 104 | "query": "Find all users who registered in the last 30 days" |
| 105 | }) |
| 106 | print(result.query) |
| 107 | print(result.explanation) |
| 108 | ``` |
| 109 | |
| 110 | ## Detailed patterns and worked examples |
| 111 | |
| 112 | Detailed pattern documentation lives in `references/details.md`. Read that file when the navigation tier above is insufficient. |
| 113 | |
| 114 | ## Best Practices |
| 115 | |
| 116 | 1. **Be Specific**: Vague prompts produce inconsistent results |
| 117 | 2. **Show, Don't Tell**: Examples are more effective than descriptions |
| 118 | 3. **Use Structured Outputs**: Enforce schemas with Pydantic for reliability |
| 119 | 4. **Test Extensively**: Evaluate on diverse, representative inputs |
| 120 | 5. **Iterate Rapidly**: Small changes can have large impacts |
| 121 | 6. **Monitor Performance**: Track metrics in production |
| 122 | 7. **Version Control**: Treat prompts as code with proper versioning |
| 123 | 8. **Document Intent**: Explain why prompts are structured as they are |
| 124 | |
| 125 | ## Common Pitfalls |
| 126 | |
| 127 | - **Over-engineering**: Starting with complex prompts before trying simple ones |
| 128 | - **Example pollution**: Using examples that don't match the target task |
| 129 | - **Context overflow**: Exceeding token limits with excessive examples |
| 130 | - **Ambiguous instructions**: Leaving room for multiple interpretations |
| 131 | - **Ignoring edge cases**: Not testing on unusual or boundary inputs |
| 132 | - **No error handling**: Assuming outputs will always be well-formed |
| 133 | - **Hardcoded values**: Not parameterizing prompts for reuse |
| 134 | |
| 135 | ## Success Metrics |
| 136 | |
| 137 | Track these KPIs for your prompts: |
| 138 | |
| 139 | - **Accuracy**: Correctness of outputs |
| 140 | - **Consistency**: Reproducibility across similar inputs |
| 141 | - **Latency**: Response time (P50, P95, P99) |
| 142 | - **Token Usage**: Average tokens per request |
| 143 | - **Success Rate**: Percentage of valid, parseable outputs |
| 144 | - **User Satisfaction**: Ratings and feedback |
| 145 |
Reviews
Installed this one?Write the first review and take the Trailblazer badge.
Alternatives
Task Coordination StrategiesDecompose complex tasks, design dependency graphs, and coordinate multi-agent work with proper task descriptions and workload balancing. Use this skill when breaking down work for agent teams, managing task dependencies, or monitoring team progress.◐◐◐◐◐●35/40Ebay Seller Tools·····●34/40Tough Decision Advisor: Every Angle ConsideredHand in a decision you're stuck on. Get back a clear breakdown of every angle — the trade-offs, the risks, the blind spot, and a recommended path.●····●32/40DHDNA Profiler — Cognitive Pattern ExtractionPaste any email, proposal, or note someone wrote, and get back a plain-language read on how they think, what drives their decisions, and how they communicate.●····●32/40