← Back to Skills Marketplace
sky-lv

Skylv Prompt Optimization Tool

by SKY-lv · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ Security Clean
45
Downloads
0
Stars
1
Active Installs
1
Versions
Install in OpenClaw
/install skylv-prompt-optimization-tool
Description
Automatically analyzes, A/B tests, and optimizes AI prompts to improve output quality, reduce token usage, and increase consistency.
README (SKILL.md)

AI Prompt Optimizer — 提示词自动优化器

功能说明

基于 A/B 测试和性能数据,自动优化 AI 提示词,提升输出质量并降低 Token 消耗。让提示词工程从"艺术"变成"科学"。

核心能力

1. 提示词分析 (Prompt Analysis)

analysis_dimensions:
  - clarity: 清晰度(指令是否明确)
  - specificity: 具体性(是否有足够细节)
  - structure: 结构化(是否有清晰格式)
  - examples: 示例(是否有 few-shot 示例)
  - constraints: 约束(是否有输出限制)
  - tone: 语气(是否适合场景)

scoring:
  - overall_score: 0-100
  - dimension_scores: 各维度分数
  - improvement_areas: 需改进的方面

使用示例:

用户:分析这个提示词的质量
Agent:
  1. 多维度评分
  2. 识别问题点
  3. 提供改进建议

2. A/B 测试 (A/B Testing)

test_setup:
  - variants: 2-5 个提示词变体
  - sample_size: 每个变体 100+ 次测试
  - metrics: 质量评分、Token 消耗、用户满意度
  - duration: 7-14 天

metrics_tracked:
  - output_quality: 输出质量(1-5 分)
  - token_efficiency: Token 效率
  - user_satisfaction: 用户满意度
  - task_completion: 任务完成率

使用示例:

用户:为这个提示词运行 A/B 测试
Agent:
  1. 生成 3 个变体
  2. 分配流量(33% each)
  3. 收集性能数据
  4. 选出最优版本

3. 自动优化 (Auto Optimization)

optimization_techniques:
  - prompt_compression: 压缩冗余内容
  - structure_addition: 添加结构化格式
  - example_injection: 注入 few-shot 示例
  - constraint_refinement: 优化约束条件
  - tone_adjustment: 调整语气风格

expected_improvements:
  - token_reduction: 30-60%
  - quality_improvement: 20-40%
  - consistency: 提升 50%+

使用示例:

用户:优化这个提示词
Agent:
  1. 分析当前版本
  2. 应用优化技术
  3. 输出优化版本
  4. 对比性能数据

4. 提示词库 (Prompt Library)

categories:
  - writing: 写作类
  - coding: 编程类
  - analysis: 分析类
  - creative: 创意类
  - business: 商业类

features:
  - search: 关键词搜索
  - filter: 按类别/评分筛选
  - rating: 社区评分
  - versioning: 版本历史

优化框架

BEFORE → AFTER 对比

❌ 低效提示词:

帮我写一个 Python 函数,要能处理各种情况,
考虑周全一点,输出要好。

✅ 优化后:

# 角色
Python 高级开发工程师

# 任务
编写一个数据验证函数

# 输入
- data: dict,待验证数据
- schema: dict,验证规则

# 输出
- valid: bool,是否通过验证
- errors: list,错误列表(如有)

# 约束
- 使用 type hints
- 添加 docstring
- 包含单元测试示例
- 处理边界情况

# 示例
输入:{"name": "John", "age": 25}
输出:{"valid": True, "errors": []}

效果对比:

指标 Before After 提升
Token 消耗 800 450 -44%
输出质量 3.2/5 4.6/5 +44%
一致性 60% 92% +53%

优化技巧清单

1. 角色定义

  • ❌ "你是一个助手"
  • ✅ "你是拥有 10 年经验的资深 Python 工程师,擅长编写生产级代码"

2. 任务明确

  • ❌ "帮我处理这个"
  • ✅ "分析以下数据,输出 3 个关键洞察,每个洞察包含数据支撑"

3. 输出格式

  • ❌ "输出结果"
  • ✅ "以 JSON 格式输出,包含 keys: summary, insights, recommendations"

4. 添加示例

  • ❌ 无示例
  • ✅ "输入示例:... 期望输出:..."

5. 约束条件

  • ❌ 无约束
  • ✅ "不超过 500 字,使用专业术语,避免口语化"

工具函数

analyze_prompt

def analyze_prompt(prompt: str) -> dict:
    """
    提示词分析
    
    Args:
        prompt: 待分析提示词
    
    Returns:
        {
            "overall_score": 65,
            "dimensions": {
                "clarity": 70,
                "specificity": 55,
                "structure": 60,
                "examples": 40,
                "constraints": 50
            },
            "issues": [
                "缺少角色定义",
                "输出格式不明确",
                "没有示例"
            ],
            "suggestions": [
                "添加专业角色定义",
                "指定 JSON 输出格式",
                "添加 few-shot 示例"
            ]
        }
    """

optimize_prompt

def optimize_prompt(prompt: str, goal: str = "quality") -> dict:
    """
    提示词优化
    
    Args:
        prompt: 原始提示词
        goal: 优化目标 (quality|tokens|speed)
    
    Returns:
        {
            "original": {...},
            "optimized": "优化后的提示词",
            "changes": ["添加角色", "结构化", "添加示例"],
            "expected_improvement": {
                "quality": "+35%",
                "tokens": "-40%",
                "consistency": "+50%"
            }
        }
    """

run_ab_test

def run_ab_test(base_prompt: str, variants: list, iterations: int = 100) -> dict:
    """
    A/B 测试
    
    Args:
        base_prompt: 基础提示词
        variants: 变体列表
        iterations: 测试次数
    
    Returns:
        {
            "winner": "variant_2",
            "results": [
                {"variant": "base", "score": 3.8, "tokens": 500},
                {"variant": "v1", "score": 4.1, "tokens": 450},
                {"variant": "v2", "score": 4.6, "tokens": 420}
            ],
            "statistical_significance": 0.95
        }
    """

generate_variants

def generate_variants(prompt: str, count: int = 5) -> list:
    """
    生成提示词变体
    
    Args:
        prompt: 原始提示词
        count: 生成数量
    
    Returns:
        [
            {"id": "v1", "prompt": "...", "changes": ["添加角色"]},
            {"id": "v2", "prompt": "...", "changes": ["结构化"]},
            ...
        ]
    """

提示词模板库

写作类

template: blog_post
prompt: |
  # 角色
  资深内容创作者,10 年科技博客经验

  # 任务
  撰写一篇关于{主题}的博客文章

  # 要求
  - 字数:2000-2500 字
  - 结构:引言 + 3-5 个主体段落 + 结论
  - 语气:专业但易懂
  - 包含:实际案例、数据支撑、行动建议

  # 输出格式
  Markdown,包含 H2/H3标题、列表、引用块

编程类

template: code_review
prompt: |
  # 角色
  资深代码审查工程师,精通{语言}

  # 任务
  审查以下代码,输出审查报告

  # 审查维度
  1. 代码质量(命名、结构、注释)
  2. 安全性(OWASP Top 10)
  3. 性能(时间/空间复杂度)
  4. 可维护性(测试、文档)

  # 输出格式
  JSON:
  {
    "issues": [{"severity": "high|medium|low", "description": "...", "fix": "..."}],
    "score": 0-100,
    "summary": "..."
  }

分析类

template: data_analysis
prompt: |
  # 角色
  数据科学家,擅长商业洞察

  # 任务
  分析以下数据集,输出商业洞察

  # 分析框架
  1. 描述性统计(均值、中位数、分布)
  2. 趋势分析(同比、环比)
  3. 异常检测(离群值、异常模式)
  4. 商业建议(可行动洞察)

  # 输出格式
  Markdown 报告,包含图表描述、关键数字、行动建议

相关文件

触发词

  • 自动:检测 prompt、optimize、improve、A/B testing 相关关键词
  • 手动:/prompt-optimizer, /optimize-prompt, /ab-test
  • 短语:优化提示词、改进 prompt、A/B 测试

Usage

  1. Install the skill
  2. Configure as needed
  3. Run with OpenClaw
Usage Guidance
This appears safe to install as an instruction-only prompt optimizer. Before using its A/B testing features, set explicit limits on token budget, number of test runs, duration, and whether results are real or simulated.
Capability Analysis
Type: OpenClaw Skill Name: skylv-prompt-optimization-tool Version: 1.0.0 The skill bundle is a prompt engineering tool designed to help an AI agent analyze, optimize, and A/B test prompts. The SKILL.md file contains structured instructions, templates, and function definitions (e.g., analyze_prompt, optimize_prompt) that guide the agent's behavior for prompt optimization tasks. There is no evidence of malicious code, data exfiltration, or harmful prompt injection; all content is consistent with the stated goal of improving LLM output quality and reducing token costs.
Capability Assessment
Purpose & Capability
The skill’s prompt analysis, optimization, and A/B testing instructions match its stated purpose, but they are descriptive instructions rather than implemented code and include potentially high-volume testing guidance.
Instruction Scope
The A/B testing workflow recommends 100+ tests per prompt variant over 7–14 days, which could create token cost or long-running work if followed literally.
Install Mechanism
There is no install spec and no code, which limits runtime risk, but the registry metadata and SKILL.md disagree on slug/version and the source/homepage are absent.
Credentials
The artifacts declare no required binaries, environment variables, credentials, config paths, or OS-specific access.
Persistence & Privilege
No artifact-backed persistence, background worker, credential use, local indexing, or privilege escalation mechanism is present.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install skylv-prompt-optimization-tool
  3. After installation, invoke the skill by name or use /skylv-prompt-optimization-tool
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.0
- Initial release of AI Prompt Optimizer. - Automatically analyzes and optimizes AI prompts to improve output quality and reduce token usage using A/B testing and performance data. - Features include multi-dimensional prompt analysis, automated A/B prompt testing, and intelligent optimization suggestions. - Provides a structured prompt template library for writing, coding, and data analysis use cases. - Includes utility functions for analyzing, optimizing, generating variants, and testing prompts.
Metadata
Slug skylv-prompt-optimization-tool
Version 1.0.0
License MIT-0
All-time Installs 1
Active Installs 1
Total Versions 1
Frequently Asked Questions

What is Skylv Prompt Optimization Tool?

Automatically analyzes, A/B tests, and optimizes AI prompts to improve output quality, reduce token usage, and increase consistency. It is an AI Agent Skill for Claude Code / OpenClaw, with 45 downloads so far.

How do I install Skylv Prompt Optimization Tool?

Run "/install skylv-prompt-optimization-tool" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Skylv Prompt Optimization Tool free?

Yes, Skylv Prompt Optimization Tool is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does Skylv Prompt Optimization Tool support?

Skylv Prompt Optimization Tool is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created Skylv Prompt Optimization Tool?

It is built and maintained by SKY-lv (@sky-lv); the current version is v1.0.0.

💬 Comments