prompt-improver

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Prompt Improver

Prompt 优化器

Overview

概述

A skill that analyzes and improves prompts based on general LLM/agent best practices. It focuses on verifiability, clear scope, explicit constraints, and context economy so the agent can execute with minimal back-and-forth.
If you are running in Claude Code, also read
references/claude.md
and apply the additional Claude-specific techniques. If you are running in Codex CLI, also read
references/codex.md
and apply the additional Codex-specific techniques.
When the input is a document that instructs an agent (e.g., plan files, AGENTS.md, system instruction docs), treat the document as the improvement target; identify issues and propose concrete improvements, and include a revised draft when helpful.
一款基于通用LLM/Agent最佳实践来分析和优化提示词的Skill。它聚焦于可验证性、明确范围、显式约束以及上下文精简,让Agent能够以最少的交互次数完成任务。
如果您在Claude Code环境中运行,请同时阅读
references/claude.md
并应用针对Claude的额外优化技巧。 如果您在Codex CLI环境中运行,请同时阅读
references/codex.md
并应用针对Codex的额外优化技巧。
当输入内容是指导Agent的文档时(例如计划文件、AGENTS.md、系统指令文档),请将该文档作为优化目标;识别其中的问题并提出具体改进方案,必要时可提供修订后的草稿。

Workflow

工作流程

Step 0: Classify Task and Complexity

步骤0:任务分类与复杂度评估

Classify the task and decide whether an explicit exploration/planning phase should be recommended:
  • Task type: bugfix, feature, refactor, research, UI/visual, docs, ops
  • Complexity: single-file/small change vs multi-file/uncertain impact
  • Risk: data safety, security, compatibility, performance
  • Input type: prompt vs agent-instruction document (plan files, AGENTS.md, system instruction docs)
If the task is complex or ambiguous, the improved prompt should explicitly request an exploration/planning phase before implementation.
对任务进行分类,并决定是否建议开启显式的探索/规划阶段:
  • 任务类型:bug修复、功能开发、重构、研究、UI/视觉设计、文档编写、运维
  • 复杂度:单文件/小型变更 vs 多文件/影响不确定的变更
  • 风险:数据安全、安全性、兼容性、性能
  • 输入类型:提示词 vs Agent指令文档(计划文件、AGENTS.md、系统指令文档)
如果任务复杂或模糊,优化后的提示词应明确要求在实施前先进行探索/规划阶段。

Step 1: Analyze the Prompt

步骤1:分析提示词

Analyze the user-provided prompt from the following perspectives:
  1. Verifiability: Does it include means for Claude to verify its own work?
  2. Specificity: Are files, scenarios, and constraints clearly specified?
  3. Context: Is necessary background information provided?
  4. Scope: Is the task scope appropriately defined?
  5. Expected Outcome: Are success criteria clear?
  6. Constraints: Are language/runtime versions, dependencies, security, or compatibility requirements specified?
  7. Context Economy: Is the prompt concise and focused, without unnecessary information?
  8. Execution Preference: Is it clear whether the model should implement, propose, or just analyze?
从以下角度分析用户提供的提示词:
  1. 可验证性:是否包含让Claude验证自身工作成果的方法?
  2. 明确性:文件、场景和约束是否有清晰的说明?
  3. 上下文:是否提供了必要的背景信息?
  4. 范围:任务范围是否定义得当?
  5. 预期结果:成功标准是否明确?
  6. 约束条件:是否指定了语言/运行时版本、依赖项、安全或兼容性要求?
  7. 上下文精简:提示词是否简洁聚焦,没有冗余信息?
  8. 执行偏好:是否明确模型应该执行实现、提出方案还是仅进行分析?

Step 2: Identify Issues

步骤2:识别问题

Check for the following anti-patterns:
Anti-patternDescription
Vague instructionsLacks specificity like "make it better" or "improve it"
No verification methodMissing tests, screenshots, or expected output
No verification commandsMissing how to run tests or check outputs
Overly broad scopeAsking for too many things at once
Insufficient contextMissing file paths, error messages, or references to existing patterns
Symptom-only descriptionNot requesting investigation of root cause
Missing constraintsNo environment, dependency, or compatibility requirements
No exploration/planning cueComplex tasks not asking for exploration/planning first
Context bloatUnnecessary details that increase token usage
Ambiguous deliverableUnclear whether to plan, implement, or only analyze
Unclear response formatMissing brevity/structure expectations
检查是否存在以下反模式:
反模式描述
模糊指令缺乏具体性,例如“让它更好”或“优化它”
无验证方法缺少测试用例、截图或预期输出
无验证命令缺少如何运行测试或检查输出的说明
范围过于宽泛一次要求完成过多任务
上下文不足缺少文件路径、错误信息或对现有模式的引用
仅描述症状未要求调查根本原因
缺少约束条件未指定环境、依赖项或兼容性要求
无探索/规划提示复杂任务未要求先进行探索/规划
上下文冗余包含不必要的细节,增加Token使用量
交付物模糊不清楚是要规划、实现还是仅进行分析
响应格式不明确缺少对简洁性/结构的预期

Step 3: Create Improved Prompt

步骤3:生成优化后的提示词

Apply best practices to create an improved version:
应用最佳实践生成优化版本:

Add Verifiability

添加可验证性

Before: "implement a function that validates email addresses"
After: "write a validateEmail function. test cases: user@example.com is true, invalid is false, user@.com is false. run the tests after implementing"
Before: "implement a function that validates email addresses"
After: "write a validateEmail function. test cases: user@example.com is true, invalid is false, user@.com is false. run the tests after implementing"

Add Specific Context

添加具体上下文

Before: "fix the login bug"
After: "users report that login fails after session timeout. check the auth flow in src/auth/, especially token refresh. write a failing test that reproduces the issue, then fix it"
Before: "fix the login bug"
After: "users report that login fails after session timeout. check the auth flow in src/auth/, especially token refresh. write a failing test that reproduces the issue, then fix it"

Add Reference to Existing Patterns

添加对现有模式的引用

Before: "add a calendar widget"
After: "look at how existing widgets are implemented on the home page to understand the patterns. HotDogWidget.php is a good example. follow the pattern to implement a new calendar widget with month selection and pagination"
Before: "add a calendar widget"
After: "look at how existing widgets are implemented on the home page to understand the patterns. HotDogWidget.php is a good example. follow the pattern to implement a new calendar widget with month selection and pagination"

Add Context Economy

实现上下文精简

Before: "here is a long unrelated history ... fix the dropdown"
After: "fix the dropdown in src/ui/Dropdown.tsx. issue: keyboard navigation skips items. keep the prompt focused; omit unrelated history"
Before: "here is a long unrelated history ... fix the dropdown"
After: "fix the dropdown in src/ui/Dropdown.tsx. issue: keyboard navigation skips items. keep the prompt focused; omit unrelated history"

Add Rich Context Inputs

添加丰富上下文输入

Before: "build fails"
After: "build fails with this error: [paste error]. run the smallest relevant test command. if needed, read the build script and package config"
Before: "build fails"
After: "build fails with this error: [paste error]. run the smallest relevant test command. if needed, read the build script and package config"

Add Explicit Exploration/Planning When Needed

必要时添加显式探索/规划要求

Before: "refactor auth to support OAuth"
After: "first explore src/auth and summarize current flow, then propose a plan. after approval, implement with tests"
When information is missing, include explicit questions inside the improved prompt and do not assume defaults.
Before: "refactor auth to support OAuth"
After: "first explore src/auth and summarize current flow, then propose a plan. after approval, implement with tests"
当信息缺失时,在优化后的提示词中加入明确的问题,不要假设默认值。

Example: Bugfix

示例:Bug修复

Before: "search is broken"
After: "users report search returns empty results for queries with hyphens. reproduce in src/search/. paste the error log if any. write a failing test for 'foo-bar' returning results, fix the root cause, run: pnpm test --filter search"
Before: "search is broken"
After: "users report search returns empty results for queries with hyphens. reproduce in src/search/. paste the error log if any. write a failing test for 'foo-bar' returning results, fix the root cause, run: pnpm test --filter search"

Example: UI/Visual

示例:UI/视觉设计

Before: "make the dashboard look better"
After: "implement the attached screenshot for the dashboard header in src/ui/DashboardHeader.tsx. match spacing and typography. take a new screenshot and list any differences. run: pnpm lint"
Before: "make the dashboard look better"
After: "implement the attached screenshot for the dashboard header in src/ui/DashboardHeader.tsx. match spacing and typography. take a new screenshot and list any differences. run: pnpm lint"

Example: Refactor

示例:重构

Before: "clean up the auth code"
After: "inspect src/auth and list duplication hotspots. propose a refactor plan scoped to one module. after approval, remove duplication without changing behavior. add a targeted test if coverage is missing. run the smallest relevant test command"
Before: "clean up the auth code"
After: "inspect src/auth and list duplication hotspots. propose a refactor plan scoped to one module. after approval, remove duplication without changing behavior. add a targeted test if coverage is missing. run the smallest relevant test command"

Example: Research

示例:研究

Before: "why is this API slow?"
After: "explore request flow around src/api/. summarize likely bottlenecks with evidence (logs, timings). propose 2-3 hypotheses and what data is needed to confirm. do not implement yet. if needed, ask for access to profiling output"
Before: "why is this API slow?"
After: "explore request flow around src/api/. summarize likely bottlenecks with evidence (logs, timings). propose 2-3 hypotheses and what data is needed to confirm. do not implement yet. if needed, ask for access to profiling output"

Example: Ops

示例:运维

Before: "deployment failed"
After: "deploy fails with error: [paste log]. identify the failing step in scripts/deploy.sh and related CI config. suggest a fix and a rollback plan. run: ./scripts/deploy.sh --dry-run (if available)"
Before: "deployment failed"
After: "deploy fails with error: [paste log]. identify the failing step in scripts/deploy.sh and related CI config. suggest a fix and a rollback plan. run: ./scripts/deploy.sh --dry-run (if available)"

Example: Docs

示例:文档

Before: "update the README"
After: "update README.md to include install + dev steps based on existing scripts. keep it concise. confirm commands exist and match actual scripts"
Before: "update the README"
After: "update README.md to include install + dev steps based on existing scripts. keep it concise. confirm commands exist and match actual scripts"

Step 4: Output Format

步骤4:输出格式

Output in the following format:
markdown
undefined
按以下格式输出:
markdown
undefined

Prompt Analysis

Prompt Analysis

Original Prompt

Original Prompt

[User-provided prompt]
[User-provided prompt]

Issues

Issues

  • [Issue 1 and its impact]
  • [Issue 2 and its impact] ...
  • [Issue 1 and its impact]
  • [Issue 2 and its impact] ...

Missing Information (Questions to Ask)

Missing Information (Questions to Ask)

The following questions should be answered to make the prompt more effective:
  • [Question 1] (Why it is needed)
  • [Question 2] (Why it is needed) ...
The following questions should be answered to make the prompt more effective:
  • [Question 1] (Why it is needed)
  • [Question 2] (Why it is needed) ...

Verification Plan

Verification Plan

  • Commands to run (tests, build, lint, screenshots)
  • Expected results or acceptance criteria
  • Commands to run (tests, build, lint, screenshots)
  • Expected results or acceptance criteria

Exploration/Planning Recommendation

Exploration/Planning Recommendation

  • Recommend exploration/planning first? [Yes/No] and why
  • Recommend exploration/planning first? [Yes/No] and why

Execution Preference

Execution Preference

  • Implement now / propose plan only / analyze only
  • Any constraints on response length or format
  • Implement now / propose plan only / analyze only
  • Any constraints on response length or format

Improved Prompt

Improved Prompt

[The improved prompt]
[The improved prompt]

Document Improvement Suggestions (if applicable)

Document Improvement Suggestions (if applicable)

  • [Issue and concrete improvement for the instruction document]
  • [Issue and concrete improvement for the instruction document]
  • [Issue and concrete improvement for the instruction document]
  • [Issue and concrete improvement for the instruction document]

Revised Document (optional)

Revised Document (optional)

[A revised draft of the instruction document when helpful]
[A revised draft of the instruction document when helpful]

Improved Prompt Template (optional)

Improved Prompt Template (optional)

Use this as a fill-in template if the user wants a reusable prompt format:
[Task]
- Goal:
- Target files/paths (@...):
- Constraints (runtime/version/deps/security/compat):
- Context (symptom, logs, repro, links):

[Verification]
- Commands:
- Expected results:
- UI checks (screenshots/visual diffs):

[Exploration/Planning]
- Do exploration/planning first? (Yes/No) + reason:

[Execution Preference]
- Implement now / plan only / analyze only
- Output format (concise report, patch summary, checklist, etc.)
Use this as a fill-in template if the user wants a reusable prompt format:
[Task]
- Goal:
- Target files/paths (@...):
- Constraints (runtime/version/deps/security/compat):
- Context (symptom, logs, repro, links):

[Verification]
- Commands:
- Expected results:
- UI checks (screenshots/visual diffs):

[Exploration/Planning]
- Do exploration/planning first? (Yes/No) + reason:

[Execution Preference]
- Implement now / plan only / analyze only
- Output format (concise report, patch summary, checklist, etc.)

Short Prompt Template (optional)

Short Prompt Template (optional)

Use this when the user wants the shortest effective prompt:
Goal: ...
Targets: path1/path2
Context: symptom + repro + logs
Constraints: runtime/deps/compat
Verify: command + expected result
Explore/Plan: yes/no (why)
Execute: implement / plan only / analyze only
Output: concise format
Use this when the user wants the shortest effective prompt:
Goal: ...
Targets: path1/path2
Context: symptom + repro + logs
Constraints: runtime/deps/compat
Verify: command + expected result
Explore/Plan: yes/no (why)
Execute: implement / plan only / analyze only
Output: concise format

Improvement Points

Improvement Points

  1. [Explanation of improvement 1]
  2. [Explanation of improvement 2] ...
  1. [Explanation of improvement 1]
  2. [Explanation of improvement 2] ...

Additional Recommendations (optional)

Additional Recommendations (optional)

  • [Whether to do exploration/planning first]
  • [Whether to parallelize or delegate investigation]
  • [Whether preliminary research is needed]
  • [Ways to reduce context usage]
undefined
  • [Whether to do exploration/planning first]
  • [Whether to parallelize or delegate investigation]
  • [Whether preliminary research is needed]
  • [Ways to reduce context usage]
undefined

Reference: Best Practices Checklist

参考:最佳实践清单

Best practices to reference when improving prompts:
优化提示词时可参考的最佳实践:

Provide Verification Methods

提供验证方法

  • Include test cases
  • Specify expected output
  • For UI changes, request screenshot comparison
  • Add "run the tests" or "verify the build succeeds"
  • Include explicit commands to run
  • 包含测试用例
  • 指定预期输出
  • 对于UI变更,要求截图对比
  • 添加“运行测试”或“验证构建成功”的要求
  • 包含明确的运行命令

Explore → Plan → Implement Order

遵循“探索→规划→实现”的顺序

  • Use an exploration/planning phase first for complex tasks
  • Create a plan before implementation
  • Small fixes don't need a formal plan
  • When uncertain, ask clarifying questions before coding
  • 复杂任务先进行探索/规划阶段
  • 实现前先制定计划
  • 小型修复无需正式计划
  • 不确定时,先询问澄清问题再编码

Include Specific Context

包含具体上下文

  • Paste error messages
  • Specify existing patterns
  • Clarify edge cases
  • State environment constraints (runtime, language versions, dependencies)
  • 粘贴错误信息
  • 指定现有模式
  • 明确边缘情况
  • 说明环境约束(运行时、语言版本、依赖项)

Use Rich Inputs

使用丰富输入

  • Paste logs and stack traces
  • Provide URLs for docs or API references
  • Attach or paste large text outputs when needed
  • 粘贴日志和堆栈跟踪
  • 提供文档或API参考的URL
  • 必要时附加或粘贴大文本输出

Manage Context Window

管理上下文窗口

  • Keep prompts concise and focused
  • Remove unrelated history or speculation
  • Ask for missing info instead of guessing
  • 保持提示词简洁聚焦
  • 删除无关历史或推测内容
  • 询问缺失信息而非猜测

Leverage Parallelism/Delegation

利用并行处理/委托

  • For research tasks: request parallel investigation or summaries
  • For code review: request an independent review pass
  • Keeps the main task focused
  • 对于研究任务:要求并行调查或总结
  • 对于代码审查:要求独立审查环节
  • 保持主任务聚焦

Patterns to Avoid

需避免的模式

  • Vague instructions like "make it better" or "improve it"
  • Implementation requests without verification methods
  • Multiple unrelated tasks at once
  • Requesting changes to files not yet read
  • Large context dumps with no clear signal
  • 模糊指令,如“让它更好”或“优化它”
  • 无验证方法的实现请求
  • 同时要求完成多个无关任务
  • 请求修改尚未读取的文件
  • 包含无明确信号的大段上下文内容