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
| Method | Command | Effect |
|---|---|---|
| Append to prompt | claude -p "..." --append-system-prompt "..." | Adds instructions while preserving defaults |
| Replace prompt | claude -p "..." --system-prompt "..." | Completely replaces the system prompt |
| Project context | CLAUDE.md file | Automatically loaded, persistent |
| Output styles | /output-style [name] | Apply predefined response styles |
Agent SDK Customization
| Method | Configuration | Effect |
|---|---|---|
| Custom prompt | systemPrompt: "..." | Replaces default entirely (loses tools) |
| Preset with append | systemPrompt: { type: "preset", preset: "claude_code", append: "..." } | Preserves CLI functionality + custom instructions |
| CLAUDE.md loading | settingSources: ["project"] | Loads project-level instructions |
| Output styles | settingSources: ["user"] or settingSources: ["project"] | Loads saved output styles |
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
| Use Case | Recommended Interface | Reason |
|---|---|---|
| Interactive development | Claude CLI | Full tool suite, project context |
| Programmatic integration | Agent SDK | Fine-grained control, embedding |
| Consistent API responses | Agent SDK + custom prompt | More control over system prompt |
| Batch processing | Agent SDK | Better for automation pipelines |
| One-off tasks | Claude CLI | Faster setup, immediate context |
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
| Configuration | Architecture | Notes |
|---|---|---|
| SDK (minimal) | Minimal default | Only essential tool instructions |
| SDK (claude_code preset) | Modular (~269+ base) | Matches CLI, varies by features |
| CLI (default) | Modular (~269+ base) | Additional context loaded conditionally |
| CLI (with MCP tools) | Modular + MCP | MCP tool descriptions add significant tokens |
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
