Skip to main content
When sending the same message through the Claude Agent SDK versus the Claude CLI (Claude Code), the system prompts accompanying these messages are fundamentally different. There is no guarantee of identical output between the two, even with matching configurations, due to the absence of a seed parameter and inherent non-determinism in Claude’s architecture.

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 |
  • 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 |
  • 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?”

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"] configuration

Output Consistency Guarantees

Critical Finding: NO Determinism GuaranteedThe Claude Messages API does not provide a seed parameter for reproducibility. This is a fundamental architectural limitation.

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 with temperature=0.0 (greedy decoding):

Achieving Maximum Consistency

To get the closest possible identical outputs between SDK and CLI:
Still Not GuaranteedEven with perfectly matching configurations:
  • Output may differ between runs
  • Output may differ between SDK and CLI
  • No seed parameter exists to force reproducibility

Practical Implications

When to Use Each Interface

Design Recommendations

  • Build applications robust to minor output variations
  • Use structured outputs and validation
  • Cache results when possible
  • Use structured outputs with JSON schema validation
  • Combine with deterministic logic and validation
  • Consider multiple generations with consensus

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

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.
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
Recommendation: Design systems to be robust to output variations rather than relying on deterministic behavior. For consistency-critical applications, use structured outputs, caching, and validation layers.

Sources