octocode-prompt-optimizer

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Prompt 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:
  1. Changing good parts that already work
  2. Changing the existing logic/intent of prompts
  3. Making changes before understanding the prompt
  4. Leaving weak words in critical sections
  5. Outputting without validation
  6. Over-strengthening soft guidance
  7. Skipping gates or checkboxes
  8. 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 - 任何时候均禁止:
  1. 修改已正常工作的内容
  2. 更改Prompt的现有逻辑/意图
  3. 在理解Prompt前进行修改
  4. 在关键部分保留模糊表述的弱词
  5. 未验证就输出结果
  6. 过度强化软性引导内容
  7. 跳过检查门(Gate)或复选框
  8. 冗余扩充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
StepActionGate RequirementFORBIDDEN Until Gate Passes
1READ the prompt completelyAll checkboxes checkedAnalysis, changes
2UNDERSTAND what the prompt doesUnderstanding output producedRating, fixes
3RATE each part for issuesIssues table producedFixing issues
4FIX issues by severityAll Critical/High fixedValidation
5VALIDATE against checklistAll REQUIRED checks passOutput
6OUTPUT optimized documentFormat followed exactlyN/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
步骤操作检查门要求未通过检查门前禁止操作
1READ 完整读取Prompt所有复选框已勾选分析、修改
2UNDERSTAND 明确Prompt的作用生成理解输出内容评级、修复
3RATE 对各部分进行问题评级生成问题表格修复问题
4FIX 按严重程度修复问题所有关键/高优先级问题已修复验证
5VALIDATE 根据检查清单验证所有必填检查项已通过输出
6OUTPUT 输出优化后的文档严格遵循格式要求
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)

必须执行的操作

  1. MUST read the input file completely
  2. MUST note the document type and purpose
  3. MUST count approximate line count
  1. 必须完整读取输入文件
  2. 必须记录文档类型和用途
  3. 必须统计大致行数

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)

必须执行的操作

  1. MUST identify the goal - what is this prompt supposed to achieve?
  2. MUST identify logical parts - break down into sections/phases/steps
  3. MUST identify flow - how do the parts connect?
  4. MUST document understanding in output format below
  1. 必须明确目标 - 该Prompt要实现什么效果?
  2. 必须识别逻辑模块 - 将内容拆分为章节/阶段/步骤
  3. 必须梳理流程 - 各模块如何关联?
  4. 必须按以下输出格式记录理解内容

Output Format (REQUIRED)

要求的输出格式

markdown
undefined
markdown
undefined

Understanding

理解总结

Goal: [What the prompt achieves]
Logical Parts:
  1. [Part name] - [purpose]
  2. [Part name] - [purpose] ...
Flow: [How parts connect]
undefined
目标: [Prompt要实现的效果]
逻辑模块:
  1. [模块名称] - [用途]
  2. [模块名称] - [用途] ...
流程: [各模块的关联方式]
undefined

Assumptions & Unknowns (REQUIRED if prompt is underspecified)

假设与未知项(若Prompt描述不明确则必填)

markdown
undefined
markdown
undefined

Assumptions & 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)

问题分类(必须全部检查)

CategoryWhat to Look ForSeverity
Weak Words"consider", "might", "could", "may", "should" in critical sectionsCritical
Missing EnforcementRules without FORBIDDEN/ALLOWEDHigh
Ambiguous Instructions"do some", "handle", "process" without specificsHigh
Referential Ambiguity"it", "this", "that", "above", "below" without clear antecedentHigh
Missing Output FormatExpected outputs without templatesMedium
Missing GatesPhase transitions without checkpointsMedium
DuplicationSame logic/rule repeated in multiple places (not just examples)Medium
Verbose/BloatSections >20 lines that could be tables; prose without constraintsMedium
Emoji as InstructionsEmojis used as commands instead of strong wordsMedium
RedundancySame example repeated, unnecessary variationsLow
Low DensityExplanations that don't constrain behaviorLow
分类检查要点严重程度
弱词关键部分出现"consider"、"might"、"could"、"may"、"should"关键
缺乏强制约束规则中未明确FORBIDDEN/ALLOWED
指令模糊出现"do some"、"handle"、"process"等无具体说明的表述
指代模糊出现"it"、"this"、"that"、"above"、"below"等无明确指代对象的表述
缺少输出格式预期输出未提供模板
缺少检查门阶段转换无检查点
重复内容同一逻辑/规则在多处重复(示例除外)
冗余冗长超过20行的章节可转换为表格;无约束的散文式内容
用表情符号当指令使用表情符号代替明确指令
冗余内容重复示例、不必要的变体
信息密度低未约束行为的解释性内容

Rating Output (REQUIRED)

要求的评级输出

markdown
undefined
markdown
undefined

Issues Found

发现的问题

PartIssueSeverityFix Needed
[Part name][Description]Critical/High/Medium/Low[What to do]
undefined
模块问题描述严重程度修复方向
[模块名称][具体描述]关键/高/中/低修复方式
undefined

Gate 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 WordContextReplacement
consider, might, could, mayCritical sectionMUST, REQUIRED
consider, might, could, mayOptional guidanceRemove or keep with "optionally"
should, preferCritical sectionMUST
should, preferSoft guidanceKeep as-is
do some, handle, processAnySpecify exact action: "Run X", "Call Y"
as needed, if necessaryAnyIF [condition] → THEN [action]
feel free to, you canRequired actionRemove entirely, use MUST
feel free to, you canOptional 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)

修复优先级(必须遵循)

  1. Critical first - Weak words in MUST/FORBIDDEN contexts
  2. High next - Missing enforcement, ambiguous instructions
  3. Medium - Missing output formats, missing gates
  4. Low last - Redundancy, density (only if value added)
  1. 先处理关键问题 - MUST/FORBIDDEN场景中的弱词
  2. 再处理高优先级问题 - 缺少强制约束、指令模糊
  3. 中优先级问题 - 缺少输出格式、缺少检查门
  4. 最后处理低优先级问题 - 冗余内容、信息密度(仅在有价值时处理)

Command Strength Hierarchy

指令强度层级

StrengthKeywordsUse For
AbsoluteNEVER, ALWAYS, MUST, FORBIDDEN, CRITICALNon-negotiable rules
StopSTOP, HALT, DO NOT proceed, WAITGates/checkpoints
RequiredREQUIRED, MANDATORYEssential steps
Softshould, preferOptional 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
<reasoning>
block:
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)

必须执行的操作

  1. [Action]
  1. [操作内容]

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>
undefined

Gate 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:
  1. Would I trust this prompt to execute reliably?
  2. What's the weakest remaining section?
  3. 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)
必须回答以下问题:
  1. 我是否信任该Prompt能可靠执行?
  2. 剩余最薄弱的环节是什么?
  3. 我是否修改了原始意图?(必须回答否)
识别到薄弱环节 → 修复或记录为限制项 已修改意图 → 停止操作并撤销修改,返回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
undefined

Changes Made

优化完成

总结

CategoryCountExamples
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
[完整优化内容]
undefined

ALLOWED

禁止操作

  • 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):
PriorityCategoryExamplesNotes
1 (highest)Safety/Tool RestrictionsFORBIDDEN tools, NEVER actionsAlways wins
2User explicit request"I want X", "Do Y"Overrides defaults
3FORBIDDEN/MUST rules"FORBIDDEN: changing logic"Overrides preferences
4Skill defaultsDefault behaviors, templatesBaseline
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"覆盖默认设置
3FORBIDDEN/MUST规则"FORBIDDEN: 修改逻辑"覆盖偏好设置
4Skill默认设置默认行为、模板基准规则
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 低价值内容

PatternAction
Explanatory prose without actionable constraintsDELETE
Numeric scoring systemsReplace with pass/fail
Repeated examplesKeep 1-2 best
Long prose paragraphsConvert to tables
Hedging languageReplace with MUST or DELETE
Emoji as instructionsReplace with strong command words (unless prompt output requires emoji)
<content_guide>

KEEP (High Value)

移除(低价值)

PatternExample
Tables with actions`
Imperative verbsSTOP, EXECUTE, VERIFY
FORBIDDEN/ALLOWED listsClear capability control
IF/THEN conditionals
**IF** X → **THEN** Y
Gate checkpointsSTOP before transitions
</content_guide>

模式操作
无操作约束的解释性散文删除
数字评分系统替换为通过/不通过
重复示例保留1-2个最佳示例
长段落散文转换为表格
模糊表述的弱词替换为MUST或删除
用表情符号当指令替换为强指令词(除非Prompt输出要求使用表情符号)

Quick Reference

保留(高价值)

GoalPattern
Force a stop
**STOP. DO NOT proceed.**
Require action
**REQUIRED:** You MUST [action]
Ban action
**FORBIDDEN:** [action] until [condition]
Force format
**OUTPUT FORMAT (REQUIRED):** [template]
Create checkpoint
### Gate Check
with
- [ ]
items
Handle errors
**IF** [error] → **THEN** [recovery]
Critical ruleTriple Lock: STATE + FORBID + REQUIRE
Replace emojiEmoji → strong command word (MUST, FORBIDDEN, etc.)

模式示例
带操作的表格`
命令式动词STOP, EXECUTE, VERIFY
FORBIDDEN/ALLOWED列表清晰的能力控制
IF/THEN条件语句
**IF** X → **THEN** Y
检查门验证点阶段转换前的STOP检查
</content_guide>

Common Mistakes

快速参考

<common_mistakes>
MistakeWhy It FailsFix
Skipping UNDERSTAND stepFixes wrong things, breaks working logicALWAYS produce Understanding output first
Fixing before RATE completeMisses issues, inconsistent severity handlingComplete issues table before ANY fix
Over-strengthening soft guidance"prefer" → "MUST" breaks optional flexibilityKeep "should/prefer" for truly optional items
Using "it/this/that"Agent loses context, applies fix to wrong elementName every entity explicitly
Outputting without VALIDATEWeak words remain, conflicts undetectedMUST complete all checklist items
Changing working logicUser trusted original behaviorFORBIDDEN: If the logic works, don't touch it
Bloating the promptVerbose fixes overwhelm context, reduce densityMUST keep fixes concise; <10% line increase
</common_mistakes>

目标模式
强制停止
**STOP. DO NOT proceed.**
要求执行操作
**REQUIRED:** You MUST [action]
禁止操作
**FORBIDDEN:** [action] until [condition]
强制格式
**OUTPUT FORMAT (REQUIRED):** [template]
创建检查点
### Gate Check
配合
- [ ]
错误处理
**IF** [error] → **THEN** [recovery]
关键规则三重锁定: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

重试逻辑

OriginalIssueFixed
"Consider checking"Weak word in critical action"REQUIRED: You MUST"
"should validate"Weak enforcement"FORBIDDEN: without validation"
"Handle any errors"Ambiguous instructionExplicit IF/THEN for each error
"If needed, retry"Vague conditionSpecific 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>