Chapter 17
17 / 50

System Prompt Case Studies

⏱️ 30 min

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.

📚 Related resources

Common questions

Open a question to review the practical answer.

What's the biggest stylistic difference between Anthropic, OpenAI, and Google system prompts?

Three different routes. Anthropic Claude bets on safety-first: RLHF + Constitutional AI + NEVER/ALWAYS keywords drawing red lines + CLAUDE.md letting users customize Agent behavior. OpenAI GPT bets on tools-first: TypeScript Namespace tool definitions, Function Calling, explicit Allowed/Not Allowed lists (banking transfers forbidden, etc). Google Gemini bets on workflow-first: a five-step Understand → Plan → Implement → Verify (Tests) → Verify (Standards) flow, stressing "NEVER assume" — analyze existing code before changing anything.

How does xAI Grok's Persona system engineer extreme personalization?

Grok offers a swappable persona suite: Companion, Unhinged Comedian, Loyal Friend, Homework Helper, Not a Doctor / Not a Therapist. Each persona has its own style rules — Loyal Friend, for example, demands: lowercase writing (except for emphasis), abbreviations like rn/ur/bc, sparse commas, no assumptions about the friend's gender, matching the user's profanity level (only curse if they curse). This level of style-rule granularity is an extreme example of "using system prompts to engineer a consistent personality" — and the reference template for social AI apps.

How does Perplexity's system prompt enforce up-to-date search results?

Perplexity hardcodes it in the prompt: any follow-up that "might also require fresh details" forces a new search_web call, never assume previous results are still valid; any uncertainty triggers a re-search. Verbatim: "Always verify with a new search to ensure accuracy if there's any uncertainty." The rule shifts "cached = stale" judgment from engineering to the prompt layer — the model decides per turn whether to re-search, more flexible than hardcoded refresh logic. The core pattern for search-style AI apps.

Which is better — OpenAI's TypeScript Namespace or Anthropic's XML tool definitions?

Neither is universally better — depends on context. OpenAI's `namespace file_search { type msearch = (_: { queries?: string[]; }) => any; }` uses TS types to constrain params — instantly familiar to JS/TS engineers, and IDEs can autocomplete. Anthropic's XML format (`<tool_definition>...</tool_definition>`) handles nested structures and explanatory text better. Grok also uses XML Function Call. Rule of thumb: JS/TS teams prefer namespace, Python or polyglot teams prefer XML — but models are trained on both, and the gap matters far less than how clearly the description is written.

Which company's system prompt should I copy as a reference for my own AI app?

Match by use case: code assistants — copy Claude Code + Gemini CLI (one for minimal output style, one for the verification workflow). Search apps — copy Perplexity (freshness strategy). Chatbots — copy Grok Personas (style-rule granularity). Browser automation / Agent Mode — copy OpenAI (tool definitions + message channels). High-security enterprise apps — copy Claude (NEVER/ALWAYS + safety boundaries). Compose by section: Identity → Tools → Constraints → Output — each section has a ready template you can lift and adapt.