anthropic-1p-prompt-optimizer

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Anthropic 1p Prompt Optimizer

Anthropic 1P 提示词优化器

Overview

概述

Turn vague “帮我改一下提示词/Make this prompt better” into a repeatable workflow:
  1. clarify goals + constraints, 2) restructure the prompt using proven building blocks, 3) add formatting/examples/guardrails, 4) propose a small test plan for iteration.
将模糊的“帮我改一下提示词/Make this prompt better”转化为可重复的工作流:1) 明确目标与约束条件,2) 使用经过验证的构建模块重构提示词,3) 添加格式/示例/防护措施,4) 提出用于迭代的小型测试计划。

Workflow (1P-style)

工作流(1P风格)

Step 0: Intake (ask only what’s missing)

步骤0:收集信息(仅询问缺失内容)

Request:
  • Current prompt (system + user), and where it runs (UI / API / multi-turn).
  • Target behavior: success criteria + non-goals.
  • Inputs the prompt will receive (and typical edge cases).
  • Required output format (plain text / XML / JSON) + strictness.
  • Common failures (hallucination, wrong tone, ignored constraints, formatting drift).
请求提供:
  • 当前的提示词(系统+用户),以及其运行环境(UI / API / 多轮对话)。
  • 目标行为:成功标准与非目标。
  • 提示词将接收的输入(以及典型边缘案例)。
  • 要求的输出格式(纯文本 / XML / JSON)+ 严格程度。
  • 常见失败情况(幻觉、语气错误、忽略约束条件、格式偏移)。

Step 1: Diagnose quickly

步骤1:快速诊断

Check for:
  • Ambiguous verbs (e.g., “analyze”, “optimize”) without definitions.
  • Missing role/audience/tone context.
  • Data mixed with instructions (needs XML delimiting).
  • Output format underspecified (needs tags / JSON schema / prefilling).
  • No examples for tricky formatting or edge cases.
检查以下内容:
  • 模糊的动词(例如“analyze”“optimize”)且无定义。
  • 缺失角色/受众/语气上下文。
  • 数据与指令混合(需要用XML分隔)。
  • 输出格式说明不足(需要标签 / JSON schema / 预填充)。
  • 没有针对复杂格式或边缘案例的示例。

Step 2: Apply building blocks (pick only what helps)

步骤2:应用构建模块(仅选择有帮助的部分)

Preferred building blocks from the tutorial (details in references):
  • Clear + direct instructions; explicitly ask for what you want.
  • Role prompting (optionally include intended audience).
  • Separate variable input from instructions using XML tags.
  • Enforce output format via XML/JSON + optional prefilling (“speaking for Claude”).
  • Add “precognition” for multi-step reasoning (thinking step-by-step).
  • Use few-shot examples to lock tone and formatting.
  • Reduce hallucinations with “give an out” + evidence-first extraction.
  • For complex prompts, use the 1P complex-prompt element ordering.
教程中的首选构建模块(详情见参考资料):
  • 清晰直接的指令;明确说明需求。
  • 角色提示(可选择性包含目标受众)。
  • 使用XML标签将可变输入与指令分离。
  • 通过XML/JSON强制输出格式,可选择预填充(“代表Claude发言”)。
  • 为多步推理添加“预知”(逐步思考)。
  • 使用少样本示例锁定语气和格式。
  • 通过“给出备选方案”+基于证据的提取减少幻觉。
  • 对于复杂提示词,使用1P复杂提示词元素排序方式。

Step 3: Ship revisions as artifacts

步骤3:交付修订成果

Always output:
  • Revised
    system
    prompt (if needed) and revised
    user
    prompt.
  • Any few-shot examples and XML tag wrappers.
  • A short change log (what changed and why; 5–10 bullets max).
  • 3–5 test cases with pass/fail criteria.
始终输出:
  • 修订后的
    system
    提示词(如有需要)和修订后的
    user
    提示词。
  • 所有少样本示例和XML标签包装器。
  • 简短的变更日志(变更内容及原因;最多5-10条要点)。
  • 3-5个带有通过/失败标准的测试用例。

Reference Files (load as needed)

参考文件(按需加载)

  • references/anthropic-1p-cheatsheet.md
    : chapter-by-chapter patterns and “why it works”.
  • references/complex-prompt-template.md
    : the 1P complex prompt element list + skeleton.
  • references/guardrails-hallucinations.md
    : “out”, evidence-first, placement, temperature tips.
  • references/tool-use-xml.md
    : function-calling XML formats (
    <function_calls>
    ,
    <function_results>
    ).
  • references/iteration-checklist.md
    : prompt chaining + evaluation loop.
  • references/anthropic-1p-cheatsheet.md
    :按章节划分的模式及其“有效原因”。
  • references/complex-prompt-template.md
    :1P复杂提示词元素列表+框架。
  • references/guardrails-hallucinations.md
    :“备选方案”、基于证据的提取、位置设置、温度参数提示。
  • references/tool-use-xml.md
    :函数调用XML格式(
    <function_calls>
    <function_results>
    )。
  • references/iteration-checklist.md
    :提示词链+评估循环。