15

System Prompt Case Studies

⏱️ 30 min

System Prompt Case Library

A collection of real system prompt designs from major AI companies. Study these cases to understand industry best practices, then apply them to your own AI Agent development.


Case Overview

CompanyProductCore FeatureLearning Value
AnthropicClaude.ai, Claude CodeRLHF safety design, multi-roleAgent safety boundary design
OpenAIGPT-4o, Agent ModeFunction Calling, message channelsTool calling conventions
GoogleGemini CLI, Guided LearningProject conventions, workflowsCode agent best practices
xAIGrok 3/4, PersonasPersona system, X platform integrationPersonalized role design
OthersPerplexity, Kagi, RaycastSearch strategies, format specsVertical domain design

Anthropic Claude

Claude.ai & Claude Code

Core design philosophy: Safe, helpful, honest

Key features:

  • RLHF safety mechanisms: Constitutional AI design
  • CLAUDE.md configuration: Users can customize agent behavior
  • Tool specifications: Detailed Tool Use constraints
  • Multi-role switching: Adapts to different scenarios via system prompt

Best suited for:

  • Coding assistant development
  • Long document processing
  • Applications requiring high safety

Typical design pattern:

You are Claude, made by Anthropic...
You can use tools to complete tasks...
NEVER do X without explicit permission...

Deep dive into Claude System Prompts


OpenAI GPT

GPT-4o & Agent Mode

Core design philosophy: General-purpose, flexible, rich ecosystem

Key features:

  • Function Calling: TypeScript Namespace-style tool definitions
  • Message channel system: analysis / commentary / final separation
  • Financial activity restrictions: Explicit Allowed / Not Allowed lists
  • Safe browsing rules: Defense against Prompt Injection

Best suited for:

  • Browser automation
  • Complex multi-step tasks
  • Applications requiring tool calling

Typical design pattern:

namespace tools {
	type function_name = (_: { param: string }) => any;
}

Deep dive into GPT System Prompts


Google Gemini

Gemini CLI & Guided Learning

Core design philosophy: Project conventions first, workflow-driven

Key features:

  • Project conventions first: NEVER assume — analyze existing code first
  • Five-step workflow: Understand → Plan → Implement → Verify Tests → Verify Standards
  • Guided learning: Socratic teaching method
  • Self-verification loops: Emphasis on testing and standards checks

Best suited for:

  • Code agent development
  • Educational AI applications
  • Scenarios requiring strict workflows

Typical design pattern:

## Software Engineering Tasks
1. Understand: Think about the user's request...
2. Plan: Build a coherent plan...
3. Implement: Use available tools...
4. Verify (Tests): Run project tests...
5. Verify (Standards): Run linting...

Deep dive into Gemini System Prompts


xAI Grok

Grok 3/4 & Persona System

Core design philosophy: Personalization, real-time information, X platform integration

Key features:

  • Persona system: Multi-personality role switching
  • X platform integration: Native X search and analysis support
  • Render components: Dedicated citation and formatting system
  • Real-time information: No strict knowledge cutoff date

Available Personas:

  • Companion
  • Unhinged Comedian
  • Loyal Friend
  • Homework Helper
  • Not a Doctor / Not a Therapist

Best suited for:

  • Social media applications
  • Personalized chatbots
  • Applications requiring real-time information

Typical design pattern:

You are Grok, a [personality] chatbot...

## Style Rules:
- match the user's vulgarity
- always write in lowercase
- use abbreviations like rn ur bc

Deep dive into Grok System Prompts


Other AI Products

Perplexity, Kagi, Raycast AI

Three products, three distinct approaches:

ProductPositioningCore Design
PerplexityAI search engineReal-time search strategy, voice interaction specs
Kagi AssistantPremium search assistantMost detailed format specification system
Raycast AIDesktop productivity toolUser system preference injection

Learning value:

  • Perplexity: How to design search-oriented AI (re-search on every follow-up)
  • Kagi: How to design detailed output format specifications
  • Raycast: How to integrate user system preferences (language, timezone, units)

Deep dive into other AI product System Prompts


Design Pattern Comparison

From these cases, we can distill several core design patterns:

1. Identity Definition Patterns

CompanyStyle
Claude"You are Claude, made by Anthropic"
GPT"You are ChatGPT, a large language model..."
Grok"You are Grok, a [persona] chatbot..."

2. Tool Definition Patterns

CompanyStyle
OpenAITypeScript Namespace
AnthropicXML-format Tool Definition
GrokXML Function Call

3. Safety Boundary Patterns

CompanyApproach
ClaudeNEVER / ALWAYS keywords
GPTAllowed / Not Allowed lists
GrokBoundaries (Never Do) sections

How to Apply These Cases

1. Choose a Reference Template

Pick the best reference based on your use case:

  • Coding assistant → Reference Claude Code, Gemini CLI
  • Search application → Reference Perplexity
  • Chatbot → Reference Grok Personas
  • Browser automation → Reference GPT Agent Mode

2. Reuse Design Patterns

Directly reuse proven design patterns:

SYSTEM_PROMPT = """
# Identity (reference: Claude)
You are [Your Agent Name], a [role] assistant.

# Tools (reference: OpenAI)
You have access to the following tools...

# Constraints (reference: Grok)
## Boundaries (Never Do):
- Never do X without permission
- Never share Y information

# Output (reference: Kagi)
Format your response with proper markdown...
"""

3. Iterate and Optimize

  1. Start with a simple version
  2. Observe agent behavior
  3. Gradually add constraints and examples
  4. Test edge cases
  5. Refine safety boundaries

Further Reading


These cases all come from real products, showing how top companies approach system prompt design. Study them, then develop your own style.

📚 相关资源

❓ 常见问题

关于本章主题最常被搜索的问题,点击展开答案

Anthropic、OpenAI、Google 三家在 system prompt 风格上最大的差异是什么?

三家走三条路。Anthropic Claude 走 "安全优先":RLHF + Constitutional AI + 用 NEVER / ALWAYS 关键词划红线 + CLAUDE.md 让用户定制 Agent 行为。OpenAI GPT 走 "工具优先":TypeScript Namespace 定义工具、Function Calling、明确的 Allowed / Not Allowed 列表(如 banking transfers 禁止)。Google Gemini 走 "工作流优先":Understand → Plan → Implement → Verify Tests → Verify Standards 五步流程,强调 "NEVER assume",先看现有代码再动手。

xAI Grok 的 Persona 系统是怎么设计极端个性化的?

Grok 提供多套 persona 切换:Companion、Unhinged Comedian、Loyal Friend、Homework Helper、Not a Doctor / Not a Therapist。每个 persona 独立的语言风格规则 —— 比如 Loyal Friend 要求:lowercase 写作(除强调外)、用缩写如 rn / ur / bc、逗号少、不假设朋友性别、match 用户的脏话级别(用户骂才骂)。这种细粒度 style rules 是 "用 system prompt 创造一致人格" 的极端样本,也是社交类 AI 应用的参考模板。

Perplexity 怎么用 system prompt 保证搜索结果的时效性?

Perplexity 在 prompt 里明确写:每次用户追问 "that might also require fresh details" 都必须重新调 search_web,不能假设之前的搜索结果还能用;遇到任何不确定都重搜一次。原文是 "Always verify with a new search to ensure accuracy if there's any uncertainty." 这条规则把 "缓存即过时" 的判断权从工程层下放到 prompt 层 —— 模型每一轮都自己决定要不要重搜,比写硬规则更灵活。这是搜索型 AI 应用的核心设计模式。

OpenAI 的 TypeScript Namespace 和 Anthropic 的 XML 工具定义哪种更好?

没有绝对更好,看场景。OpenAI 的 `namespace file_search { type msearch = (_: { queries?: string[]; }) => any; }` 用 TS 类型给参数划约束,对前端工程师来说极其熟悉,IDE 都能补全。Anthropic 的 XML 格式(`<tool_definition>...</tool_definition>`)更适合需要嵌套结构和说明文本的场景。Grok 也用 XML Function Call。规则:JS / TS 团队优先 namespace,Python / 多语言混合环境优先 XML —— 但模型对两种格式都训练过,差距远小于 description 写得清不清楚的影响。

想给自己的 AI 应用挑一个参考 system prompt,该照哪家学?

按场景对号入座:代码助手抄 Claude Code + Gemini CLI(一个学输出极简,一个学验证流程);搜索类应用抄 Perplexity(学时效性策略);聊天机器人抄 Grok Persona(学个性化风格规则);浏览器自动化 / Agent Mode 抄 OpenAI(学工具定义和消息通道);高安全性企业应用抄 Claude(学 NEVER / ALWAYS + 安全边界)。复用模式时按 Identity → Tools → Constraints → Output 四段拼装,每段都有现成模板可直接改。