Skills
KV Cache Sharing for Subagent Parallelism: Spawn 5 Subagents for the Cost of 1 via Byte-Identical Context Forking
The Claude Code source leak reveals that subagents are created as byte-identical copies of the parent context, sharing the KV cache. With Anthropic's prompt caching pricing cached input tokens at 90% less than regular tokens, the shared prefix between parent and subagents is nearly free—spawning 5 subagents costs barely more than spawning 1. The architecture separates static prompt content (SYSTEM_PROMPT_DYNAMIC_BOUNDARY) from dynamic context to maximize cache hit rates. Builders can replicate this by structuring their own agent systems with identical system prompt prefixes and unique-only suffixes per subagent.
Source
↳ Follow the thread