Anatomy of System Prompts
Core Components of System Prompts
Every production system prompt follows a structural pattern. After analyzing 36+ AI tools, we've identified the universal components that appear across all of them.
The Seven Core Sections
1. Identity & Role Definition
This section establishes who the AI is and its primary purpose:
You are Claude Code, Anthropic's official CLI for Claude.
You are an interactive CLI tool that helps users with
software engineering tasks.
Pattern observed across tools:
- Cursor: "You are a helpful AI coding assistant"
- Windsurf Cascade: "You are Cascade, Windsurf's AI assistant"
- Devin: "You are Devin, an AI software engineer"
2. Capability Boundaries
Defines what the AI can and cannot do:
You can:
- Read and write files
- Execute terminal commands
- Search codebases
- Make API calls
You cannot:
- Access the internet without explicit tools
- Execute code outside sandboxes
- Modify system files
3. Tool Definitions
Production prompts include detailed tool specifications:
# Tool definition pattern from Claude Code
- name: "Read"
description: "Reads a file from the filesystem"
parameters:
file_path:
type: string
required: true
offset:
type: number
description: "Line number to start from"
4. Behavioral Guidelines
Instructions for how the AI should interact:
Guidelines:
- Be concise and direct
- Ask clarifying questions when requirements are ambiguous
- Prefer editing existing files over creating new ones
- Always explain your reasoning before taking action
5. Output Format Specifications
Defines expected response structure:
Response Format:
- Use markdown for code blocks
- Include file paths when referencing code
- Structure complex responses with headers
- Keep explanations brief unless asked for detail
6. Safety Constraints
Defensive rules to prevent misuse:
IMPORTANT: Never:
- Generate malicious code
- Expose API keys or credentials
- Execute destructive commands without confirmation
- Bypass security restrictions
7. Context Injection Points
Dynamic sections populated at runtime:
<environment>
Working directory: {{cwd}}
Platform: {{platform}}
Current time: {{timestamp}}
User permissions: {{permissions}}
</environment>
Real-World Example: Dissecting a Prompt
Here's a simplified structure from a production coding assistant:
[IDENTITY]
You are an AI coding assistant integrated into {{IDE_NAME}}.
[CAPABILITIES]
Available tools: file_read, file_write, terminal, search
[CONTEXT]
<codebase_context>
{{relevant_files}}
</codebase_context>
[GUIDELINES]
1. Understand before acting
2. Preserve existing code style
3. Test changes when possible
[CONSTRAINTS]
- Maximum response: 4000 tokens
- File edit limit: 10 files per request
- No external network calls
[OUTPUT FORMAT]
Respond in this structure:
1. Analysis (what you understand)
2. Plan (what you'll do)
3. Implementation (the actual changes)
Token Budget Allocation
Production prompts carefully allocate their token budget:
| Section | Typical % | Purpose |
|---|---|---|
| Identity & Role | 5% | Establish persona |
| Tool Definitions | 25% | Enable capabilities |
| Behavioral Guidelines | 15% | Shape interactions |
| Safety Constraints | 10% | Prevent misuse |
| Dynamic Context | 30% | Runtime information |
| Examples | 15% | Demonstrate patterns |
Pro Tip: The most effective prompts front-load critical constraints and identity, then use the remaining space for context and examples.
Common Structural Patterns
Pattern 1: Layered Instructions
[Core Identity] → [Capabilities] → [Guidelines] → [Constraints]
Pattern 2: XML-Structured Sections
<system>
<identity>...</identity>
<tools>...</tools>
<rules>...</rules>
</system>
Pattern 3: Markdown Headers
# Role
## Tools
## Guidelines
## Constraints
Next, we'll examine how different AI companies structure their identity and persona sections differently. :::