Follow Discord
Sweep 22 Sep 2026 · 17:19Z Build v2.1.280 501 read Stable v2.1.267 Latest v2.1.280 Next v2.1.280 Feeds RSS JSON llms.txt Unofficial
One change · claude-code

How Claude Code uses prompt caching changed

prompt-caching

Nearest release: v2.1.265, published under an hour before this site recorded the change. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.

Recorded here
Lines+15added
Lines−13removed
From line 18 where the diff opens
First seen 14 Aug 2026 this site's first read of the page
Recorded edits32to this page, all time

The whole hunk

from line 18, old and new numbered
/
lines
from line 18
1818 
1919To get the most out of prefix matching, Claude Code orders each request so content that rarely changes between turns comes first:
2020 
21| Layer | Content | Changes when |
22| --------------- | ------------------------------------------------- | ---------------------------------------------------------------------- |
23| System prompt | Core instructions, tool definitions, output style | The set of loaded tool definitions changes, or Claude Code is upgraded |
24| Project context | CLAUDE.md, auto memory, unscoped rules | Session starts, or after `/clear` or `/compact` |
25| Conversation | Your messages, Claude's responses, tool results | Every turn |
21| Layer | Content | Changes when |
22| --------------- | ------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
23| System prompt | Core instructions, tool definitions, output style | The set of loaded tool definitions changes, you switch output style, or Claude Code is upgraded |
24| Project context | CLAUDE.md, auto memory, unscoped rules | Session starts, or after `/clear` or `/compact` |
25| Conversation | Your messages, Claude's responses, tool results | Every turn |
2626 
27A change to the conversation layer leaves the system prompt and project context cached. A change to the system prompt invalidates everything, because all later content now sits behind a different prefix. The third column gives common triggers rather than an exhaustive list, and the sections below cover the full set, including content such as output style that is fixed at session start.
27A change to the conversation layer leaves the system prompt and project context cached. A change to the system prompt invalidates everything, because all later content now sits behind a different prefix. The third column gives common triggers rather than an exhaustive list, and the sections below cover the full set.
2828 
2929The prefix-match rule explains most of the behaviors on this page. [Plan mode](/docs/en/permission-modes#analyze-before-you-edit-with-plan-mode) and [skill loading](/docs/en/skills), for example, append their instructions as conversation messages, so the cached prefix stays intact.
3030 
from line 68
6868* [Connecting or disconnecting an MCP server](#connecting-or-disconnecting-an-mcp-server)
6969* [Enabling or disabling a plugin](#enabling-or-disabling-a-plugin)
7070* [Denying an entire tool](#denying-an-entire-tool)
71* [Changing output style](#changing-output-style)
7172* [Compacting the conversation](#compacting-the-conversation)
7273* [Accumulating many images](#accumulating-many-images)
7374* [Upgrading Claude Code](#upgrading-claude-code)
from line 151
150151 
151152Only a deny rule that matches in the tool-name position has this effect: a bare tool name, the equivalent `Bash(*)` form, or a [tool-name glob](/docs/en/permissions#tool-name-wildcards) like `"*"`. A glob that matches only MCP tools, such as `"mcp__*"`, removes those tools the same way but leaves the cache intact when the matched tools are [deferred](#connecting-or-disconnecting-an-mcp-server), the default, since deferred definitions were never in the cached prefix. Scoped deny rules like `Bash(rm *)`, and all allow and ask rules, don't change which tools Claude sees. Claude Code checks them when Claude attempts a call, leaving the prefix intact.
152153 
154### Changing output style
155 
156[Output style](/docs/en/output-styles) is part of the system prompt. When you switch styles mid-session with `/config` or the `outputStyle` setting, Claude uses the new style starting with your next message, and that request reads the entire conversation history with no cache hits. To keep that cost small, switch styles before your first message in a session or right after `/clear` or `/compact`, when there is little or no conversation history to re-read.
157 
158Before v2.1.251, a mid-session style switch kept the cache but didn't apply until you ran `/clear` or started a new session.
159 
153160### Compacting the conversation
154161 
155162[Compaction](/docs/en/context-window#what-survives-compaction) replaces your message history with a summary. By design, this invalidates the conversation layer, since the next request has a new, shorter history that doesn't share a prefix with the old one. Claude Code reuses the system prompt layer and reloads project context from disk, which cache-hits only if CLAUDE.md and memory are unchanged since the session started.
from line 187
180187 
181188## Actions that keep the cache
182189 
183These actions either append to the end of the conversation or don't touch the request at all. Some of them, such as editing CLAUDE.md or changing output style, are also why a setting change waits for a restart to apply.
190These actions either append to the end of the conversation or don't touch the request at all. Some of them, such as editing CLAUDE.md, keep the cache for the same reason the change doesn't reach the running session until `/clear`, `/compact`, or a restart.
184191 
185192* [Editing files in your repository](#editing-files-in-your-repository)
186193* [Editing CLAUDE.md mid-session](#editing-claude-md-mid-session)
187* [Changing output style](#changing-output-style)
188194* [Changing permission mode](#changing-permission-mode)
189195* [Invoking skills and commands](#invoking-skills-and-commands)
190196* [Running `/recap`](#running-%2Frecap)
from line 206
200206Your project-root and user-level CLAUDE.md files are read once at session start and held in memory. Editing them mid-session does not invalidate the cache, but the edit also doesn't apply. Claude keeps working with the version that was loaded at session start. The new content loads on the next `/clear`, `/compact`, or restart.
201207 
202208[Nested CLAUDE.md files in subdirectories](/docs/en/memory) and [rules with `paths:` frontmatter](/docs/en/memory#path-specific-rules) load later, when Claude first reads a matching file. Editing one before it loads does take effect. After it loads, the content is part of the conversation history, so a mid-session edit doesn't retroactively change it.
203 
204### Changing output style
205 
206[Output style](/docs/en/output-styles) is part of the system prompt, which Claude Code reads once at session start. Changing it via `/config` or the `outputStyle` setting mid-session does not invalidate the cache, but the change also doesn't apply. Claude keeps using the style that was loaded at session start. The new style loads on the next `/clear` or restart.
207209 
208210### Changing permission mode
209211 
Feedback