System Prompt Comparison
Claude CLI (Claude Code)
The Claude CLI uses a modular system prompt architecture with a ~269-token base prompt, with additional context conditionally loaded: | Component | Description | Loading | |-----------|-------------|---------|| | Base System Prompt | Core instructions and behavior | Always (~269 tokens) | | Tool Instructions | 18+ builtin tools (Write, Read, Edit, Bash, TodoWrite, etc.) | Always | | Coding Guidelines | Code style, formatting rules, security practices | Always | | Safety Rules | Refusal rules, injection defense, harm prevention | Always | | Response Style | Tone, verbosity, explanation depth, emoji usage | Always | | Environment Context | Working directory, git status, platform info | Always | | Project Context | CLAUDE.md content, settings, hooks configuration | Conditional | | Subagent Prompts | Plan mode, Explore agent, Task agent | Conditional | | Security Review | Extended security instructions (~2,610 tokens) | Conditional |Key Characteristics
Key Characteristics
- Modular architecture with 110+ system prompt strings loaded conditionally
- Base prompt is modest (~269 tokens), total varies by features activated
- Includes extensive security and injection defense layers
- Automatically loads CLAUDE.md files in the working directory
- Session-persistent context in interactive mode
Claude Agent SDK
The Agent SDK uses a minimal system prompt by default containing: | Component | Description | Token Impact | |-----------|-------------|--------------|| | Essential Tool Instructions | Only tools explicitly provided | Minimal | | Basic Safety | Minimal safety instructions | Minimal |Key Characteristics
Key Characteristics
- No coding guidelines or style preferences by default
- No project context unless explicitly configured
- No extensive tool descriptions
- Requires explicit configuration to match CLI behavior
What Each Interface Sends
Example: “What is the capital of Norway?”
- Via Claude CLI
- Via SDK (Default)
- Via SDK (with preset)
Customization Methods
Claude CLI Customization
Agent SDK Customization
Configuration Comparison
| Feature | CLI Default | SDK Default | SDK with Preset | |---------|-------------|-------------|-----------------|| | Tool instructions | ✅ Full | ❌ Minimal | ✅ Full | | Coding guidelines | ✅ Yes | ❌ No | ✅ Yes | | Safety rules | ✅ Yes | ❌ Basic | ✅ Yes | | CLAUDE.md auto-load | ✅ Yes | ❌ No | ❌ No* | | Project context | ✅ Automatic | ❌ No | ❌ No* |*Requires explicit
settingSources: ["project"] configurationOutput Consistency Guarantees
Factors Preventing Identical Output
| Factor | Description | Controllable? | |--------|-------------|---------------|| | Different system prompts | CLI vs SDK have different defaults | ✅ Yes (with configuration) | | Floating-point arithmetic | Parallel hardware quirks | ❌ No | | MoE routing | Mixture-of-Experts architecture variations | ❌ No | | Batching/scheduling | Cloud infrastructure differences | ❌ No | | Numeric precision | Inference engine variations | ❌ No | | Model snapshots | Version updates/changes | ❌ No |Temperature and Sampling
Even withtemperature=0.0 (greedy decoding):
- Full determinism is NOT guaranteed
- Minor variations can still occur due to infrastructure factors
- Known bug: Claude CLI produces non-deterministic output for identical inputs
Achieving Maximum Consistency
To get the closest possible identical outputs between SDK and CLI:Practical Implications
When to Use Each Interface
Design Recommendations
Don't rely on bit-perfect reproducibility
Don't rely on bit-perfect reproducibility
- Build applications robust to minor output variations
- Use structured outputs and validation
For production pipelines requiring consistency
For production pipelines requiring consistency
- Cache results when possible
- Use structured outputs with JSON schema validation
- Combine with deterministic logic and validation
- Consider multiple generations with consensus
For matching CLI behavior in SDK
For matching CLI behavior in SDK
System Prompt Token Impact
Note: Claude Code uses a modular architecture with 110+ system prompt strings. The base prompt is ~269 tokens, with individual components ranging from 18 to 2,610 tokens depending on features activated.Implication: The SDK’s minimal default gives you more context for your actual task, but at the cost of Claude Code’s full capabilities.
Summary
Q: What system prompts accompany the same message in SDK vs CLI?
Q: What system prompts accompany the same message in SDK vs CLI?
The CLI uses a modular system prompt architecture with a ~269-token base prompt and 110+ conditionally-loaded components (tool instructions, coding guidelines, safety rules, project context). The SDK uses a minimal default with only essential tool instructions, though it can be configured to match CLI behavior using the
claude_code preset.Q: Is there a guarantee of identical output?
Q: Is there a guarantee of identical output?
No. Even with matching system prompts, identical inputs, and
temperature=0, there is no guarantee of identical outputs due to:- Absence of a seed parameter in Claude’s API
- Floating-point arithmetic variations
- Infrastructure-level non-determinism
- Model architecture (Mixture-of-Experts) routing variations
Sources
- Modifying System Prompts - Agent SDK
- Claude Code CLI Reference
- Claude Code Headless Mode
- Claude Code Best Practices - Anthropic Engineering
- Claude Messages API Reference
- GitHub Issue #3370: Non-deterministic output
- Claude Code System Prompts Repository
- Why Deterministic Output from LLMs is Nearly Impossible
