octocode-prompt-optimizer
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePrompt Optimizer Skill
Prompt Optimizer Skill
<what>
Analyzes and improves prompts, documentation, and agent instructions using prompt engineering best practices.
</what>
<when_to_use>
- Creating or improving prompts
- Agents skip steps or ignore instructions
- Instructions lack enforcement
- Output format is inconsistent
- Reviewing any instruction document or prompt </when_to_use>
<global_forbidden priority="maximum">
CRITICAL - FORBIDDEN at ALL times:
- Changing good parts that already work
- Changing the existing logic/intent of prompts
- Making changes before understanding the prompt
- Leaving weak words in critical sections
- Outputting without validation
- Over-strengthening soft guidance
- Skipping gates or checkboxes
- Bloating prompts - fixes MUST NOT increase line count >10% unless adding required gates
Triple Lock:
- STATE: You MUST preserve working logic AND follow all gates in order
- FORBID: FORBIDDEN: Altering intent without user approval
- FORBID: FORBIDDEN: Skipping steps or gates
- REQUIRE: REQUIRED: Validate all changes before output AND complete all checkboxes
Violation invalidates optimization. Start over if violated.
</global_forbidden>
<tool_control priority="high">
FORBIDDEN tools during optimization:
- Shell commands that modify files directly
- Any tool that executes code
- Tools that skip the READ→UNDERSTAND→RATE→FIX→VALIDATE flow
ALLOWED tools:
- Read (to read prompt files)
- StrReplace/Write (ONLY after VALIDATE step passes)
- AskQuestion (for clarification)
- Text output (all phases) </tool_control>
<what>
运用提示工程最佳实践,分析并优化Prompt、文档及Agent指令。
</what>
<when_to_use>
- 创建或优化Prompt时
- Agent跳过步骤或忽略指令时
- 指令缺乏强制约束力时
- 输出格式不一致时
- 审核任何指令文档或Prompt时 </when_to_use>
<global_forbidden priority="maximum">
CRITICAL - 任何时候均禁止:
- 修改已正常工作的内容
- 更改Prompt的现有逻辑/意图
- 在理解Prompt前进行修改
- 在关键部分保留模糊表述的弱词
- 未验证就输出结果
- 过度强化软性引导内容
- 跳过检查门(Gate)或复选框
- 冗余扩充Prompt - 除非添加必要的检查门,否则修复后的行数增幅不得超过10%
三重锁定规则:
- STATE: 必须保留现有可正常运行的逻辑,并按顺序遵循所有检查门要求
- FORBID: 禁止:未经用户批准更改意图
- FORBID: 禁止:跳过步骤或检查门
- REQUIRE: 要求:输出前必须验证所有更改,并完成所有复选框检查
违反上述规则将导致优化失效,若违反需重新开始。
</global_forbidden>
<tool_control priority="high">
优化期间禁止使用的工具:
- 直接修改文件的Shell命令
- 任何可执行代码的工具
- 跳过READ→UNDERSTAND→RATE→FIX→VALIDATE流程的工具
允许使用的工具:
- Read(用于读取Prompt文件)
- StrReplace/Write(仅在VALIDATE步骤通过后使用)
- AskQuestion(用于澄清疑问)
- 文本输出(所有阶段均可使用) </tool_control>
Execution Flow
执行流程
<execution_flow>
READ → UNDERSTAND → RATE → FIX → VALIDATE → OUTPUT
↓ ↓ ↓ ↓ ↓ ↓
GATE GATE GATE GATE GATE GATE| Step | Action | Gate Requirement | FORBIDDEN Until Gate Passes |
|---|---|---|---|
| 1 | READ the prompt completely | All checkboxes checked | Analysis, changes |
| 2 | UNDERSTAND what the prompt does | Understanding output produced | Rating, fixes |
| 3 | RATE each part for issues | Issues table produced | Fixing issues |
| 4 | FIX issues by severity | All Critical/High fixed | Validation |
| 5 | VALIDATE against checklist | All REQUIRED checks pass | Output |
| 6 | OUTPUT optimized document | Format followed exactly | N/A |
CRITICAL: You MUST complete each gate before proceeding. DO NOT skip steps.
</execution_flow>
<execution_flow>
READ → UNDERSTAND → RATE → FIX → VALIDATE → OUTPUT
↓ ↓ ↓ ↓ ↓ ↓
GATE GATE GATE GATE GATE GATE| 步骤 | 操作 | 检查门要求 | 未通过检查门前禁止操作 |
|---|---|---|---|
| 1 | READ 完整读取Prompt | 所有复选框已勾选 | 分析、修改 |
| 2 | UNDERSTAND 明确Prompt的作用 | 生成理解输出内容 | 评级、修复 |
| 3 | RATE 对各部分进行问题评级 | 生成问题表格 | 修复问题 |
| 4 | FIX 按严重程度修复问题 | 所有关键/高优先级问题已修复 | 验证 |
| 5 | VALIDATE 根据检查清单验证 | 所有必填检查项已通过 | 输出 |
| 6 | OUTPUT 输出优化后的文档 | 严格遵循格式要求 | 无 |
CRITICAL: 必须完成每个检查门后才能进入下一步,禁止跳过步骤。
</execution_flow>
Step 1: READ
步骤1:READ
<read_gate>
STOP. DO NOT proceed to analysis.
<read_gate>
STOP. 禁止进入分析环节。
Pre-Conditions
前置条件
- User provided prompt/file to optimize
- Path is valid and readable
- 用户已提供待优化的Prompt/文件
- 路径有效且可读取
Actions (REQUIRED)
必须执行的操作
- MUST read the input file completely
- MUST note the document type and purpose
- MUST count approximate line count
- 必须完整读取输入文件
- 必须记录文档类型和用途
- 必须统计大致行数
Gate Check
检查门验证
Verify before proceeding:
- File read completely (no skipped sections)
- Document type identified
- Line count noted
进入下一步前需确认:
- 文件已完整读取(无跳过章节)
- 已识别文档类型
- 已记录行数
FORBIDDEN
禁止操作
- Making ANY changes before reading
- Skipping sections
- Proceeding without completing all checkboxes
- 读取前进行任何修改
- 跳过文件章节
- 未完成所有复选框就进入下一步
ALLOWED
允许操作
- Read tool only
- Text output to confirm reading
- 仅使用Read工具
- 输出文本确认已完成读取
On Failure
失败处理
- IF file unreadable → THEN ask user for correct path
- IF file empty → THEN ask user to provide content </read_gate>
- 若 文件无法读取 → 则 向用户询问正确路径
- 若 文件为空 → 则 请用户提供内容 </read_gate>
Step 2: UNDERSTAND
步骤2:UNDERSTAND
<understand_gate>
STOP. DO NOT proceed to rating. Understand what this prompt does first.
<understand_gate>
STOP. 禁止进入评级环节,先明确该Prompt的作用。
Pre-Conditions
前置条件
- Step 1 (READ) completed
- File content in context
- 步骤1(READ)已完成
- 已获取文件上下文内容
Actions (REQUIRED)
必须执行的操作
- MUST identify the goal - what is this prompt supposed to achieve?
- MUST identify logical parts - break down into sections/phases/steps
- MUST identify flow - how do the parts connect?
- MUST document understanding in output format below
- 必须明确目标 - 该Prompt要实现什么效果?
- 必须识别逻辑模块 - 将内容拆分为章节/阶段/步骤
- 必须梳理流程 - 各模块如何关联?
- 必须按以下输出格式记录理解内容
Output Format (REQUIRED)
要求的输出格式
markdown
undefinedmarkdown
undefinedUnderstanding
理解总结
Goal: [What the prompt achieves]
Logical Parts:
- [Part name] - [purpose]
- [Part name] - [purpose] ...
Flow: [How parts connect]
undefined目标: [Prompt要实现的效果]
逻辑模块:
- [模块名称] - [用途]
- [模块名称] - [用途] ...
流程: [各模块的关联方式]
undefinedAssumptions & Unknowns (REQUIRED if prompt is underspecified)
假设与未知项(若Prompt描述不明确则必填)
markdown
undefinedmarkdown
undefinedAssumptions & Unknowns
假设与未知项
Assumptions (temporary - proceeding with these):
- [Assumption 1] - Impact if wrong: [consequence]
Unknowns (MUST ask before proceeding):
- [Unknown 1] - Why critical: [reason]
Clarification needed: Yes/No
**IF** Unknowns exist → **THEN** STOP and ask user before proceeding to RATE.假设内容(临时,基于此推进):
- [假设1] - 若假设错误的影响:[后果]
未知项(必须先询问用户才能推进):
- [未知项1] - 为何关键:[原因]
是否需要澄清: 是/否
**若** 存在未知项 → **则** 停止操作并询问用户,之后再进入RATE环节。Gate Check
检查门验证
Verify before proceeding:
- Goal clearly stated
- All logical parts identified
- Flow documented
- Understanding output produced
进入下一步前需确认:
- 已明确表述目标
- 已识别所有逻辑模块
- 已梳理并记录流程
- 已生成理解输出内容
Reflection
反思
- Did I understand the intent correctly?
- Did I identify all logical parts? IF you are uncertain about your understanding → THEN re-read before proceeding. DO NOT guess.
- 我是否正确理解了Prompt的意图?
- 我是否识别了所有逻辑模块? 若 对理解内容不确定 → 则 重新读取文件后再推进,禁止猜测。
FORBIDDEN
禁止操作
- Proceeding without understanding the goal
- Making changes based on assumptions
- Skipping output format
- 未明确目标就推进
- 基于假设进行修改
- 跳过输出格式要求
ALLOWED
允许操作
- Text output (understanding summary)
- Re-reading file if needed
- 文本输出(理解总结)
- 必要时重新读取文件
On Failure
失败处理
- IF intent unclear → THEN ask user for clarification
- IF multiple interpretations → THEN present options and WAIT for user choice </understand_gate>
- 若 意图不明确 → 则 向用户请求澄清
- 若 存在多种解读 → 则 列出选项并等待用户选择 </understand_gate>
Step 3: RATE
步骤3:RATE
<rate_gate>
STOP. DO NOT fix anything yet. Rate each logical part for issues first.
<rate_gate>
STOP. 先不要修复问题,先对每个逻辑模块进行问题评级。
Pre-Conditions
前置条件
- Step 2 (UNDERSTAND) completed
- Understanding output produced
- 步骤2(UNDERSTAND)已完成
- 已生成理解输出内容
Issue Categories (MUST check all)
问题分类(必须全部检查)
| Category | What to Look For | Severity |
|---|---|---|
| Weak Words | "consider", "might", "could", "may", "should" in critical sections | Critical |
| Missing Enforcement | Rules without FORBIDDEN/ALLOWED | High |
| Ambiguous Instructions | "do some", "handle", "process" without specifics | High |
| Referential Ambiguity | "it", "this", "that", "above", "below" without clear antecedent | High |
| Missing Output Format | Expected outputs without templates | Medium |
| Missing Gates | Phase transitions without checkpoints | Medium |
| Duplication | Same logic/rule repeated in multiple places (not just examples) | Medium |
| Verbose/Bloat | Sections >20 lines that could be tables; prose without constraints | Medium |
| Emoji as Instructions | Emojis used as commands instead of strong words | Medium |
| Redundancy | Same example repeated, unnecessary variations | Low |
| Low Density | Explanations that don't constrain behavior | Low |
| 分类 | 检查要点 | 严重程度 |
|---|---|---|
| 弱词 | 关键部分出现"consider"、"might"、"could"、"may"、"should" | 关键 |
| 缺乏强制约束 | 规则中未明确FORBIDDEN/ALLOWED | 高 |
| 指令模糊 | 出现"do some"、"handle"、"process"等无具体说明的表述 | 高 |
| 指代模糊 | 出现"it"、"this"、"that"、"above"、"below"等无明确指代对象的表述 | 高 |
| 缺少输出格式 | 预期输出未提供模板 | 中 |
| 缺少检查门 | 阶段转换无检查点 | 中 |
| 重复内容 | 同一逻辑/规则在多处重复(示例除外) | 中 |
| 冗余冗长 | 超过20行的章节可转换为表格;无约束的散文式内容 | 中 |
| 用表情符号当指令 | 使用表情符号代替明确指令 | 中 |
| 冗余内容 | 重复示例、不必要的变体 | 低 |
| 信息密度低 | 未约束行为的解释性内容 | 低 |
Rating Output (REQUIRED)
要求的评级输出
markdown
undefinedmarkdown
undefinedIssues Found
发现的问题
| Part | Issue | Severity | Fix Needed |
|---|---|---|---|
| [Part name] | [Description] | Critical/High/Medium/Low | [What to do] |
undefined| 模块 | 问题描述 | 严重程度 | 修复方向 |
|---|---|---|---|
| [模块名称] | [具体描述] | 关键/高/中/低 | 修复方式 |
undefinedGate Check
检查门验证
Verify before proceeding:
- All logical parts rated
- Weak word scan completed
- Issues table produced
- Severity assigned to each issue
进入下一步前需确认:
- 所有逻辑模块已完成评级
- 已完成弱词扫描
- 已生成问题表格
- 每个问题已分配严重程度
FORBIDDEN
禁止操作
- Fixing issues before completing rating
- Ignoring critical issues
- Skipping weak word scan
- Proceeding without issues table
- 完成评级前修复问题
- 忽略关键问题
- 跳过弱词扫描
- 未生成问题表格就推进
ALLOWED
允许操作
- Text output (issues table)
- Re-reading parts for rating
- 文本输出(问题表格)
- 为评级重新读取模块内容
On Failure
失败处理
- IF no issues found → THEN MUST double-check with weak word scan
- IF scan still clean → THEN document "No issues found" and proceed </rate_gate>
- 若 未发现问题 → 则 必须重新进行弱词扫描确认
- 若 扫描后仍无问题 → 则 记录"未发现问题"并进入下一步 </rate_gate>
Weak Word Reference
弱词参考表
| Weak Word | Context | Replacement |
|---|---|---|
| consider, might, could, may | Critical section | MUST, REQUIRED |
| consider, might, could, may | Optional guidance | Remove or keep with "optionally" |
| should, prefer | Critical section | MUST |
| should, prefer | Soft guidance | Keep as-is |
| do some, handle, process | Any | Specify exact action: "Run X", "Call Y" |
| as needed, if necessary | Any | IF [condition] → THEN [action] |
| feel free to, you can | Required action | Remove entirely, use MUST |
| feel free to, you can | Optional action | "Optionally, you may..." |
CRITICAL: Weak words in FORBIDDEN/MUST/NEVER sections MUST be replaced.
| 弱词 | 使用场景 | 替换词 |
|---|---|---|
| consider, might, could, may | 关键环节 | MUST, REQUIRED |
| consider, might, could, may | 可选引导 | 删除或添加"optionally"保留 |
| should, prefer | 关键环节 | MUST |
| should, prefer | 软性引导 | 保留原样 |
| do some, handle, process | 任何场景 | 指定具体操作:"Run X", "Call Y" |
| as needed, if necessary | 任何场景 | IF [条件] → THEN [操作] |
| feel free to, you can | 必要操作 | 完全删除,使用MUST |
| feel free to, you can | 可选操作 | "Optionally, you may..." |
CRITICAL: MUST/FORBIDDEN/NEVER等关键规则中的弱词必须替换。
Step 4: FIX
步骤4:FIX
<fix_gate>
STOP. Fix issues in priority order: Critical → High → Medium → Low.
<fix_gate>
STOP. 按优先级修复问题:关键 → 高 → 中 → 低。
Pre-Conditions
前置条件
- Step 3 (RATE) completed
- Issues table produced
- 步骤3(RATE)已完成
- 已生成问题表格
Fix Priority (MUST follow order)
修复优先级(必须遵循)
- Critical first - Weak words in MUST/FORBIDDEN contexts
- High next - Missing enforcement, ambiguous instructions
- Medium - Missing output formats, missing gates
- Low last - Redundancy, density (only if value added)
- 先处理关键问题 - MUST/FORBIDDEN场景中的弱词
- 再处理高优先级问题 - 缺少强制约束、指令模糊
- 中优先级问题 - 缺少输出格式、缺少检查门
- 最后处理低优先级问题 - 冗余内容、信息密度(仅在有价值时处理)
Command Strength Hierarchy
指令强度层级
| Strength | Keywords | Use For |
|---|---|---|
| Absolute | NEVER, ALWAYS, MUST, FORBIDDEN, CRITICAL | Non-negotiable rules |
| Stop | STOP, HALT, DO NOT proceed, WAIT | Gates/checkpoints |
| Required | REQUIRED, MANDATORY | Essential steps |
| Soft | should, prefer | Optional guidance only |
| 强度 | 关键词 | 使用场景 |
|---|---|---|
| 绝对强制 | NEVER, ALWAYS, MUST, FORBIDDEN, CRITICAL | 不可协商的规则 |
| 强制停止 | STOP, HALT, DO NOT proceed, WAIT | 检查门/检查点 |
| 必须执行 | REQUIRED, MANDATORY | 必要步骤 |
| 软性引导 | should, prefer | 仅用于可选引导 |
Triple Lock Pattern (REQUIRED for Critical Rules)
三重锁定模式(关键规则必填)
1. STATE: "You MUST X"
2. FORBID: "FORBIDDEN: Not doing X"
3. REQUIRE: "REQUIRED: Verify X complete"1. STATE: "You MUST X"
2. FORBID: "FORBIDDEN: Not doing X"
3. REQUIRE: "REQUIRED: Verify X complete"Reasoning Block (REQUIRED Before Changes)
推理模块(修改前必填)
REQUIRED: Before making changes, produce a block:
<reasoning>markdown
<reasoning>
1. **Current state:** [What exists now]
2. **Goal:** [What we are trying to achieve]
3. **Approach:** [Why this specific change]
4. **Risk:** [What could go wrong]
</reasoning>必须执行: 修改前需生成模块:
<reasoning>markdown
<reasoning>
1. **当前状态:** [现有内容]
2. **目标:** [要实现的效果]
3. **方案:** 选择该修改的原因
4. **风险:** 可能出现的问题
</reasoning>Gate Template (When Adding Gates)
检查门模板(添加检查门时使用)
markdown
<[name]_gate>
**STOP. DO NOT proceed. [What to verify]**markdown
<[名称]_gate>
**STOP. DO NOT proceed. [需验证的内容]**Pre-Conditions
前置条件
- [Previous step completed]
- 上一步已完成
Actions (REQUIRED)
必须执行的操作
- [Action]
- [操作内容]
Gate Check
检查门验证
Verify before proceeding:
- [Condition]
进入下一步前需确认:
- [验证条件]
FORBIDDEN
禁止操作
- [What not to do]
- [禁止的行为]
ALLOWED
允许操作
- [What is permitted]
- [允许的行为]
On Failure
失败处理
- IF [condition] → THEN [recovery] </[name]_gate>
undefined- IF [条件] → THEN [恢复措施] </[名称]_gate>
undefinedGate Check
检查门验证
Verify before proceeding:
- All Critical issues fixed
- All High issues fixed
- Medium/Low addressed or documented as skipped
- Reasoning block produced before changes
进入下一步前需确认:
- 所有关键问题已修复
- 所有高优先级问题已修复
- 中/低优先级问题已处理或记录为跳过
- 修改前已生成推理模块
FORBIDDEN
禁止操作
- Over-strengthening soft guidance (keep "should" for optional items)
- Changing logic that already works
- Adding unnecessary complexity
- Skipping Critical/High issues
- Bloating: fixes that increase line count >10% without adding required gates
- 过度强化软性引导内容(可选内容保留"should")
- 修改已正常运行的逻辑
- 添加不必要的复杂度
- 跳过关键/高优先级问题
- 冗余扩充:除非添加必要检查门,否则修复后行数增幅不得超过10%
ALLOWED
允许操作
- Text output (draft fixes)
- Iterating on fixes
- 文本输出(修复草稿)
- 迭代优化修复内容
On Failure
失败处理
- IF over-strengthening detected → THEN revert and re-assess using RATE step criteria
- IF unsure if logic changed → THEN compare before/after intent </fix_gate>
- 若 发现过度强化 → 则 撤销修改并重新按RATE步骤标准评估
- 若 不确定是否修改了逻辑 → 则 对比修改前后的意图 </fix_gate>
Step 5: VALIDATE
步骤5:VALIDATE
<validate_gate>
STOP. DO NOT output yet. Validate all fixes against checklist.
<validate_gate>
STOP. 先不要输出,根据检查清单验证所有修复内容。
Pre-Conditions
前置条件
- Step 4 (FIX) completed
- All Critical/High issues addressed
- 步骤4(FIX)已完成
- 所有关键/高优先级问题已处理
Validation Checklist (MUST complete all)
验证检查清单(必须全部完成)
REQUIRED checks:
- No weak words in critical sections
- Critical rules use MUST/NEVER/FORBIDDEN
- No conversational filler
- No conflicting instructions
- Logical flow preserved
- Original intent preserved
- Triple Lock applied to critical rules
- Line count increase <10% (unless adding required gates)
Additional checks (if applicable):
- Gates have Pre-Conditions, Gate Check, FORBIDDEN, ALLOWED, On Failure
- Outputs have format specifications
- IF/THEN rules for decision points
Referential Clarity (MUST check):
- No ambiguous pronouns or positional references without explicit antecedent
- All entities have stable names (same term throughout)
- Steps/outputs referenced by name, not position
- All cross-references are unambiguous
- No implicit "the" references without clear antecedent
- XML tags for attention-critical sections
必填检查项:
- 关键部分无弱词
- 关键规则使用MUST/NEVER/FORBIDDEN
- 无对话式冗余内容
- 无冲突指令
- 逻辑流程保留
- 原始意图保留
- 关键规则已应用三重锁定模式
- 行数增幅<10%(添加必要检查门除外)
附加检查项(若适用):
- 检查门包含前置条件、验证项、禁止操作、允许操作、失败处理
- 输出内容有格式规范
- 决策点使用IF/THEN规则
Reflection (REQUIRED)
指代清晰度检查(必须完成)
MUST answer these questions:
- Would I trust this prompt to execute reliably?
- What's the weakest remaining section?
- Did I change any original intent? (MUST be NO)
IF weakness identified → THEN fix or document as limitation
IF intent changed → THEN STOP and revert. Return to UNDERSTAND step.
- 无模糊代词或位置指代(需明确指代对象)
- 所有实体名称统一
- 步骤/输出按名称引用,而非位置
- 所有交叉引用清晰明确
- 无隐含的"the"指代(需明确对象)
- 关键内容使用XML标签标注
Definition of Done (DoD) - Fast Final Gate
反思(必须完成)
ALL must be true before OUTPUT:
- Single execution path (no ambiguous branches)
- All inputs/outputs explicitly defined
- All decision points use IF/THEN
- No orphan references (every "it/this" resolved)
必须回答以下问题:
- 我是否信任该Prompt能可靠执行?
- 剩余最薄弱的环节是什么?
- 我是否修改了原始意图?(必须回答否)
若 识别到薄弱环节 → 则 修复或记录为限制项
若 已修改意图 → 则 停止操作并撤销修改,返回UNDERSTAND步骤
Gate Check
完成标准(DoD)- 最终检查门
Verify before proceeding:
- All REQUIRED checks pass
- Reflection questions answered
- No intent changes
输出前必须满足所有条件:
- 单一执行路径(无模糊分支)
- 所有输入/输出明确定义
- 所有决策点使用IF/THEN
- 无未明确指代的"it/this"等表述
FORBIDDEN
检查门验证
- Outputting without completing validation
- Skipping checklist items
- Proceeding with failed checks
进入下一步前需确认:
- 所有必填检查项已通过
- 已回答反思问题
- 未修改原始意图
ALLOWED
禁止操作
- Text output (validation results)
- Returning to FIX step
- 未完成验证就输出
- 跳过检查清单项
- 未通过检查就推进
On Failure
允许操作
- IF validation fails → THEN return to FIX step
- IF intent changed → THEN return to UNDERSTAND step </validate_gate>
- 文本输出(验证结果)
- 返回FIX步骤重新处理
Step 6: OUTPUT
失败处理
<output_gate>
STOP. Verify VALIDATE step passed before outputting.
- 若 验证失败 → 则 返回FIX步骤
- 若 已修改意图 → 则 返回UNDERSTAND步骤 </validate_gate>
Pre-Conditions
步骤6:OUTPUT
- Step 5 (VALIDATE) completed
- All REQUIRED checks passed
- No intent changes confirmed
<output_gate>
STOP. 确认VALIDATE步骤通过后再输出。
Output Format (REQUIRED - DO NOT deviate)
前置条件
markdown
undefined- 步骤5(VALIDATE)已完成
- 所有必填检查项已通过
- 已确认未修改原始意图
Optimization Complete
要求的输出格式(必须严格遵循,不得偏离)
Summary
—
- Issues Found: [N]
- Fixes Applied: [N]
- Intent Preserved: Yes
markdown
undefinedChanges Made
优化完成
—
总结
| Category | Count | Examples |
|---|---|---|
| Command Strengthening | [N] | [Brief example] |
| Gates Added/Fixed | [N] | [Brief example] |
| Redundancy Removed | [N] | [Brief example] |
- 发现问题数: [N]
- 已修复问题数: [N]
- 意图保留: 是
Optimized Document
已做修改
[Full optimized content]
undefined| 分类 | 数量 | 示例 |
|---|---|---|
| 指令强化 | [N] | [简要示例] |
| 检查门添加/修复 | [N] | [简要示例] |
| 冗余内容移除 | [N] | [简要示例] |
FORBIDDEN
优化后的文档
- Deviating from output format
- Outputting without validation pass
- Omitting the optimized document
[完整优化内容]
undefinedALLOWED
禁止操作
- StrReplace/Write to save optimized content
- Text output (summary + document)
- 偏离输出格式
- 未通过验证就输出
- 省略优化后的文档
On Failure
允许操作
- IF format deviates → THEN regenerate output
- IF user requests changes → THEN return to FIX step </output_gate>
- 使用StrReplace/Write保存优化内容
- 文本输出(总结+文档)
Reference: Instruction Precedence
失败处理
<precedence_table>
When rules conflict, follow this precedence (highest wins):
| Priority | Category | Examples | Notes |
|---|---|---|---|
| 1 (highest) | Safety/Tool Restrictions | FORBIDDEN tools, NEVER actions | Always wins |
| 2 | User explicit request | "I want X", "Do Y" | Overrides defaults |
| 3 | FORBIDDEN/MUST rules | "FORBIDDEN: changing logic" | Overrides preferences |
| 4 | Skill defaults | Default behaviors, templates | Baseline |
| 5 (lowest) | Soft guidance | "prefer", "consider" | Yields to all above |
Resolution rule: When two rules conflict, the higher priority wins. Document the conflict and resolution.
</precedence_table>
- 若 格式偏离 → 则 重新生成输出内容
- 若 用户要求修改 → 则 返回FIX步骤 </output_gate>
Reference: Context Patterns
参考:指令优先级
<reasoning_patterns>
<precedence_table>
当规则冲突时,遵循以下优先级(优先级高的胜出):
| 优先级 | 分类 | 示例 | 说明 |
|---|---|---|---|
| 1(最高) | 安全/工具限制 | 禁止使用的工具、NEVER操作 | 始终优先 |
| 2 | 用户明确请求 | "我想要X", "执行Y" | 覆盖默认设置 |
| 3 | FORBIDDEN/MUST规则 | "FORBIDDEN: 修改逻辑" | 覆盖偏好设置 |
| 4 | Skill默认设置 | 默认行为、模板 | 基准规则 |
| 5(最低) | 软性引导 | "prefer", "consider" | 服从所有更高优先级规则 |
冲突解决规则: 当两条规则冲突时,优先级高的规则胜出。需记录冲突及解决方式。
</precedence_table>
State Summaries (Context Retention)
参考:上下文模式
Use at the start of complex phases to prevent "forgetting":
markdown
<phase_start>
**State Summary:**
- **Goal:** [What are we solving?]
- **Progress:** [What is already done?]
- **Next:** [Immediate next step]
- **Blockers:** [Any issues?]
</phase_start>REQUIRED: For multi-step fixes, produce a state summary every 3 fixes.
</reasoning_patterns>
<reasoning_patterns>
Reference: High-Value vs Low-Value Content
状态总结(上下文保留)
<content_guide>
在复杂阶段开始时使用,防止"遗忘":
markdown
<phase_start>
**状态总结:**
- **目标:** 我们要解决什么问题?
- **进度:** 已完成哪些内容?
- **下一步:** 立即要执行的步骤
- **障碍:** 存在哪些问题?
</phase_start>必须执行: 对于多步骤修复,每完成3个修复需生成一次状态总结。
</reasoning_patterns>
REMOVE (Low Value)
参考:高价值 vs 低价值内容
| Pattern | Action |
|---|---|
| Explanatory prose without actionable constraints | DELETE |
| Numeric scoring systems | Replace with pass/fail |
| Repeated examples | Keep 1-2 best |
| Long prose paragraphs | Convert to tables |
| Hedging language | Replace with MUST or DELETE |
| Emoji as instructions | Replace with strong command words (unless prompt output requires emoji) |
<content_guide>
KEEP (High Value)
移除(低价值)
| Pattern | Example |
|---|---|
| Tables with actions | ` |
| Imperative verbs | STOP, EXECUTE, VERIFY |
| FORBIDDEN/ALLOWED lists | Clear capability control |
| IF/THEN conditionals | |
| Gate checkpoints | STOP before transitions |
| </content_guide> |
| 模式 | 操作 |
|---|---|
| 无操作约束的解释性散文 | 删除 |
| 数字评分系统 | 替换为通过/不通过 |
| 重复示例 | 保留1-2个最佳示例 |
| 长段落散文 | 转换为表格 |
| 模糊表述的弱词 | 替换为MUST或删除 |
| 用表情符号当指令 | 替换为强指令词(除非Prompt输出要求使用表情符号) |
Quick Reference
保留(高价值)
| Goal | Pattern |
|---|---|
| Force a stop | |
| Require action | |
| Ban action | |
| Force format | |
| Create checkpoint | |
| Handle errors | |
| Critical rule | Triple Lock: STATE + FORBID + REQUIRE |
| Replace emoji | Emoji → strong command word (MUST, FORBIDDEN, etc.) |
| 模式 | 示例 |
|---|---|
| 带操作的表格 | ` |
| 命令式动词 | STOP, EXECUTE, VERIFY |
| FORBIDDEN/ALLOWED列表 | 清晰的能力控制 |
| IF/THEN条件语句 | |
| 检查门验证点 | 阶段转换前的STOP检查 |
| </content_guide> |
Common Mistakes
快速参考
<common_mistakes>
| Mistake | Why It Fails | Fix |
|---|---|---|
| Skipping UNDERSTAND step | Fixes wrong things, breaks working logic | ALWAYS produce Understanding output first |
| Fixing before RATE complete | Misses issues, inconsistent severity handling | Complete issues table before ANY fix |
| Over-strengthening soft guidance | "prefer" → "MUST" breaks optional flexibility | Keep "should/prefer" for truly optional items |
| Using "it/this/that" | Agent loses context, applies fix to wrong element | Name every entity explicitly |
| Outputting without VALIDATE | Weak words remain, conflicts undetected | MUST complete all checklist items |
| Changing working logic | User trusted original behavior | FORBIDDEN: If the logic works, don't touch it |
| Bloating the prompt | Verbose fixes overwhelm context, reduce density | MUST keep fixes concise; <10% line increase |
| </common_mistakes> |
| 目标 | 模式 |
|---|---|
| 强制停止 | |
| 要求执行操作 | |
| 禁止操作 | |
| 强制格式 | |
| 创建检查点 | |
| 错误处理 | |
| 关键规则 | 三重锁定:STATE + FORBID + REQUIRE |
| 替换表情符号 | 表情符号 → 强指令词(MUST, FORBIDDEN等) |
Before/After Example
常见错误
<before_after_example>
<common_mistakes>
| 错误 | 失败原因 | 修复方式 |
|---|---|---|
| 跳过UNDERSTAND步骤 | 修复错误内容,破坏正常逻辑 | 始终先生成理解输出内容 |
| 完成RATE前修复问题 | 遗漏问题,严重程度处理不一致 | 生成问题表格后再进行任何修复 |
| 过度强化软性引导 | 将"prefer"改为"MUST"破坏可选灵活性 | 真正的可选内容保留"should/prefer" |
| 使用"it/this/that" | Agent丢失上下文,修复错误元素 | 明确命名所有实体 |
| 未验证就输出 | 仍存在弱词,未检测到冲突 | 必须完成所有检查清单项 |
| 修改正常运行的逻辑 | 用户信任原始行为 | 禁止操作:若逻辑正常,请勿修改 |
| 冗余扩充Prompt | 冗长修复内容超出上下文,降低信息密度 | 必须保持修复简洁;行数增幅<10% |
| </common_mistakes> |
Before (Weak)
前后对比示例
Consider checking the file before making changes.
You should validate the output.
Handle any errors that occur.
If needed, retry the operation.<before_after_example>
After (Strong)
优化前(弱指令)
**REQUIRED:** You MUST read the file completely before making ANY changes.
**FORBIDDEN:** Outputting without validation.Consider checking the file before making changes.
You should validate the output.
Handle any errors that occur.
If needed, retry the operation.On Error
优化后(强指令)
- IF file unreadable → THEN ask user for correct path
- IF validation fails → THEN return to FIX step
**REQUIRED:** You MUST read the file completely before making ANY changes.
**FORBIDDEN:** Outputting without validation.Retry Logic
错误处理
- IF operation fails AND retry_count < 3 → THEN retry with exponential backoff
- IF retry_count >= 3 → THEN STOP and report failure to user
undefined- IF file unreadable → THEN ask user for correct path
- IF validation fails → THEN return to FIX step
Changes Applied
重试逻辑
| Original | Issue | Fixed |
|---|---|---|
| "Consider checking" | Weak word in critical action | "REQUIRED: You MUST" |
| "should validate" | Weak enforcement | "FORBIDDEN: without validation" |
| "Handle any errors" | Ambiguous instruction | Explicit IF/THEN for each error |
| "If needed, retry" | Vague condition | Specific retry count + backoff |
| </before_after_example> |
- IF operation fails AND retry_count < 3 → THEN retry with exponential backoff
- IF retry_count >= 3 → THEN STOP and report failure to user
undefined—
已做修改
—
| 原始内容 | 问题 | 优化后 |
|---|---|---|
| "Consider checking" | 关键操作使用弱词 | "REQUIRED: You MUST" |
| "should validate" | 约束性弱 | "FORBIDDEN: without validation" |
| "Handle any errors" | 指令模糊 | 为每个错误明确IF/THEN规则 |
| "If needed, retry" | 条件模糊 | 明确重试次数 + 退避策略 |
| </before_after_example> |