In March 2026, Anthropic shipped a 59.8 megabyte source map inside the Claude Code npm package. It contained 512,000 lines of TypeScript. The community found it, read it, and dissected it. The most important discovery was not an unreleased feature or an internal codename. It was a single constant: SYSTEMPROMPTDYNAMIC_BOUNDARY.

This boundary splits Claude Code's system prompt into two halves. Everything before it is static and cached globally. Everything after it is dynamic and assembled per session. The best prompt engineering team in the industry does not write one static system prompt. They compose it, module by module, with cache-aware architecture engineered into the design.

This leak validates what many production agent builders already suspected. Modular system prompts are not a nice-to-have. They are how production agents work at scale.

The Leak

Claude Code is Anthropic's official agentic coding tool. In March 2026, a source map meant for internal debugging shipped with the public npm package. Source maps map minified code back to original TypeScript. This one mapped everything.

The community extracted the code, built documentation sites, and started reading. Within weeks, sites like claude-code-explain.helmcode.com and repositories like Piebald-AI/claude-code-system-prompts were publishing detailed breakdowns of the architecture.

The most interesting discovery was the system prompt assembly logic.

The SYSTEMPROMPTDYNAMIC_BOUNDARY Pattern

Claude Code's system prompt is not a single string. It is assembled by getSystemPrompt() in src/constants/prompts.ts and then processed by buildEffectiveSystemPrompt(). The assembly follows a 6-layer priority hierarchy and includes 7 distinct content sections. But the key architectural decision is the boundary marker.

The marker SYSTEMPROMPTDYNAMIC_BOUNDARY splits the prompt into two halves with different caching behavior.

Before the boundary: static and globally cached.

This half contains the core identity and behavioral rules. It is the same for every organization on every request. Anthropic's infrastructure caches it globally. The sections are:

  • Intro: Defines Claude as an interactive software engineering agent, including the security policy and the no-URL-guessing rule.
  • System: Output rendering rules, permission mode mechanics, and how to handle denied tool calls and prompt injection in tool results.
  • Doing Tasks: Engineering task rules like "read before proposing changes," "prefer editing over creating," and "no premature abstractions."
  • Executing Actions with Care: Risk classification for actions. Local reversible actions are free. Hard-to-reverse actions require confirmation.
  • Using Tools: Dedicated tool preferences and parallel tool call guidance.
  • Tone and Style: No emojis, short responses for external users, filepath:linenumber format for code citations.
  • Output Efficiency: Rules for concision, including explicit word-count caps for inter-tool text.

After the boundary: dynamic and session-specific.

This half changes on every call. It is not globally cacheable. The sections include:

  • Session-specific guidance and rules
  • Memory from MEMORY.md and memory files
  • Environment context like current working directory, platform, and model
  • Language preference
  • Output style if configured
  • MCP instructions (always uncached because servers can connect or disconnect between turns)
  • Scratchpad directory if enabled
  • Function result clearing if micro-compaction is active

The boundary is not decorative. It is a cost and latency optimization. Static content gets cached across millions of requests. Dynamic content gets assembled fresh per session. The model sees both halves as one prompt, but the infrastructure treats them differently.

The Priority Hierarchy

Claude Code's prompt assembly also uses a 6-layer priority system. Higher layers replace everything below them.

  1. Override prompt: Replaces the entire system prompt. Used for special modes like Simple Mode.
  2. Coordinator prompt: Active in multi-agent coordinator mode.
  3. Agent prompt: Replaces the default prompt when running as a sub-agent.
  4. Custom prompt: Injected via the --system-prompt CLI flag.
  5. Default prompt: The standard system prompt with all built-in behavioral rules.
  6. Append prompt: Always added at the end. Carries dynamic context like memory and environment info.

This hierarchy means the system prompt is not just modular within a session. It is also modular across session types. A sub-agent gets a different prompt than the main agent. A coordinator gets a different prompt than a worker. The same codebase serves multiple prompt configurations through the same assembly pipeline.

What the Leak Reveals About Anthropic's Approach

Three things stand out from the leaked code.

First, even Anthropic composes its system prompt. The team that builds Claude does not write one perfect static prompt and call it done. They treat the system prompt as production code with versioned sections, conditional assembly, and cache-aware boundaries. Internal comments reference A/B tests on concision, measuring a 1.2 percent output token reduction from explicit rules versus vague ones like "be concise." The system prompt is actively maintained, tested, and optimized.

Second, prompt caching is a first-class architectural concern. The SYSTEMPROMPTDYNAMIC_BOUNDARY exists because Anthropic operates at a scale where prompt caching matters in the bill. The static half is cached globally. The dynamic half is assembled per call. MCP instructions are explicitly uncached because server state changes between turns. This is not an afterthought. It is engineered into the prompt assembly logic.

Third, the CLAUDE.md file is part of the default prompt layer. When users create a CLAUDE.md file in their project, it gets injected into the default prompt layer, not treated as a separate mechanism. This is why it has such strong influence. It sits inside the core system prompt, not as an add-on.

Why This Validates Modular System Prompts

The leak arrived at a useful moment. The production agent community had already been moving toward modular system prompts. Elliott Girard published "Modular System Prompts: How I Build Agents That Adapt to Every Session" in Towards AI on May 20, 2026, describing a 12-section prompt builder with conditional assembly, canonical ordering, and token budget enforcement. The Claude Code leak confirmed that the company building the most capable coding agent uses essentially the same pattern.

The core idea is simple. A system prompt should be the output of a function that runs every turn, not a static string written on day one. The function assembles sections based on the current state of the world: who is talking, what time it is, which tools are available, what failed last turn, and what tier the user is on.

The benefits are concrete.

Relevance. The model only sees instructions that apply to the current request. A free-tier user never sees premium-tier rules. An agent without shell access never sees shell usage guidance. A session at 3am sees behavioral guards about off-hours scheduling. The signal-to-noise ratio stays high.

Cost. Static sections get cached. Dynamic sections only get injected when needed. The token budget is tracked and enforced. Sections that would push the assembly over budget get dropped by priority.

Observability. Because the prompt is assembled from named sections, you can log which sections were active for any given turn. When the agent does something weird at 2am, you can reconstruct exactly what it saw instead of guessing which version of a monolithic prompt was in effect.

Testability. Each section can be tested independently. A guard that triggers after two tool errors can be unit-tested. A tier constraint can be verified against a mock user profile. The assembly logic stays simple because the complexity lives in the sections.

Production Implications for Agent Builders

If you are building production agents, the Claude Code leak provides a blueprint.

Order your sections with caching in mind. Put static content first and dynamic content last. If your LLM provider supports prompt caching, this maximizes cache hits. At scale, this directly reduces your API bill.

Use a boundary marker or equivalent. You do not need Anthropic's exact constant. You need a clear separation between what is global and what is per-session. Your caching layer should know which half to treat as stable.

Make sections conditional. Every section should have a prerequisite_met flag. The builder only includes sections whose conditions are true. This prevents token waste and keeps the model focused.

Track token budgets explicitly. The builder should know the approximate token count of framework-added sections and enforce a cap. When the budget is tight, the lowest-priority sections drop first.

Log every assembled prompt. When something goes wrong, the first thing you need is the exact prompt the model saw. Log the active sections and a hash of the assembled prompt so you can diff across turns and users.

Version your identity section. Even the nearly-static identity block should be versioned. When you change the agent's tone or core constraints, bump the version so you can A/B test against past runs.

When Modular Is Overkill

Not every agent needs this architecture. If your agent has a single narrow purpose, one user type, no time sensitivity, and no tiering, a static prompt may be fine. The crossover point is roughly: two or more tiers, two or more session modes, or any agent that must survive across time where "now" matters.

The test is simple. Read your system prompt and count the instructions that do not apply to the most common request your agent handles. If it is more than three, you have crossed the line into monolithic territory. A modular builder will pay for itself within a handful of interactions.

The Deeper Pattern

Modular system prompts are one instance of a broader pattern: deterministic shells around probabilistic cores. The language model is brilliant and unpredictable. The shell's job is to give it a consistent, controlled briefing for every interaction. The briefing is assembled deterministically from the current state of the world. The model handles the probabilistic reasoning inside that controlled context.

The Claude Code leak proved that this pattern is not a community workaround. It is how the best team in the industry builds its own product. The SYSTEMPROMPTDYNAMIC_BOUNDARY is not a hack. It is architecture.


Suggested title: What the Claude Code Leak Taught Us About System Prompts

Word count: ~1,650

Citations:

Fact-check notes:

  • The 59.8 MB source map figure and 512,000 lines claim come from Elliott Girard's Towards AI article. These should be verified against primary sources if possible.
  • The SYSTEMPROMPTDYNAMIC_BOUNDARY constant and 6-layer priority hierarchy are documented on claude-code-explain.helmcode.com and derived from the leaked source. These are secondary sources based on community analysis of the leak.
  • The exact token counts for Claude Code's static sections are not confirmed in this article. The Piebald-AI repository tracks these per version but was not exhaustively reviewed for this draft.
  • The claim that Anthropic's infrastructure caches the static half "globally across every organization" is an inference from the caching documentation on claude-code-explain.helmcode.com. The exact scope of Anthropic's cache segmentation is not publicly confirmed.