prompt-optimizer

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Prompt Optimizer

提示词优化器

Optimize prompts with evals. Keep every instruction, example, and external context reference causal.
通过评估优化提示词。确保每条指令、示例和外部上下文引用都具备因果关联性。

Load Only What You Need

按需加载内容

NeedRead
New prompt
references/core-patterns.md
,
references/model-family-notes.md
,
references/transformed-examples.md
Existing prompt
references/meta-optimization-loop.md
,
references/core-patterns.md
,
references/model-family-notes.md
Model-family port
references/model-family-notes.md
,
references/core-patterns.md
Repeated failures
references/meta-optimization-loop.md
,
references/core-patterns.md
Weak or ambiguous draft
references/transformed-examples.md
Provenance
SOURCES.md
需求阅读内容
新提示词
references/core-patterns.md
,
references/model-family-notes.md
,
references/transformed-examples.md
已有提示词
references/meta-optimization-loop.md
,
references/core-patterns.md
,
references/model-family-notes.md
跨模型迁移
references/model-family-notes.md
,
references/core-patterns.md
重复失败问题
references/meta-optimization-loop.md
,
references/core-patterns.md
薄弱或模糊的草稿
references/transformed-examples.md
来源追溯
SOURCES.md

Step 1: Capture Contract

步骤1:明确约定

Record before editing:
  • task type: new, refine, port, or debug
  • target model family and snapshot, if known
  • prompt surface:
    system
    ,
    developer
    ,
    user
    , tool descriptions, examples, schemas
  • layer owners: platform, deployer/persona, retrieved context, user payload
  • objective and non-goals
  • inputs, tools, and external files available
  • required output shape
  • success criteria and failure cases
  • hard constraints: latency, verbosity, safety, budget, tool use, style
If success criteria or examples are missing, create a small eval set first. If the bottleneck is model choice, retrieval, tool schema, or missing evals, say so before rewriting.
在编辑前记录以下信息:
  • 任务类型:新建、改进、迁移或调试
  • 目标模型家族及版本快照(若已知)
  • 提示词载体:
    system
    developer
    user
    、工具描述、示例、模式
  • 层级负责人:平台、部署者/角色、检索上下文、用户负载
  • 目标与非目标
  • 可用的输入、工具和外部文件
  • 要求的输出格式
  • 成功标准与失败案例
  • 硬性约束:延迟、冗长性、安全性、预算、工具使用、风格
若缺少成功标准或示例,先创建一个小型评估集。 若瓶颈在于模型选择、检索能力、工具模式或缺失的评估体系,请在重写前说明。

Step 2: Inventory External Context

步骤2:梳理外部上下文

For repo or agent prompts, list stable context by exact path:
Context typeExamples
Agent rules
AGENTS.md
,
CLAUDE.md
Specs
specs/*.md
,
docs/api.md
Policies
SECURITY.md
,
docs/releasing.md
Examples
examples/
,
tests/fixtures/
Rules:
  • Reference stable files by repo-relative path instead of copying them.
  • Paste only excerpts needed for the prompt or eval case.
  • Mark whether a file is
    loaded
    ,
    referenced
    , or
    out of scope
    .
  • Avoid vague context pointers such as "read the docs".
对于仓库或Agent提示词,按精确路径列出稳定上下文:
上下文类型示例
Agent规则
AGENTS.md
,
CLAUDE.md
规范
specs/*.md
,
docs/api.md
政策
SECURITY.md
,
docs/releasing.md
示例
examples/
,
tests/fixtures/
规则:
  • 通过仓库相对路径引用稳定文件,而非复制内容。
  • 仅粘贴提示词或评估案例所需的摘录。
  • 标记文件状态为
    loaded
    (已加载)、
    referenced
    (已引用)或
    out of scope
    (超出范围)。
  • 避免使用“阅读文档”这类模糊的上下文指向。

Step 3: Choose Model Strategy

步骤3:选择模型策略

Read
references/model-family-notes.md
.
  • Known family: optimize for that family.
  • Unknown family: write a portable base plus short adapter notes.
  • Snapshot changes: rerun evals.
  • Cross-family divergence: specialize only the failing layer.
阅读
references/model-family-notes.md
  • 已知模型家族:针对该家族进行优化。
  • 未知模型家族:编写可移植的基础版本,附加简短适配说明。
  • 版本快照变更:重新运行评估。
  • 跨家族差异:仅针对失败层级进行定制。

Step 4: Shape Prompt

步骤4:构建提示词结构

Read
references/core-patterns.md
.
  • Put stable policy in
    system
    or
    developer
    .
  • Put task-local facts, retrieved context, and variables in user-facing sections.
  • Keep one owner per behavior rule.
  • Use headings or tags only to separate content types.
  • Put tool policy in prompt text; keep schemas in provider-native tools.
  • Keep persona light unless it changes behavior.
  • Use the shortest wording that preserves the constraint.
  • Cut filler, repeated reminders, dead examples, and rationale that does not affect evals.
阅读
references/core-patterns.md
  • 将稳定政策置于
    system
    developer
    层级。
  • 将任务本地事实、检索上下文和变量置于用户可见部分。
  • 每个行为规则仅对应一个负责人。
  • 仅使用标题或标签区分内容类型。
  • 将工具政策写入提示词文本;保持模式为原生工具格式。
  • 除非角色会改变行为,否则尽量简化角色设定。
  • 使用能保留约束的最短措辞。
  • 删除冗余内容、重复提醒、失效示例以及不影响评估的原理说明。

Step 5: Optimize

步骤5:优化迭代

Read
references/meta-optimization-loop.md
for refinements.
  1. Baseline the current prompt on the same eval slice.
  2. Cluster failures by root cause.
  3. Write concrete edit criticisms.
  4. Generate two to four candidates:
    • minimal-diff repair
    • structure-first rewrite
    • examples-first or tool-rule variant
    • provider adapter when needed
  5. Compare candidates on the same cases.
  6. Keep a short optimization log.
  7. Validate the winner on holdout cases.
  8. Stop on plateau, oscillation, overfit, excessive cost, or non-prompt bottleneck.
阅读
references/meta-optimization-loop.md
进行改进。
  1. 在相同评估切片上建立当前提示词的基准。
  2. 按根本原因对失败案例进行聚类。
  3. 撰写具体的编辑改进意见。
  4. 生成2-4个候选版本:
    • 最小差异修复版本
    • 结构优先重写版本
    • 示例优先或工具规则变体版本
    • 必要时提供模型适配版本
  5. 在相同案例上比较候选版本。
  6. 保留简短的优化日志。
  7. 在预留案例上验证最优版本。
  8. 当出现性能停滞、震荡、过拟合、成本过高或非提示词瓶颈时停止优化。

Step 6: Return Package

步骤6:交付成果包

Return:
  1. Target
  2. Success Criteria
  3. External Context
  4. Optimized Prompt
  5. Adapter Notes
  6. Eval Set
  7. Optimization Log
  8. Residual Risks
For existing prompts, include a concise diff-style note of the main behavioral changes.
返回以下内容:
  1. 目标
  2. 成功标准
  3. 外部上下文
  4. 优化后的提示词
  5. 适配说明
  6. 评估集
  7. 优化日志
  8. 剩余风险
对于已有提示词,需包含简洁的差异式说明,标注主要行为变更。

Failure Modes

失败模式

  • editing before defining the eval target
  • mixing policy, examples, and raw context without boundaries
  • duplicating rules across layers
  • putting durable policy in user payloads
  • asking for chain-of-thought
  • keeping contradictory legacy instructions
  • overfitting to one or two examples
  • retaining examples that no longer improve evals
  • fixing tool-use failures only in prompt text when tool descriptions or schemas are weak
  • adding markup that does not reduce ambiguity
  • using persona as a substitute for behavior rules
  • 在定义评估目标前就开始编辑
  • 无边界地混合政策、示例和原始上下文
  • 在多个层级重复规则
  • 将持久化政策放入用户负载
  • 要求链式思考(chain-of-thought)
  • 保留矛盾的遗留指令
  • 过度拟合单个或两个示例
  • 保留无法提升评估效果的示例
  • 当工具描述或模式薄弱时,仅在提示词文本中修复工具使用失败问题
  • 添加无法减少歧义的标记
  • 用角色设定替代行为规则