prompt-enhancer

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Prompt Enhancer Skill

Prompt增强技能

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.
将用户提示词转换为经过增强的、可用于生产环境的版本,使其简洁、规范,并针对AI Agent及子Agent实现最优结构。包含在保持语义准确性和向后兼容性的同时,降低LLM输出Token使用量的优化技术。

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
在以下场景中使用本技能:
  • 用户明确要求改进、增强或优化提示词
  • 用户发送的提示词模糊、冗长或结构混乱
  • 用户提及希望从AI交互中获得更好的结果
  • 用户请求帮助为Agent或自动化流程编写提示词
  • 用户的请求缺乏清晰度或合理结构
  • 用户希望减少LLM输出Token或降低API成本
  • 用户需要针对Token效率优化JSON Schema
  • 用户要求在保持兼容性的同时采用紧凑的输出格式

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
  1. 简洁性:删除冗余词汇,同时保留核心意图
  2. 结构性:使用清晰的格式,分多行呈现并划分逻辑板块
  3. XML集成:将自然文本与XML标签混合使用,提升清晰度与可解析性
  4. 直接任务:核心任务/目标不得包裹在XML元素内
  5. 纯净输出:仅返回增强后的提示词,不得添加任何元注释

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
  • 识别核心目标
  • 提取关键需求与约束条件
  • 检测模糊点或缺失信息
  • 确认目标Agent或使用场景

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.
评估任务是否能从特定提示词技术中获益:
Chain-of-Thought (CoT) 思维链
  • 适用场景:复杂推理、数学问题、逻辑推导、分步分析
  • 实现方式:添加“逐步思考”或“展示推理过程”的指令
Chain-of-Draft 草稿迭代链
  • 适用场景:写作任务、内容创作、迭代优化
  • 实现方式:先要求生成初始草稿,再逐步优化
Few-Shot Learning 少样本学习
  • 适用场景:基于模式的任务、特定格式要求、输出一致性需求
  • 实现方式:包含2-3个输入-输出示例
ReAct (Reasoning + Acting) 推理-行动结合
  • 适用场景:工具调用、多步骤任务、决策流程
  • 实现方式:将推理轨迹与行动步骤相结合
Self-Consistency 自一致性
  • 适用场景:需要验证的任务、存在多种有效解法的任务
  • 实现方式:要求生成多个解决方案,再进行综合
Tree-of-Thoughts 思维树
  • 适用场景:复杂问题解决、探索多种方案
  • 实现方式:要求在选择最优方案前探索多种路径
Role-Based Prompting 角色化提示
  • 适用场景:领域专业知识需求、视角转换任务
  • 实现方式:为AI分配专家角色(例如:“扮演资深工程师...”)
Least-to-Most Prompting 由简到繁提示
  • 适用场景:将复杂问题拆解为子问题
  • 实现方式:从简单版本入手,逐步提升复杂度
仅当技术能切实提升任务结果时才应用。

LLM Output Token Optimization

LLM输出Token优化

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)
当目标是在保持功能的同时减少输出Token(降低API成本)时:
核心策略:紧凑输出 + 服务端重映射
LLM生成超紧凑格式,应用程序在服务端将其重映射为原始格式供客户端使用。该策略可带来:
  • 显著的Token节省(30-60%)
  • 100%向后兼容性
  • 可忽略的重映射开销(<10微秒)
优化技术:
1. 超紧凑JSON键名
  • 用1-2个字符的缩写替换长键名
  • 示例:
    queries
    q
    keyword
    kw
    filter
    f
    sort_by
    s
  • 节省比例:每个键名节省70-85%
2. 重复值的短代码替换
  • 用短代码(c1-c18等)替换长ID/枚举值
  • 示例:
    category=MjUzOTM=
    c=c4
  • 在应用程序中提供反向映射表
  • 节省比例:分类/枚举值节省75-90%
3. 结构化数据的字符串压缩
  • 尽可能用紧凑字符串格式替代嵌套对象
  • 示例:
    [{"filter_by":"category","operator":"=","value":"c4"}]
    "c=c4"
  • 在服务端进行解析与展开
  • 节省比例:过滤/查询结构节省60-80%
4. 省略默认值
  • 指示LLM省略具有默认值的字段
  • 应用程序在重映射时自动填充默认值
  • 示例:当
    "sort_by":"relevant"
    为默认值时,省略该字段
  • 节省比例:当默认值常见时,可额外节省10-30%
5. 操作符缩写
  • 使用最简形式:
    p<50000
    替代
    price<50000
  • 在重映射时解析
    p
    /
    c
    前缀
  • 用分号组合多个过滤条件:
    c=c4;p<50000
实现模式:
System Prompt结构:
1. 定义超紧凑Schema并提供示例
2. 指定键名映射规则(q=queries, kw=keyword等)
3. 提供短代码对照表(c1=category1, c2=category2等)
4. 展示紧凑输出示例
5. 强调:可能时省略默认值

应用层处理:
1. 解析LLM生成的紧凑输出
2. 展开缩写键名
3. 将短代码映射为完整值
4. 填充默认值
5. 向客户端返回原始格式
转换示例:
优化前(原始输出):
json
{
  "queries": [
    {"keyword": "milk", "filter": "category=dairy", "sort_by": "relevant"},
    {"keyword": "bread", "filter": "category=bakery", "sort_by": "relevant"}
  ]
}
优化后(LLM输出 - 体积减小60%):
json
{
  "q": [
    {"kw": "milk", "f": "c=c8"},
    {"kw": "bread", "f": "c=c3"}
  ]
}
客户端收到的内容: 自动重映射后的原始格式
权衡分析:
优势:
  • 通常可节省30-60%的Token
  • 降低API成本
  • LLM响应速度更快(生成内容更少)
  • 100%向后兼容
⚠️ 劣势:
  • 存在重映射开销(<10μs,可忽略)
  • 实现复杂度更高
  • 需要应用层的映射逻辑
  • 提示词的人类可读性略有下降
适用场景:
  • 高流量API使用(每日请求>1000次)
  • 对成本敏感的应用
  • 输出Token占总成本的50%以上
  • Schema稳定且定义清晰
  • 应用程序可处理重映射逻辑
不适用场景:
  • 低流量使用(每日请求<100次)
  • Schema频繁变更
  • 人类可读性为核心需求
  • 无应用层(直接LLM→客户端)

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
  • 将复杂请求拆分为清晰的板块
  • 对以下内容使用XML标签:约束条件、示例、上下文、格式要求
  • 核心任务/目标以自然语言直接呈现
  • 按逻辑换行,提升可读性

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

XML标签使用指南

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
XML标签适用于:
  • <constraints>
    - 限制条件与边界
  • <examples>
    - 输入/输出示例
  • <context>
    - 背景信息
  • <format>
    - 输出结构要求
  • <requirements>
    - 需满足的特定标准
  • <guidelines>
    - 需遵循的最佳实践
XML标签不适用于:
  • 核心任务陈述
  • 主要任务描述
  • 核心请求或问题

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 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> - Highlight statistically significant findings - Identify temporal trends and correlations - Note any anomalies or outliers </requirements> <format> - Executive summary of findings - Data visualizations (charts/graphs as needed) - Detailed pattern analysis - Actionable recommendations </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: 1. Analyze target customer segments and their payment preferences 2. Evaluate competitor pricing models in the space 3. Calculate unit economics for each pricing option 4. Assess cash flow implications 5. Consider customer lifetime value impact </approach> <requirements> - Provide reasoning for each recommendation - Include pros/cons analysis - Suggest A/B testing approach if applicable </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: 1. Create outline with key points and narrative arc 2. Draft introduction and conclusion 3. Develop body sections with examples 4. Refine for clarity, flow, and engagement </approach> <requirements> - Target audience: healthcare professionals and tech enthusiasts - Length: 1200-1500 words - Include real-world examples and case studies - Balance technical accuracy with accessibility </requirements> <format> - Compelling headline - Hook in first paragraph - Clear section headers - Actionable takeaways </format>
优化前: "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?"
优化后: 为Web应用创建安全的认证系统,包含用户注册与登录功能。
<requirements> - 采用现代安全最佳实践 - 实现密码哈希与会话管理 - 设计简洁友好的用户界面 - 提供框架推荐及理由 </requirements> <format> - 代码实现 - 安全注意事项 - 框架选择依据 - UI/UX设计指南 </format>
优化前: "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?"
优化后: 分析提供的数据集,识别关键洞察、趋势与模式。
<requirements> - 突出统计显著性发现 - 识别时间趋势与相关性 - 标注异常值或离群点 </requirements> <format> - 发现摘要 - 数据可视化(按需使用图表) - 模式详细分析 - 可落地建议 </format>
优化前: "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?"
优化后(应用Chain-of-Thought技术): 为SaaS产品确定最优定价策略。
<context> 需考虑:月度/年度计费、分层定价模型、市场定位 </context> <approach> 逐步思考: 1. 分析目标客户群体及其支付偏好 2. 评估竞品定价模型 3. 计算各定价选项的单位经济效益 4. 评估对现金流的影响 5. 考虑对客户生命周期价值的影响 </approach> <requirements> - 为每个建议提供推理过程 - 包含优缺点分析 - 适用时提供A/B测试方案 </requirements>
优化前: "Write a blog post about AI in healthcare that's engaging and informative"
优化后(应用Chain-of-Draft技术): 撰写一篇引人入胜且内容详实的关于AI在医疗领域应用的博客文章。
<approach> 采用迭代草稿法: 1. 创建包含核心要点与叙事逻辑的大纲 2. 撰写引言与结论 3. 展开正文板块并添加示例 4. 优化内容的清晰度、流畅度与吸引力 </approach> <requirements> - 目标受众:医疗从业者与科技爱好者 - 篇幅:1200-1500词 - 包含真实案例与研究 - 平衡技术准确性与易读性 </requirements> <format> - 吸睛标题 - 开篇钩子 - 清晰的板块标题 - 可落地的关键要点 </format>

Real-World Token Optimization Example

真实场景Token优化示例

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:
  • LLM generates:
    {"q":[{"kw":"milk","f":"c=c8"}]}
    (60% smaller)
  • Application remaps to:
    {"queries":[{"keyword":"milk","filter":"category=dairy","sort_by":"relevance"}]}
  • Client receives original format unchanged
  • Token savings: 60.5% on typical 3-query response
优化前(原始提示词):
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"}]}
优化后(Token优化提示词):
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>
结果:
  • LLM生成内容:
    {"q":[{"kw":"milk","f":"c=c8"}]}
    (体积减小60%)
  • 应用程序重映射为:
    {"queries":[{"keyword":"milk","filter":"category=dairy","sort_by":"relevance"}]}
  • 客户端收到的内容与原始格式完全一致
  • Token节省率:典型3查询响应节省60.5%

Quality Checklist

质量检查清单

Before returning the enhanced prompt, verify:
  • ✓ Main objective is clear and unambiguous
  • ✓ XML tags are used appropriately (not for main mission)
  • ✓ Structure uses multiple lines for readability
  • ✓ Language is concise and direct
  • ✓ No extraneous commentary included
  • ✓ All key requirements preserved
  • ✓ Actionable and complete
  • ✓ If optimizing tokens: compact schema defined, mapping clear, examples provided
返回增强后的提示词前,需验证:
  • ✓ 核心目标清晰明确
  • ✓ XML标签使用恰当(未包裹核心任务)
  • ✓ 结构采用多行呈现,可读性强
  • ✓ 语言简洁直接
  • ✓ 无多余注释
  • ✓ 所有关键需求均被保留
  • ✓ 内容可直接执行且完整
  • ✓ 若进行Token优化:已定义紧凑Schema、映射规则清晰、提供示例

Implementation Notes

实现注意事项

When applying this skill:
  1. Read the user's prompt completely
  2. Identify enhancement opportunities
  3. Apply structural and linguistic improvements
  4. Output ONLY the enhanced version
  5. Do not ask for clarification unless absolutely critical information is missing
The enhanced prompt should be immediately usable by the user without any modifications.
应用本技能时:
  1. 完整阅读用户的提示词
  2. 识别可优化的空间
  3. 应用结构与语言优化
  4. 仅输出增强后的版本
  5. 除非缺失关键信息,否则无需请求澄清
增强后的提示词应可直接被用户使用,无需任何修改。