提示词重写器:优化 AI 提示词以获得更好结果 - Openclaw Skills

作者:互联网

2026-04-16

AI教程

什么是 提示词重写器?

提示词重写器是一款专业级工具,旨在弥合模糊的用户意图与高性能 AI 执行之间的差距。作为 Openclaw Skills 生态系统的核心组件,它从五个关键维度系统地评估提示词:清晰度、具体性、结构性、完整性和可用性。通过识别请求中的具体弱点,它为用户提供全面的质量评分和可操作的反馈,以确保其指令产生一致、可靠的结果。

除了简单的编辑,这项技能还为开发者和创作者架起了教育桥梁。它将提示工程的技术细微差别(如思维链、少样本学习和基于角色的框架)转化为实用的、开箱即用的模板。使用此技能可确保您的 AI 代理获得所需的上下文和结构,从而最大限度地减少幻觉并提高输出相关性,使其成为在 Openclaw Skills 框架内构建应用的必备工具。

下载入口:https://github.com/openclaw/skills/tree/main/skills/hhhh124hhhh/prompt-rewriter

安装与下载

1. ClawHub CLI

从源直接安装技能的最快方式。

npx clawhub@latest install prompt-rewriter

2. 手动安装

将技能文件夹复制到以下位置之一

全局模式 ~/.openclaw/skills/ 工作区 /skills/

优先级:工作区 > 本地 > 内置

3. 提示词安装

将此提示词复制到 OpenClaw 即可自动安装。

请帮我使用 Clawhub 安装 prompt-rewriter。如果尚未安装 Clawhub,请先安装(npm i -g clawhub)。

提示词重写器 应用场景

  • 将单句请求转化为针对复杂任务的详细、多步骤指令。
  • 排除导致模糊或幻觉 AI 响应的无效提示词故障。
  • 生成提示词的多个变体,以便进行系统性的 A/B 测试以优化性能。
  • 在团队中标准化提示词结构,以确保文档和代码审查的一致性。
  • 通过实际的上下文示例学习高级提示工程技术。
提示词重写器 工作原理
  1. 该技能捕捉原始输入提示词,并识别用户的主要目标和潜在约束。
  2. 它执行多维度分析,根据标准工程最佳实践给出 0 到 10 的评分。
  3. 系统生成三个不同的重写变体:进行最小更改的“保守修复版”、旨在实现最大效果的“技术增强版”以及易于使用的“简化版”。
  4. 它展示改进后的选项,并解释所应用的特定提示工程模式,如角色扮演或约束定义。
  5. 用户选择最佳变体,或使用提供的 A/B 测试指南进一步完善指令集。

提示词重写器 配置指南

提示词重写器是一个在代理环境中运行的基于逻辑的技能。要开始优化提示词,请确保您的代理配置为识别 prompt-rewriter 技能定义。无需外部依赖或脚本。

# 通过 CLI 启动提示词优化的示例
openclaw skill run prompt-rewriter --input "编写一个代码审查提示词"

提示词重写器 数据架构与分类体系

该技能利用定量评分矩阵评估提示词健康状况,并将发现组织成结构化报告。

指标 定义 评分权重
清晰度 请求是否明确且术语定义良好? 0-2 分
具体性 约束、边界和输出格式是否明确说明? 0-2 分
结构性 信息是否使用框架或步骤进行逻辑组织? 0-2 分
完整性 是否有足够的上下文且包含所有要求? 0-2 分
可用性 提示词是否可重复使用、适应性强且语言自然? 0-2 分

最终得分决定提示词的就绪程度:8-10(优秀)、6-7(良好)、4-5(可用)、0-3(较差)。

name: prompt-rewriter
description: Advanced prompt rewriting and optimization service. Analyzes prompts for clarity, specificity, structure, completeness, and usability. Identifies weaknesses, suggests improvements, and generates multiple rewrite options. Use when users need to improve an existing prompt's effectiveness, understand why a prompt isn't working well, generate variations of a prompt for A/B testing, or learn prompt engineering best practices through examples.

Prompt Rewriter

Overview

Help users transform vague, ineffective prompts into powerful, well-structured instructions that produce consistent, high-quality results from AI models. Analyzes prompts across multiple quality dimensions and provides actionable suggestions.

Quick Start

User says: "Help me rewrite this prompt: 'Write a blog post about AI'"

You should:

  1. Analyze the original prompt's weaknesses (too vague, no audience specified, no format defined)
  2. Identify improvement areas (add topic specificity, target audience, tone, length, structure)
  3. Provide 2-3 rewrite options with different approaches
  4. Explain the changes and why they matter

Core Capabilities

1. Prompt Quality Analysis

Evaluate prompts across five key dimensions:

Clarity (0-2)

  • Is the request unambiguous?
  • Are terms defined?
  • Can Claude understand without clarification?

Specificity (0-2)

  • Are constraints clear?
  • Is output format specified?
  • Are boundaries defined?

Structure (0-2)

  • Is information organized logically?
  • Are steps clear if applicable?
  • Is there a framework?

Completeness (0-2)

  • Is sufficient context provided?
  • Are requirements comprehensive?
  • Is missing information flagged?

Usability (0-2)

  • Is it reusable?
  • Can it be adapted easily?
  • Is the language natural?

Scoring:

  • 8-10: Excellent prompt, minor tweaks needed
  • 6-7: Good prompt, moderate improvements possible
  • 4-5: Functional but has significant weaknesses
  • 0-3: Poor prompt, needs major rework

2. Rewrite Generation

Generate 2-3 rewrite variations using different approaches:

Variation 1: Conservative Fix

  • Keep original intent
  • Add specificity and structure
  • Minimal stylistic changes
  • Best when user wants to preserve voice

Variation 2: Technique Enhancement

  • Apply prompt engineering patterns (CoT, few-shot, etc.)
  • Add advanced techniques
  • Focus on effectiveness
  • Best when user wants optimal results

Variation 3: Simplification

  • Strip complexity while keeping core request
  • Make more conversational
  • Focus on ease of use
  • Best for beginners or quick tasks

3. Improvement Explanation

For each rewrite, explain:

  • What changed (specific modifications)
  • Why it matters (impact on AI output)
  • When to use (appropriate scenarios)

4. Pattern Application

Apply proven prompt engineering techniques:

Chain of Thought (CoT)

  • "Let's think step by step"
  • "First, analyze... Then, evaluate..."
  • Best for: complex reasoning, math, logic

Few-Shot Learning

  • Provide 2-3 examples before request
  • Pattern: Example 1 → Example 2 → Example 3 → Your task
  • Best for: format specification, style matching

Role-Based Prompts

  • "Act as a senior engineer..."
  • "You are a marketing expert..."
  • Best for: specialized knowledge, tone control

Output Structure

  • Use templates and headers
  • Define sections explicitly
  • Best for: reports, documentation, structured content

Constraint Definition

  • "Limit response to 500 words"
  • "Exclude jargon for non-technical audience"
  • Best for: length control, accessibility

5. A/B Testing Guidance

Help users test prompts effectively:

  • Generate variations systematically
  • Suggest test methodology
  • Recommend evaluation criteria

Workflow

Step 1: Receive and Analyze

  1. Extract the prompt to rewrite
  2. Identify user's intent (what do they want to achieve?)
  3. Check for constraints (tone, format, length, audience)
  4. Evaluate against 5 quality dimensions
  5. Calculate score and identify primary weaknesses

Step 2: Generate Rewrites

  1. Variation 1 (Conservative): Add structure, clarify terms, define output
  2. Variation 2 (Technique-Enhanced): Apply relevant patterns (CoT, few-shot, etc.)
  3. Variation 3 (Simplified): Make conversational, reduce complexity

Step 3: Present Options

For each rewrite:

  • Show the improved prompt
  • Explain the changes
  • Highlight which techniques were used
  • Recommend which to use based on context

Step 4: Educational Component

Briefly explain:

  • Which prompt engineering techniques were applied
  • Why they work in this context
  • How the user can apply them in future prompts

Common Patterns and Fixes

Pattern: Too Vague

Weak: "Write about climate change" Fix: Add specificity - audience, purpose, format, depth

Strong: "Write a 1000-word blog post for a general audience explaining climate change's causes, effects, and potential solutions. Use an optimistic but realistic tone. Include: (1) introduction with hook, (2) 3 main sections with data, (3) conclusion with actionable advice."

Pattern: No Structure

Weak: "Analyze this data" Fix: Add framework or step-by-step instructions

Strong: "Analyze the sales data provided. Structure your response as:

  1. Executive Summary (3 bullet points of key findings)
  2. Detailed Analysis (break down by region and product)
  3. Trend Identification (what patterns emerge?)
  4. Recommendations (3 actionable steps based on data)"

Pattern: Missing Context

Weak: "Improve this email" Fix: Add context about audience, goal, constraints

Strong: "Improve this email for a C-level executive audience. Goal: Get approval for a $50k project. Keep it under 200 words. Tone: Professional but persuasive. Current email: [paste]"

Pattern: Unclear Output Format

Weak: "Create marketing content" Fix: Specify format, style, deliverables

Strong: "Create marketing content for our new product launch. Deliver:

  1. Social media post (LinkedIn, 150 words, professional tone)
  2. Email blurb (75 words, excitement-focused)
  3. Website headline (catchy, under 10 words)
  4. 3 key benefits (each under 15 words)"

Examples

Example 1: Content Creation

Input Prompt: "Write an article about remote work"

Analysis:

  • Clarity: 1/2 (clear topic but vague on specifics)
  • Specificity: 0/2 (no format, audience, length)
  • Structure: 0/2 (no framework)
  • Completeness: 0/2 (missing key details)
  • Usability: 1/2 (somewhat reusable)
  • Score: 2/10 - Major weaknesses across dimensions

Rewrite Option 1 (Conservative):

Write a 1500-word article about remote work for business professionals. Cover:
1. Benefits of remote work (productivity, cost savings, flexibility)
2. Challenges (isolation, communication, work-life balance)
3. Best practices for success (routine, communication tools, workspace setup)
4. Future trends (hybrid models, technology evolution)

Tone: Informative and balanced
Format: Use headings and bullet points

Rewrite Option 2 (Technique-Enhanced):

Act as an experienced remote work consultant. Write a comprehensive article about remote work for business leaders considering transitioning their teams.

Structure your response using the following framework:

**Introduction (150 words)**
- Hook with a surprising statistic
- Briefly state the article's purpose
- Outline what will be covered

**Section 1: The Business Case (400 words)**
Let's think about this step by step:
- Analyze cost benefits (real estate, equipment, turnover)
- Evaluate productivity studies (with data sources)
- Consider talent access (hiring from anywhere)

**Section 2: Implementation Challenges (350 words)**
- Communication breakdowns (provide examples)
- Culture maintenance (specific strategies)
- Performance management (tools and metrics)

**Section 3: Success Framework (400 words)**
Provide a concrete 90-day rollout plan:
- Month 1: Foundation and tools
- Month 2: Training and feedback
- Month 3: Optimization and refinement

**Conclusion (200 words)**
- Summarize key takeaways
- Provide 3 actionable next steps
- End with an inspiring vision

Tone: Professional yet engaging
Examples: Include 2-3 real company case studies

Rewrite Option 3 (Simplified):

Write an article about remote work. Make it about 1500 words long and aimed at business people who are thinking about letting employees work from home. Talk about:
- Why it's good (saves money, people like it)
- What's hard (staying in touch, managing performance)
- How to do it right (tools, schedules, clear expectations)

Use a helpful, informative tone with clear headings.

Recommendation: Use Option 2 if the user wants maximum impact. Use Option 1 for clarity and professionalism. Use Option 3 for quick, casual needs.


Example 2: Code Review

Input Prompt: "Review this code"

Analysis:

  • Clarity: 0/2 (completely unclear what to look for)
  • Specificity: 0/2 (no criteria, no scope)
  • Structure: 0/2 (no framework)
  • Completeness: 0/2 (missing all context)
  • Usability: 0/2 (not reusable)
  • Score: 0/10 - Needs complete rework

Rewrite Option 1 (Conservative):

Review the code provided below. Focus on:
1. Bugs or errors
2. Performance issues
3. Code style and readability
4. Potential security vulnerabilities

Provide specific line references and suggestions for each issue found.

Rewrite Option 2 (Technique-Enhanced):

Act as a senior software engineer conducting a thorough code review. Analyze the provided code following this systematic approach:

**Step 1: Functional Analysis**
Let's check if the code works correctly:
- Verify logic correctness (walk through execution)
- Check edge cases (null inputs, empty arrays, boundary conditions)
- Validate error handling (try-catch blocks, meaningful error messages)

**Step 2: Performance Evaluation**
Analyze computational complexity:
- Time complexity: Big-O notation
- Space complexity: Memory usage
- Identify any O(n2) or worse bottlenecks
- Suggest optimization opportunities

**Step 3: Security Review**
Look for common vulnerabilities:
- SQL injection risks
- XSS vulnerabilities
- Improper input validation
- Sensitive data exposure

**Step 4: Code Quality**
Assess adherence to best practices:
- Naming conventions (descriptive, consistent)
- Comments (helpful, not redundant)
- DRY principle (Don't Repeat Yourself)
- Single Responsibility Principle

**Step 5: Recommendations**
Provide:
- Priority-ranked list of issues (Critical > High > Medium > Low)
- Specific code examples for fixes
- Refactoring suggestions for improvement

Code to review:

Rewrite Option 3 (Simplified):

Look at this code and tell me what's wrong or could be better. Check for bugs, slow parts, security issues, and things that are hard to understand. Give me specific suggestions with examples.

Code:

Recommendation: Option 2 is best for professional code reviews. Option 1 works for quick checks. Use Option 3 for informal feedback or beginners.


Example 3: Email Writing

Input Prompt: "Write an email asking for a meeting"

Analysis:

  • Clarity: 1/2 (clear intent but vague context)
  • Specificity: 0/2 (no purpose, no agenda, no recipient type)
  • Structure: 0/2 (no format)
  • Completeness: 0/2 (missing all details)
  • Usability: 1/2 (somewhat reusable)
  • Score: 2/10 - Needs major improvement

Rewrite Option 1 (Conservative):

Write an email requesting a meeting with [recipient name]. Purpose: Discuss [topic].

Include:
- Brief introduction (context)
- Meeting purpose (why we need to meet)
- Proposed agenda (3-4 bullet points)
- Suggested time options (provide 2-3 alternatives)
- Call to action (confirmation request)

Tone: Professional and respectful
Length: Under 200 words

Rewrite Option 2 (Technique-Enhanced):

Act as an executive assistant drafting a meeting request email to [recipient type, e.g., senior executive/client].

Context: We need to discuss [specific topic] to [desired outcome].

Apply these principles:

**Subject Line Best Practice**
Make it specific and actionable: "Meeting Request: [Topic] - [Urgency/Timeframe]"
Example: "Meeting Request: Q1 Strategy Alignment - This Week"

**Opening Strategy**
First, establish relevance in 1 sentence:
- Reference prior conversation
- Mention shared goal or project
- Acknowledge their value/time

**Value Proposition Frame**
Instead of "I want to meet," use "We'll achieve X by meeting together":
- "In 30 minutes, we can finalize the project timeline"
- "This discussion will unblock the next phase of development"

**Agenda Structure**
Use the SCQA framework:
1. **Situation** (current state)
2. **Complication** (what's blocking us)
3. **Question** (decision needed)
4. **Answer** (your recommendation)

**Time Options Psychology**
Offer specific times with psychological anchors:
- Tuesday 2pm (after lunch, high energy)
- Thursday 10am (start of week, fresh)
- Friday 3pm (end of week, closure mindset)

**Closing**
Make it easy to say yes:
- "If these don't work, suggest your best time"
- "I'll adjust to accommodate your schedule"

Tone: Respectful of their time, clear on value
Length: 150-180 words

Rewrite Option 3 (Simplified):

Write a short email asking for a meeting with [name]. We need to talk about [topic]. Suggest a few times that would work, mention what we'll cover, and ask them to confirm. Keep it friendly and brief.

Recommendation: Option 2 is ideal for important business communications. Option 1 works for routine internal emails. Option 3 is fine for casual requests.


Advanced Techniques

Multiple Rewrites for A/B Testing

When users need to test prompts systematically:

  1. Control: The original prompt
  2. Variation A: Change one variable (e.g., add examples)
  3. Variation B: Change a different variable (e.g., add role)
  4. Variation C: Combine A + B

Suggest testing methodology:

  • Run each prompt 3-5 times with same input
  • Evaluate outputs on criteria (quality, consistency, usefulness)
  • Track which variation performs best

Iterative Improvement

Guide users through multiple rounds:

Round 1: Initial rewrite (address major weaknesses) Round 2: Refine based on feedback (what worked, what didn't) Round 3: Polish (fine-tune for specific use case)

Each round should:

  • Show what changed
  • Explain the reasoning
  • Ask for specific feedback

Context Injection

When prompts lack context, guide users to add it:

Ask these questions:

  1. Who is the audience?
  2. What is the goal/purpose?
  3. What constraints exist (length, tone, format)?
  4. What background is assumed?
  5. What should the output look like?

Then incorporate answers into the rewrite.


When to Use This Skill

Trigger when users say:

  • "Rewrite this prompt"
  • "Make this prompt better"
  • "Improve my prompt"
  • "Why isn't this prompt working?"
  • "Help me write a better prompt for..."
  • "Generate variations of this prompt"
  • "A/B test this prompt"

Resources

scripts/

No scripts required for this skill - all analysis and rewriting is done by Claude directly.

references/

No references required - prompt engineering techniques are documented inline.

assets/

No assets required - this skill generates text output only.

相关推荐