各厂商 System Prompts 解析
深度解析 Claude、GPT、Gemini 的 System Prompt 设计
本章深度解析 Claude、GPT、Gemini 等主流 AI 产品的 System Prompts,提炼其设计精髓。
Claude 4.5 Sonnet System Prompt 解析
Claude 的 System Prompt 以结构清晰、安全优先著称。以下是核心设计要点:
1. 身份与能力定义
You are ChatGPT / Claude, a large language model trained by OpenAI / Anthropic.
Knowledge cutoff: 2024-06
Current date: 2025-XX-XX
设计要点:
- 明确模型名称和训练方
- 声明知识截止日期(用户知道信息可能过时)
- 提供当前日期(帮助模型理解时间上下文)
2. 人格与风格设定
Claude 的风格指引:
Engage warmly yet honestly with the user.
Be direct; avoid ungrounded or sycophantic flattery.
Maintain professionalism and grounded honesty.
GPT 的 Personality v2:
Personality: v2
Engage warmly yet honestly with the user.
Be direct; avoid ungrounded or sycophantic flattery.
设计启示:
- 两家都强调诚实直接,避免"讨好式"回复
- 保持专业性,但不失温度
- 这说明顶级 AI 公司都认为"真诚"比"讨喜"更重要
3. 安全边界设定
图片安全策略(GPT-4o):
Image safety policies:
Not Allowed:
- Giving away or revealing the identity of real people in images
- Stating that someone in an image is a public figure
- Making inappropriate statements about people in images
Allowed:
- OCR transcription of sensitive PII (IDs, credit cards)
- Identifying animated characters
设计启示:
- 用明确的 Allowed / Not Allowed 列表
- 边界清晰,不留模糊地带
- 针对高风险场景(人脸识别)有专门规则
4. 工具定义规范
GPT 的工具定义示例:
namespace file_search {
// Tool for browsing the files uploaded by the user
// To use this tool, set the recipient as `to=file_search.msearch`
type msearch = (_: {
queries?: string[];
time_frame_filter?: {
start_date: string;
end_date: string;
};
}) => any;
}
Claude Code 的工具定义:
## Tool Usage Policy
- When doing file search, prefer to use the Agent tool
in order to reduce context usage.
- If you intend to call multiple tools and there are
no dependencies between the calls, make all of the
independent calls in the same function_calls block.
设计启示:
- 工具用 TypeScript 风格定义接口,清晰准确
- 包含使用建议和最佳实践
- 说明工具间的依赖关系和调用策略
GPT vs Claude 设计哲学对比
| 维度 | GPT | Claude |
|---|---|---|
| 工具描述 | TypeScript namespace 风格 | 自然语言 + 结构化列表 |
| 安全策略 | 内置 guardian_tool | 直接在 prompt 中声明 |
| 引用格式 | 【3:13†source】 复杂格式 | <cite index="..."> XML 标签 |
| 个性设定 | Personality: v2 版本号 | 详细风格描述 |
| 工具优先级 | guardian_tool 优先 | 根据场景选择 |
GPT 的特色设计
Canvas 功能(canmore 工具):
# The `canmore` tool creates and updates textdocs
# shown in a "canvas" next to the conversation
ONLY use if you are 100% SURE the user wants to
iterate on a long document or code file.
代码预览支持:
Types "code/react" and "code/html" can be previewed.
Default to "code/react" if the user asks for code
meant to be previewed (eg. app, game, website).
Claude 的特色设计
记忆功能(Past Chats):
Claude has 2 tools to search past conversations:
- conversation_search: Topic/keyword-based search
- recent_chats: Time-based retrieval (1-20 chats)
Trigger patterns:
- Explicit: "continue our conversation about..."
- Temporal: "what did we talk about yesterday"
- Implicit: "you suggested", "the bug", "help me fix it"
引用规范:
EVERY specific claim should be wrapped in <cite> tags:
<cite index="DOC_INDEX-SENTENCE_INDEX">claim</cite>
CRITICAL: Claims must be in your own words,
never exact quoted text.
Claude Code System Prompt 解析
Claude Code 是 Anthropic 的命令行 AI 编程助手,其 System Prompt 是 Agent 设计的典范。
核心设计原则
1. 极简输出
IMPORTANT: You should minimize output tokens as much as
possible while maintaining helpfulness, quality, and accuracy.
Keep your responses short. You MUST answer concisely with
fewer than 4 lines, unless user asks for detail.
Examples:
user: 2 + 2
assistant: 4
user: what files are in src/?
assistant: [runs ls] src/foo.c, src/bar.c
2. 主动性边界
You are allowed to be proactive, but only when the
user asks you to do something.
Balance between:
1. Doing the right thing when asked
2. Not surprising the user with actions you take without asking
NEVER commit changes unless the user explicitly asks.
3. 代码规范意识
When making changes to files, first understand the
file's code conventions. Mimic code style, use existing
libraries and utilities, and follow existing patterns.
NEVER assume that a given library is available.
First check that this codebase already uses the given library.
CLAUDE.md 记忆机制
If the current working directory contains a file called
CLAUDE.md, it will be automatically added to your context.
This file serves multiple purposes:
1. Storing frequently used bash commands
2. Recording the user's code style preferences
3. Maintaining useful information about the codebase
设计启示:
- 让用户可以定制 AI 的行为
- 项目级配置,比全局设置更灵活
- 自然语言配置,降低使用门槛
设计模式总结
从以上分析中,我们可以提炼出以下 System Prompt 设计模式:
模式 1: 清晰的能力边界
✅ "You CAN do X, Y, Z"
✅ "You CANNOT / MUST NOT do A, B, C"
❌ "Try to avoid..." (模糊)
模式 2: 示例驱动
✅ 提供 input/output 示例
✅ 展示正确和错误的对比
❌ 只给抽象描述
模式 3: 优先级声明
✅ "IMPORTANT:", "CRITICAL:", "NEVER:"
✅ 明确工具选择的优先级
❌ 所有规则平级罗列
模式 4: 场景化指导
✅ "When X happens, do Y"
✅ "If user asks about X, first check Y"
❌ 泛泛而谈
📚 延伸阅读:完整的 System Prompts 原文可在课程资源中下载。建议边读原文边对照本章解析,加深理解。