Editor's note: This is an AI-assisted English adaptation of a research note on Claude Code v2.1.220. The four-breakpoint layout and named internals come from that version-specific note, not from a current public guarantee. Where the current Claude Code docs differ, this article calls out the difference.
In Part 2, we looked at the message array an agent sends on each turn. Here’s why its layout matters: if a request changes near the top, every prefix extending past that point changes too. If the agent only appends a new exchange, most of the previous request can still be reused.
That distinction explains why a skill can arrive as a new message, why a fork can start warm, and why a change to the tool list can have a much larger cost than a new tool result.
1. A breakpoint marks the end of a prefix
The Claude API prompt caching guide describes a cumulative prefix ordered as tools → system → messages. A cache write at a marked block stores the prefix through that block. The marker is not the start of a new independent segment.
Suppose you mark two positions: one at the end of your tool definitions, another after a large project brief. If the brief changes, an existing entry ending at the tool definitions can still match, assuming it hasn’t expired and the other cache conditions are met. If a tool definition changes, neither prefix matches. There’s no separate cache entry for the brief alone.
Appending new history is different from editing old history. Suppose you cached a request through block 10, then appended five blocks and moved the breakpoint to block 15. The API can look back and reuse the write at block 10. If the previous write falls outside the API’s 20-position lookback, it won’t be found from that breakpoint. The lookback searches for existing writes; it doesn’t create entries at unmarked boundaries.
The practical rules: put stable content early, append new information where possible, and mark a reusable boundary when a section will change independently.
2. Four historical breakpoints, not four independent caches
The API allows up to four breakpoints. The v2.1.220 research note described this particular allocation:
| Position in the note | Prefix preserved when later content changes |
|---|---|
| End of the tools section | Tool definitions |
| End of the stable system section | Tools plus core system instructions |
| End of a configuration-related system section | The preceding prefix plus that configuration |
| Near the end of the submitted conversation | The reusable history sent so far |
Treat this as a historical model, not a recipe Claude Code follows on every request today. The current Claude Code caching docs explain the product in three conceptual layers: system prompt and tools, project context, and conversation. Those layers describe what changes together; they don’t specify four fixed cache_control positions.
This also explains why four is a limit, not a target. One breakpoint can suffice for a large common prefix. Add another when it protects something you actually reuse, not simply because there’s an unused slot.
3. Make the boundary explicit
The older note described an internal marker named SYSTEM_PROMPT_DYNAMIC_BOUNDARY, used to distinguish reusable system content from content that might change between requests. The current public docs don’t guarantee that marker, its placement, or the serialization that goes with it.
The implementation idea is useful without the marker. If you’re building your own agent, represent core instructions and per-request context as separate blocks. Place your breakpoint based on which blocks remain stable, rather than guessing from line counts or assuming everything under the heading “system prompt” has the same lifetime.
4. Six places where the trade-off shows up
Project instructions: don’t rewrite the copy already in context
It’s tempting to treat CLAUDE.md as product-level system text. But those rules belong to the user or project, and they can change independently of the core agent. The old note described moving them into message context with an internal reminder wrapper. The wrapper is not a public contract.
The current docs say that project-root and user-level CLAUDE.md files are read at the start and held in memory. Editing one mid-session doesn’t immediately replace the old version; reload via /clear, /compact, or a restart. Directory-scoped rules can load later. The key is that editing a file on disk and rewriting text that was already sent are two different events.
Skills: deliver new instructions at the invocation point
A skill catalog is useful, but repeatedly rebuilding a catalog early in the request can make later prefixes harder to reuse. The historical note described a set of already-announced skill names and a policy of sending only additions. Its post-compaction behavior and token estimates weren’t independently verified for the current release.
What is documented now: invoking a skill or command appends its instructions to the conversation. It doesn’t rewrite the prior turns. A skill that switches models is an important exception: the new model has its own cache.
Forks: share history before adding branch-specific work
The old note cited a fixed placeholder in a fork-related path. It would be misleading to generalize that into “all inherited tool results are always replaced”: current docs say a fork can reuse the parent’s cache by inheriting the same system prompt, tools, and history. A regular subagent with a different prompt and tool set starts with a different prefix.
For a fan-out, the transferable idea is to start with a shared prefix and put each worker’s instructions after it. Don’t replace evidence the worker needs with placeholders just to save tokens. Also, equal prefixes don’t guarantee a read: a request first has to write the entry, and the entry must still be available.
Environment: a snapshot and live execution state have different jobs
The note reported an older environment snapshot that didn’t follow every shell directory change. It interpreted the behavior as a cache trade-off. The current docs confirm that startup environment and repository details can affect cache sharing, but not the note’s exact refresh rules or its claims about every tool’s working directory.
The useful distinction is between context that helps the model orient itself and state that must be read at execution time. A startup snapshot can describe the project. A file or shell operation should use the current path, not infer it from an old prompt.
Dates: append a change instead of editing the beginning
The old note described a separate date-change reminder. Treat the exact notice and trigger as historical. The design lesson is simple: if the date matters, supply the current value where it’s needed. Replacing a date near the start of a large shared prefix breaks matches for everything after it; appending an update can leave the old prefix intact.
MCP: a new instruction and a changed tool definition aren’t the same
An MCP server that finishes connecting later may bring new instructions. The historical note described adding instructions as a delta rather than rewriting the system section. Appending new text can preserve earlier cache entries. But if the change adds, removes, or modifies a definition in the request’s early tool list, the cache consequences are different.
The current Claude Code docs distinguish cases involving deferred tool loading, reconnecting with the same definitions, and deliberately removing a tool. Don’t infer a cache hit just because the change originated in MCP. Check whether the actual request prefix changed.
5. When this design pays off
“Static” has two meanings here. A project rule may be static in purpose but change in the request when you switch repositories. A date is dynamic in purpose, yet you can represent it with an append-only update. Cache behavior follows what was actually sent, not the label you give it.
The benefit depends on reuse. A single cold request pays for a write without getting a later read. Two requests can already save on the shared portion if the second hits and the read discount outweighs the write premium. Expiry, short prefixes below the model’s caching threshold, and early content that changes on every call all reduce the upside. Retrieval-augmented generation isn’t inherently a poor fit: a varying retrieval result can go after stable instructions or examples.
Nor is caching limited to repeated calls by the same end user. The API documents organization isolation and, on some providers, workspace isolation. Sharing within the applicable scope still depends on a matching prefix and other cache conditions. Different providers and APIs make different guarantees.
The quickest way to validate a design is to compare cache_creation_input_tokens and cache_read_input_tokens across representative turns. If one change repeatedly turns a read into a write, find where that change enters the request before adding more breakpoints.
Next: compaction, where preserving old history verbatim is no longer the main objective.
Top comments (0)