Prompt engineering and optimization for AI/LLMs. Capabilities: transform unclear prompts, reduce token usage, improve structure, add constraints, optimize for specific models, backward-compatible rewrites. Actions: improve, enhance, optimize, refactor, compress prompts. Keywords: prompt engineering,
npx playbooks add skill samhvw8/dot-claude --skill prompt-enhancer
Transform user prompts into enhanced, production-ready versions that are concise, clean, and optimally structured for AI agents and sub-agents. Includes optimization techniques for reducing LLM output token usage while maintaining semantic accuracy and backward compatibility.
Use this skill when:
Evaluate if the task would benefit from specific prompting techniques:
Chain-of-Thought (CoT)
Chain-of-Draft
Few-Shot Learning
ReAct (Reasoning + Acting)
Self-Consistency
Tree-of-Thoughts
Role-Based Prompting
Least-to-Most Prompting
Apply technique only if it materially improves the task outcome.
When the goal is to reduce output tokens (API costs) while maintaining functionality:
Core Strategy: Compact Output + Server-Side Remapping
The LLM generates ultra-compact format, application remaps to original format for clients. This provides:
Optimization Techniques:
1. Ultra-Compact JSON Keys
queries → q, keyword → kw, filter → f, sort_by → s2. Short Codes for Repeated Values
category=MjUzOTM= → c=c43. String Compression for Structured Data
[{"filter_by":"category","operator":"=","value":"c4"}] → "c=c4"4. Omit Default Values
"sort_by":"relevant" when it's the default5. Operator Abbreviation
p<50000 instead of price<50000p/c prefixes during remappingc=c4;p<50000 for multiple filtersImplementation Pattern:
System Prompt Structure:
1. Define ultra-compact schema with examples
2. Specify key mappings (q=queries, kw=keyword, etc.)
3. Provide short codes table (c1=category1, c2=category2, etc.)
4. Show examples of compact output
5. Emphasize: omit defaults when possible
Application Layer:
1. Parse compact LLM output
2. Expand abbreviated keys
3. Map short codes to full values
4. Fill in default values
5. Return original format to client
Example Transformation:
Before Optimization (Original Output):
{
"queries": [
{"keyword": "milk", "filter": "category=dairy", "sort_by": "relevant"},
{"keyword": "bread", "filter": "category=bakery", "sort_by": "relevant"}
]
}
After Optimization (LLM Output - 60% smaller):
{
"q": [
{"kw": "milk", "f": "c=c8"},
{"kw": "bread", "f": "c=c3"}
]
}
Client Receives: Original format (remapped automatically)
Tradeoffs Analysis:
✅ Pros:
⚠️ Cons:
When to Apply:
When NOT to Apply:
Use XML tags for:
<constraints> - Limitations and boundaries<examples> - Sample inputs/outputs<context> - Background information<format> - Output structure requirements<requirements> - Specific criteria to meet<guidelines> - Best practices to followDo NOT use XML tags for:
Return ONLY the enhanced prompt with:
Before:
"I need you to help me write some code for a web app that will let users sign up and log in, and I want it to be secure and use modern best practices, and also it should have a nice UI, maybe you could suggest what framework to use?"
After:
Create a secure authentication system for a web application with user registration and login functionality.
<requirements>
</requirements>
<format>
</format>
---
Before:
"Can you analyze this data and tell me what's interesting about it and maybe make some charts or visualizations if that would help understand it better and also let me know if there are any trends or patterns?"
After:
Analyze the provided dataset and identify key insights, trends, and patterns.
<requirements>
</requirements>
<format>
</format>
---
Before:
"I'm trying to figure out the best pricing strategy for my SaaS product and I'm not sure whether to go with monthly or annual billing or maybe tiered pricing?"
After (with Chain-of-Thought technique applied):
Determine the optimal pricing strategy for a SaaS product.
<context>
Consider: monthly vs. annual billing, tiered pricing models, market positioning
</context>
<approach>
Think step by step:
</approach>
<requirements>
</requirements>
---
Before:
"Write a blog post about AI in healthcare that's engaging and informative"
After (with Chain-of-Draft technique applied):
Write an engaging and informative blog post about AI applications in healthcare.
<approach>
Use iterative drafting:
</approach>
<requirements>
</requirements>
<format>
</format>
Before (Original Prompt):
Create JSON queries to search for products. Each query should have a keyword, filter with category, and sort_by field. Return in this format: {"queries":[{"keyword":"milk","filter":"category=dairy","sort_by":"relevance"}]}
After (Token-Optimized Prompt):
Generate product search JSON queries. Reject dangerous content.
<rules>
- Each query: ≥1 category filter
- Total: ≥3 keywords (no duplicates)
- Use 'ex' for exact brands/attributes
- Default sort: relevant (omit if default)
- Filter: string format "c=c4" or "c=c4;p<50000"
</rules>
<categories>
c1=household, c2=personal care, c3=bakery, c4=fresh food, c5=oils, c6=dry goods, c7=cleaning, c8=dairy
</categories>
<examples>
"milk vinamilk"→{"q":[{"kw":"milk vinamilk","ex":"vinamilk","f":"c=c8","s":"popular"}]}
"rice noodles meat"→{"q":[{"kw":"rice","f":"c=c6"},{"kw":"noodles","f":"c=c6"},{"kw":"meat","f":"c=c4"}]}
"oranges under 50k"→{"q":[{"kw":"oranges","f":"c=c4;p<50000"}]}
</examples>
Result:
{"q":[{"kw":"milk","f":"c=c8"}]} (60% smaller){"queries":[{"keyword":"milk","filter":"category=dairy","sort_by":"relevance"}]}Before returning the enhanced prompt, verify:
When applying this skill:
The enhanced prompt should be immediately usable by the user without any modifications.
Weekly roundup of top Claude Code skills, MCP servers, and AI coding tips.