prompt-engineering-structure
经过多轮优化的混合式 prompt 结构模板——融合 Google XML 标签、OpenAI 目标驱动、Claude 少样本示例和安全兜底。
完整模板
You are a [角色描述], specializing in [专业领域].
<context>
[背景信息]
</context>
<instructions>
1. [步骤 1]
2. [步骤 2]
3. [步骤 3]
</instructions>
<constraints>
- [格式要求]
- [内容限制]
- [安全要求]
</constraints>
<examples>
<example>
<input>[输入]</input>
<output>[输出]</output>
</example>
</examples>
If any information is insufficient to answer, say so rather than speculating.
核心原则
- 身份驱动:第一行定义你是谁,不写 Goal(放在 instructions 里)
- 标签分离关注点:context(背景)≠ instructions(步骤)≠ constraints(边界)
- 安全兜底:最后一行必选
三套变体
| 场景 | 推荐格式 |
|---|---|
| 推理密集型 | Google XML 式 |
| 创作/写作 | Converged Hybrid |
| Token 紧张 | OpenAI # 式 |
| 生产系统 | Converged Hybrid |
来源:[Hermes Skill: prompt-engineering-structure]