Anthropic Claude System Prompts
Deep dive into Claude.ai and Claude Code System Prompts
Anthropic leads the AI safety space. Their Claude models are known for safety-first design and long-context handling. This chapter takes apart Claude's System Prompt design.
Claude Product Line
| Product | Positioning | System Prompt Highlights |
|---|---|---|
| Claude.ai | General AI assistant | Conversation mgmt, memory search, citations |
| Claude Code | CLI coding assistant | Minimal output, tool spec, code conventions |
| Claude API | Developer interface | Flexible system message |
Claude.ai System Prompt Core Design
1. Past Conversation Memory System
Claude has dedicated tools for searching chat history:
Claude has 2 tools to search past conversations:
- conversation_search: Topic/keyword-based search
- recent_chats: Time-based retrieval (1-20 chats)
Trigger pattern detection:
Always use past chats tools when you see:
Explicit references:
- "continue our conversation about..."
- "what did we discuss..."
- "as I mentioned before..."
Temporal references:
- "what did we talk about yesterday"
- "show me chats from last week"
Implicit signals:
- Past tense verbs: "you suggested", "we decided"
- Definite articles: "the bug", "the strategy"
- Pronouns without antecedent: "help me fix it"
Design takeaways:
- The AI needs to read implicit intent, not just explicit commands
- Trigger word detection is smarter than waiting for explicit commands
- Time references and topic references route to different tools
2. Citation System
Claude has strict formatting requirements for information citations:
EVERY specific claim should be wrapped in <cite> tags:
<cite index="DOC_INDEX-SENTENCE_INDEX">claim</cite>
If a claim is supported by multiple sections:
<cite index="DOC_INDEX-START:END,DOC_INDEX-START:END">...</cite>
CRITICAL: Claims must be in your own words,
never exact quoted text. The citation tags are
for attribution, not permission to reproduce.
Correct vs incorrect:
Search result: "The move was a delight and a revelation"
✅ Correct:
<cite index="...">The reviewer praised the film enthusiastically</cite>
❌ Incorrect:
<cite index="...">"a delight and a revelation"</cite>
Design takeaways:
- Citations are for attribution, not reproduction
- Forced paraphrasing reduces copyright issues
- Structured format makes programmatic parsing straightforward
3. Response Style Guide
Response guidelines:
- Never claim lack of memory
- Acknowledge when drawing from past conversations naturally
- Synthesize information naturally, don't quote snippets directly
- Prioritize current context over past if contradictory
- Do not use xml tags in response unless user explicitly asks
Claude Code System Prompt Deep Dive
Claude Code is Anthropic's official CLI coding assistant. Its System Prompt is a masterclass in Agent design.
Core Design Principles
1. Identity + Dynamic Environment Injection
You are an interactive CLI tool that helps users
with software engineering tasks.
<env>
Working directory: /Users/john/project
Is directory a git repo: Yes
Platform: darwin
Today's date: 2025-01-15
Model: claude-sonnet-4
</env>
Design takeaways:
- Clear role positioning: CLI tool, not a general assistant
- Dynamic info injection: working directory, platform, date
- Makes the AI context-aware of its runtime environment
2. Minimal Output Control
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 of appropriate verbosity:
user: 2 + 2
assistant: 4
user: what command should I run to list files?
assistant: ls
user: what files are in src/?
assistant: [runs ls] src/foo.c, src/bar.c
Design takeaways:
- CLI contexts demand terse output
- Concrete examples define expected behavior better than rules
- Show, don't tell
3. Proactivity Boundary Control
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.
Design takeaways:
- Agent proactivity needs explicit boundaries
- High-risk operations (git commit) require explicit authorization
- Prevents the AI from "going rogue"
4. Code Convention Awareness
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.
Design takeaways:
- Understand existing code before making changes
- Follow the project's established style
- Don't assume library availability
5. CLAUDE.md Configuration Mechanism
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
Design takeaways:
- Lets users customize AI behavior
- Project-level config is more flexible than global settings
- Natural language configuration keeps the barrier low
Tool Usage Strategy
## 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.
Design takeaways:
- Tool selection has priority ordering
- Independent tools should be called in parallel
- Context window optimization matters
Anthropic's Design Philosophy
Safety First
IMPORTANT: Refuse to write code that may be used maliciously;
even if the user claims it is for educational purposes.
Before you begin work, think about what the code you're
editing is supposed to do based on the filenames directory
structure. If it seems malicious, refuse to work on it.
Transparent Honesty
Engage warmly yet honestly with the user.
Be direct; avoid ungrounded or sycophantic flattery.
Maintain professionalism and grounded honesty.
User Control
- CLAUDE.md lets users customize behavior
- High-risk operations need confirmation
- Proactivity has clear boundaries
Practical Application
Building Your Agent with Claude's Design
1. Environment awareness template:
SYSTEM_PROMPT = f"""
You are [Agent Name], a [Role Type].
<context>
Current directory: {os.getcwd()}
Platform: {sys.platform}
Timestamp: {datetime.now().isoformat()}
</context>
"""
2. Output control template:
OUTPUT_RULES = """
Keep responses under 3 lines for simple queries.
Use bullet points for lists.
Examples:
user: status
assistant: All systems operational. 3 tasks pending.
"""
3. Proactivity boundary template:
AUTONOMY_RULES = """
You MAY:
- Read files and search codebase
- Suggest changes
You MUST ASK before:
- Modifying files
- Running destructive commands
- Making external API calls
"""
The complete Claude Code System Prompt is available in the course resources. Read it line by line -- every single rule has a design rationale behind it.