prompt-optimization

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Prompt Optimization

Prompt优化

Skill for analyzing and improving existing prompts.
用于分析和优化现有Prompt的技能。

Optimization Workflow

优化工作流

1. ANALYZE current prompt
   ↓
2. IDENTIFY issues
   ↓
3. APPLY corrections
   ↓
4. VALIDATE improvement
   ↓
5. DOCUMENT changes
1. 分析当前Prompt
   ↓
2. 识别问题
   ↓
3. 应用修正方案
   ↓
4. 验证优化效果
   ↓
5. 记录变更内容

Analysis Checklist

分析检查清单

Clarity

清晰度

  • Unambiguous instructions?
  • Clearly defined objective?
  • Precise vocabulary?
  • 指令是否明确无歧义?
  • 是否明确定义目标?
  • 词汇是否精准?

Structure

结构

  • Well-delimited sections?
  • Logical order?
  • Clear hierarchy?
  • 各部分是否划分清晰?
  • 逻辑顺序是否合理?
  • 层级是否清晰?

Completeness

完整性

  • Output format defined?
  • Error cases handled?
  • Examples if needed?
  • 是否定义输出格式?
  • 是否处理错误场景?
  • 是否按需提供示例?

Guardrails

护栏机制

  • Explicit limits?
  • Forbidden behaviors listed?
  • Appropriate security?
  • 是否明确限制条件?
  • 是否列出禁止行为?
  • 安全性是否达标?

Common Problems and Solutions

常见问题与解决方案

1. Vague Instructions

1. 指令模糊

Before:
Write a good summary.
After:
Write a 100-150 word summary that:
1. Captures the main idea in the first sentence
2. Includes 2-3 supporting key points
3. Uses accessible language (high school level)
4. Avoids technical jargon
优化前:
写一篇好的摘要。
优化后:
撰写一篇100-150词的摘要,需满足:
1. 首句点明核心主旨
2. 包含2-3个支撑性要点
3. 使用通俗易懂的语言(高中水平)
4. 避免专业术语

2. Lack of Context

2. 缺乏上下文

Before:
Analyze this code.
After:
Analyze this Python code focusing on:
- Performance (algorithmic complexity)
- Readability (PEP 8 conventions)
- Security (OWASP vulnerabilities)

Context: Code for production REST API, 10k requests/day.
优化前:
分析这段代码。
优化后:
分析以下Python代码,重点关注:
- 性能(算法复杂度)
- 可读性(符合PEP 8规范)
- 安全性(OWASP漏洞)

上下文:用于生产环境的REST API代码,日均请求量1万次。

3. Undefined Format

3. 未定义输出格式

Before:
Give me recommendations.
After:
Provide 3-5 recommendations in this format:
优化前:
给我一些建议。
优化后:
提供3-5条建议,格式如下:

Recommendation [N]: [Short title]

建议[N]:[简短标题]

Impact: [High/Medium/Low] Effort: [High/Medium/Low] Action: [1-2 sentence description]
undefined
影响程度: [高/中/低] 实施难度: [高/中/低] 行动方案: [1-2句话说明]
undefined

4. No Error Handling

4. 无错误处理机制

Before:
Translate this text to French.
After:
Translate this text to French.

IF the text is already in French:
  → Indicate "The text is already in French" and suggest style improvements.

IF the text contains technical jargon:
  → Keep technical terms in English with translation in parentheses.

IF the text is too long (>1000 words):
  → Ask for confirmation before proceeding.
优化前:
把这段文本翻译成法语。
优化后:
把这段文本翻译成法语。

如果文本已是法语:
  → 提示“该文本已是法语”,并提供风格优化建议。

如果文本包含专业术语:
  → 保留英文专业术语,在括号中附上法语翻译。

如果文本过长(超过1000词):
  → 先请求确认再继续翻译。

5. Insufficient Emphasis

5. 强调力度不足

Before:
Don't make up information.
After:
CRITICAL - ZERO TOLERANCE: NEVER make up information.
IF uncertain → Explicitly say "I'm not sure about..."
IF no data → Say "I don't have this information"
优化前:
不要编造信息。
优化后:
【关键要求 - 零容忍】:绝对禁止编造信息。
若不确定 → 明确说明“我不确定关于……的内容”
若无相关数据 → 说明“我没有这方面的信息”

Improvement Techniques

优化技巧

Add Chain-of-Thought

添加思维链(Chain-of-Thought)

markdown
undefined
markdown
undefined

Addition

补充内容

Before answering, think step by step:
  1. What exactly is being asked?
  2. What information do I have?
  3. What is the best approach?
  4. Are there pitfalls to avoid?
undefined
作答前,请按以下步骤思考:
  1. 明确问题核心需求是什么?
  2. 我掌握哪些相关信息?
  3. 最佳解决思路是什么?
  4. 有哪些需要规避的陷阱?
undefined

Add Examples

添加示例

markdown
undefined
markdown
undefined

Addition

补充内容

Examples

示例

Good example

正面示例

Input: [...] Output: [Expected output]
输入: [...] 输出: [预期输出]

Bad example (to avoid)

反面示例(需避免)

Input: [...] Incorrect output: [What we don't want] Why incorrect: [Explanation]
undefined
输入: [...] 错误输出: [不符合要求的输出] 错误原因: [解释说明]
undefined

Strengthen Guardrails

强化护栏机制

markdown
undefined
markdown
undefined

Addition

补充内容

Forbidden (STRICT)

禁止行为(严格执行)

  • [Forbidden behavior 1]
  • [Forbidden behavior 2]
  • [禁止行为1]
  • [禁止行为2]

Required (ALWAYS)

强制要求(必须遵守)

  • [Required behavior 1]
  • [Required behavior 2]
undefined
  • [强制要求1]
  • [强制要求2]
undefined

Optimization Report Format

优化报告格式

markdown
undefined
markdown
undefined

Optimization of [Prompt Name]

[Prompt名称]优化报告

Before/After Score

优化前后评分

CriterionBeforeAfter
ClarityX/10Y/10
StructureX/10Y/10
CompletenessX/10Y/10
GuardrailsX/10Y/10
TotalX/40Y/40
评估维度优化前优化后
清晰度X/10Y/10
结构X/10Y/10
完整性X/10Y/10
护栏机制X/10Y/10
总分X/40Y/40

Identified Issues

识别出的问题

  1. [Issue 1]
  2. [Issue 2]
  1. [问题1]
  2. [问题2]

Applied Changes

实施的变更

BeforeAfterReason
[...][...][...]
优化前优化后变更原因
[...][...][...]

Optimized Prompt

优化后的Prompt


[THE COMPLETE PROMPT]


[完整Prompt内容]

Recommended Tests

推荐测试项

  • Standard case test
  • Edge case test 1
  • Edge case test 2
undefined
  • 标准场景测试
  • 边缘场景测试1
  • 边缘场景测试2
undefined

Forbidden

禁止事项

  • Never change the original meaning of the prompt
  • Never add unrequested features
  • Never remove existing guardrails
  • Never make the prompt longer without justification
  • 不得改变Prompt的原始含义
  • 不得添加未被要求的功能
  • 不得移除现有护栏机制
  • 不得无正当理由延长Prompt长度