← Claude Docs

Modifying system prompts - Claude Code Docs

Claude Docs · April 15, 2026
The Claude Agent SDK provides multiple methods for customizing system prompts that define Claude's behavior, capabilities, and response style. CLAUDE.md files offer persistent project-level instructions that serve as version-controlled team memory, while output styles provide reusable saved configurations and developers can append custom instructions to preserve built-in functionality or use entirely custom system prompts for complete control. Each approach involves different tradeoffs regarding persistence, reusability, and customization level.

Detailed Analysis

Anthropic's Claude Agent SDK documentation outlines four distinct methods for customizing system prompts within Claude Code, offering developers a structured hierarchy of configuration options that balance flexibility with built-in safety guarantees. The four approaches — CLAUDE.md files, output styles, appending to the existing system prompt, and fully custom system prompts — each occupy a different point on the tradeoff spectrum between convenience, persistence, reusability, and control. CLAUDE.md files function as version-controlled, project-level instruction sets that Claude reads automatically when properly configured via `settingSources`, making them ideal for team-shared conventions, coding standards, and recurring commands. Output styles, stored as markdown files, provide reusable configurations that can persist across multiple projects. The `systemPrompt` with `append` approach preserves all built-in tooling while layering custom instructions, and the fully custom `systemPrompt` option grants complete control at the cost of losing default tools, safety guardrails, and environmental context unless those are manually reintroduced.

A particularly significant technical development documented in this release is the introduction of `excludeDynamicSections` (TypeScript) and `exclude_dynamic_sections` (Python), a flag designed to improve prompt caching across distributed or multi-agent deployments. By default, Claude Code's system prompt embeds per-session variables — working directory, platform details, current date, git status, and auto-memory paths — which means any two sessions running from different directories will produce different system prompts and thus miss shared cache entries. Setting `excludeDynamicSections: true` moves this per-session context into the first user message instead, leaving a static, cacheable system prompt that can be reused across machines and users. The tradeoff is a marginal reduction in the authoritative weight Claude assigns to environmental context, since instructions in the user message carry slightly less influence than those in the system prompt. This option is explicitly positioned for fleet deployments where cache reuse outweighs the need for maximally authoritative environment context.

The documentation reflects a broader trend in enterprise AI tooling toward fine-grained, programmable control over model behavior at the infrastructure level. The explicit comparison table — covering persistence, reusability, default tool preservation, built-in safety, and version control — signals that Anthropic is deliberately positioning the SDK for professional and organizational use cases where governance, reproducibility, and team coordination are first-class concerns. The warning that fully custom system prompts lose built-in safety instructions unless explicitly re-added is a notable design choice, indicating that Anthropic treats safety as a default-on feature that developers must consciously opt out of, rather than something layered on top after the fact.

This documentation also reveals the growing complexity of agentic AI deployments, where multiple Claude instances may run simultaneously across different environments, directories, and machines. The prompt caching feature specifically addresses the operational cost implications of large-scale agent fleets, where redundant prompt processing across identical configurations would create unnecessary inference overhead. The fact that Anthropic is engineering solutions for cross-session cache sharing suggests that production Claude Code deployments are increasingly distributed in nature, and that infrastructure efficiency — not just model capability — is a competitive concern in the agentic coding assistant market.

The relationship between CLAUDE.md and the SDK's `settingSources` configuration underscores an important architectural distinction: Claude Code's autonomous behavior in standalone interactive use differs meaningfully from its behavior when invoked programmatically through the Agent SDK. Developers using the SDK cannot assume that project-level CLAUDE.md files will be automatically loaded without explicitly configuring the appropriate setting sources, a deliberate separation that preserves predictability in automated pipelines. This design philosophy — explicit configuration over implicit convention in programmatic contexts — aligns with how serious engineering organizations manage configuration in CI/CD systems and other automated workflows, signaling that Anthropic is actively engineering Claude Code to meet professional software development infrastructure standards rather than remaining solely a developer convenience tool.

Read original article →