Claude
Skills
Sign in
Back

prompt-enhancer

Included with Lifetime
$97 forever

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, prompt optimization, token efficiency, LLM prompt, AI prompt, clarity, structure, system prompt, user prompt, few-shot, chain-of-thought, instruction tuning, prompt compression, token reduction, prompt rewrite, semantic preservation. Use when: improving unclear prompts, reducing token consumption, optimizing LLM outputs, restructuring verbose requests, creating system prompts, enhancing prompt clarity.

AI Agents

What this skill does


# Prompt Enhancer Skill

## Purpose

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.

## When to Use This Skill

Use this skill when:
- User explicitly asks to improve, enhance, or optimize a prompt
- User sends an unclear, verbose, or poorly structured prompt
- User mentions they want better results from AI interactions
- User asks for help writing prompts for agents or automation
- User's request lacks clarity or proper structure
- User wants to reduce LLM output tokens or API costs
- User needs to optimize JSON schema for token efficiency
- User requests compact output format while maintaining compatibility

## Core Principles

1. **Conciseness**: Remove unnecessary words while preserving intent
2. **Structure**: Use clear formatting with multiple lines and logical sections
3. **XML Integration**: Mix natural text with XML tags for clarity and parsing
4. **Direct Mission**: Main task/quest/mission should NOT be wrapped in XML elements
5. **Clean Output**: Return ONLY the enhanced prompt - no meta-commentary

## Enhancement Process

### Input Analysis
- Identify the core objective
- Extract key requirements and constraints
- Detect ambiguities or missing information
- Recognize the intended agent or use case

### Task-Based Technique Selection (Optional)
Evaluate if the task would benefit from specific prompting techniques:

**Chain-of-Thought (CoT)**
- Use for: Complex reasoning, math problems, logical deduction, step-by-step analysis
- Implementation: Add instruction to "think step by step" or "show your reasoning"

**Chain-of-Draft**
- Use for: Writing tasks, content creation, iterative refinement
- Implementation: Request initial draft, then progressive improvements

**Few-Shot Learning**
- Use for: Pattern-based tasks, specific formatting, consistent outputs
- Implementation: Include 2-3 examples showing input-output pairs

**ReAct (Reasoning + Acting)**
- Use for: Tool use, multi-step tasks, decision-making processes
- Implementation: Combine reasoning traces with action steps

**Self-Consistency**
- Use for: Tasks needing verification, multiple valid approaches
- Implementation: Request multiple solutions, then synthesis

**Tree-of-Thoughts**
- Use for: Complex problem-solving, exploring alternatives
- Implementation: Ask to explore multiple paths before selecting best

**Role-Based Prompting**
- Use for: Domain-specific expertise, perspective-taking
- Implementation: Assign expert role (e.g., "Act as a senior engineer...")

**Least-to-Most Prompting**
- Use for: Breaking down complex problems into subproblems
- Implementation: Start with simpler versions, build up complexity

**Apply technique only if it materially improves the task outcome.**

### LLM Output Token Optimization

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:
- Significant token savings (30-60%)
- 100% backward compatibility
- Negligible remapping overhead (<10 microseconds)

**Optimization Techniques:**

**1. Ultra-Compact JSON Keys**
- Replace long keys with 1-2 character abbreviations
- Examples: `queries` → `q`, `keyword` → `kw`, `filter` → `f`, `sort_by` → `s`
- Savings: 70-85% per key

**2. Short Codes for Repeated Values**
- Replace long IDs/enums with short codes (c1-c18, etc.)
- Example: `category=MjUzOTM=` → `c=c4`
- Provide reverse mapping table in application
- Savings: 75-90% on category/enum values

**3. String Compression for Structured Data**
- Use compact string format instead of nested objects when possible
- Example: `[{"filter_by":"category","operator":"=","value":"c4"}]` → `"c=c4"`
- Parse and expand server-side
- Savings: 60-80% on filter/query structures

**4. Omit Default Values**
- Instruct LLM to omit fields with default values
- Application fills in defaults during remapping
- Example: Omit `"sort_by":"relevant"` when it's the default
- Savings: Additional 10-30% when defaults are common

**5. Operator Abbreviation**
- Use shortest form: `p<50000` instead of `price<50000`
- Parse `p`/`c` prefixes during remapping
- Combine with semicolons: `c=c4;p<50000` for multiple filters

**Implementation 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):**
```json
{
  "queries": [
    {"keyword": "milk", "filter": "category=dairy", "sort_by": "relevant"},
    {"keyword": "bread", "filter": "category=bakery", "sort_by": "relevant"}
  ]
}
```

**After Optimization (LLM Output - 60% smaller):**
```json
{
  "q": [
    {"kw": "milk", "f": "c=c8"},
    {"kw": "bread", "f": "c=c3"}
  ]
}
```

**Client Receives:** Original format (remapped automatically)

**Tradeoffs Analysis:**

✅ **Pros:**
- 30-60% token savings typical
- Lower API costs
- Faster LLM response (less to generate)
- 100% backward compatible

⚠️ **Cons:**
- Remapping overhead (<10μs, negligible)
- More complex implementation
- Requires application-side mapping logic
- Prompt becomes slightly less human-readable

**When to Apply:**
- High-volume API usage (>1000 requests/day)
- Cost-sensitive applications
- Output tokens are >50% of total costs
- Schema is stable and well-defined
- Application can handle remapping logic

**When NOT to Apply:**
- Low-volume usage (<100 requests/day)
- Schema frequently changes
- Human readability is critical
- No application layer (direct LLM → client)

### Structural Improvements
- Break complex requests into clear sections
- Use XML tags for: constraints, examples, context, format requirements
- Keep main mission/task as direct natural language
- Apply logical line breaks for readability

### Language Optimization
- Replace verbose phrases with concise alternatives
- Use active voice and direct instructions
- Eliminate redundancy and filler words
- Maintain specificity while reducing length

## XML Tag Usage Guidelines

**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 follow

**Do NOT use XML tags for:**
- The primary mission statement
- The main task description
- The core request or question

## Output Format

Return ONLY the enhanced prompt with:
- No conversational lead-in
- No explanations or commentary
- No placeholder text
- No quotation marks wrapping the prompt
- No meta-discussion about the enhancement

## Example Transformations

**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>
- Implement modern security best practices
- Include password hashing and session management
- Design a clean, user-friendly interface
- Provide framework recommendation with rationale
</requirements>

<format>
- Code implementation
- Security considerations
- Framework justification
- UI/UX guidelines
</format>

---

**Before:**
"Can you an
Files: 1
Size: 12.9 KB
Complexity: 23/100
Category: AI Agents

Related in AI Agents