prompt-engineering-patterns
Skill1 starsChanged 4 months agoMITView on GitHub
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.
16 other projects use a version of this, 13 of them edited.
Adopted by
Most recently taken up by
- JustinWangJP/cc-agent-teams-action-monitoredited, first seen Nov 8, 2026
- ControllableModel/SWE-Skills-Benchedited, first seen Nov 8, 2026
- The-AIOS/aiosedited, first seen Nov 3, 2026
- jonfdag-dot/claude-skills-plan-research-prompttheir own version, first seen Nov 1, 2026
- KumailQazi/krmaazha-binance-mcpedited, first seen Oct 17, 2026
- xfstudio/skillsedited, first seen Oct 13, 2026
Used with
Projects with it also use error-handling-patterns, tailwind-design-system and 1 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
xfstudioSkillerror-handling-patterns
Master error handling patterns across languages including exceptions, Result types, error propagation, and graceful degradation to build resilient applications. Use when implementing error handling, designing APIs, or improving application reliability.
Also in 3 projects that use this
xfstudioSkilltailwind-design-system
Build scalable design systems with Tailwind CSS, design tokens, component libraries, and responsive patterns. Use when creating component libraries, implementing design systems, or standardizing UI patterns.
Also in 3 projects that use this
MicrosoftSkillmcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).
Also in 3 projects that use this
Other versions16 projects use a version of this.
Word for word · 0
None found.
Edited · 13
- The-AIOS/aios★ 10527% same
- nilecui/SkillsBase★ 2740% same
- xfstudio/skills★ 937% same
- ControllableModel/SWE-Skills-Bench★ 840% same
- JustinWangJP/cc-agent-teams-action-monitor★ 632% same
- GPTtang/skill-atlas★ 432% same
- KumailQazi/krmaazha-binance-mcp★ 499% same
- ai4brands-design/claude-skills★ 237% same
- CodeWithBehnam/cc-docs★ 233% same
- roshankodi/agent-skills★ 299% same
3 more not listed
Wrote their own version · 3
- kumaran-is/claude-code-onboarding★ 35same name
- jonfdag-dot/claude-skills-plan-research-prompt★ 2same name
- Solonnikov/agent-skills★ 2same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository14 other files it gives its agents.
- skills/humanizer/AGENTS.mdAGENTS.md
- appscriptSkill
- brandkitSkill
- design-critiqueSkill
- enhance-promptSkill
- find-skillsSkill
- grafana-dashboardsSkill
- humanizerSkill
- jupyter-notebookSkill
- programmatic-seoSkill
- review-packagesSkill
- seoSkill
- VibeSec-SkillSkill
- vikunja-vjaSkill
The file
We split this skill into the rules it gives an agent
3 rules. 2 are common, 1 is distinctive, and 0 are very specific to this project.
2
Common
Most of the 16 edited versions we read keep these.
1
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Common: line 122
Version Control: Treat prompts as code with proper versioning
- Common: line 131
Ignoring edge cases: Not testing on unusual or boundary inputs
- Distinctive: line 133
Hardcoded values: Not parameterizing prompts for reuse
“Common” is measured: kept by at least 6 in 10 of the 16 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
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
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-4-6")
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
- Be Specific: Vague prompts produce inconsistent results
- Show, Don't Tell: Examples are more effective than descriptions
- Use Structured Outputs: Enforce schemas with Pydantic for reliability
- Test Extensively: Evaluate on diverse, representative inputs
- Iterate Rapidly: Small changes can have large impacts
- Monitor Performance: Track metrics in production
- Version Control: Treat prompts as code with proper versioning
- 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
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

