The model remembers nothing between requests. So every time you send a message, Claude Code re-sends the whole thing: the system prompt, your project context, every earlier message and tool result, then your new message.
Prompt caching is how the API avoids doing that work twice. It reuses what it already processed, bills the re-read at a much lower cached rate, and fully processes only what changed. You don’t switch it on; Claude Code manages it. What’s worth knowing is what breaks it, because a broken cache costs you one slower, more expensive turn while it rebuilds.
It matches the prefix
The API caches by matching the start of each request, the prefix, against what it recently processed. The match is exact: change anything in the prefix and everything after it is recomputed.
So Claude Code orders each request from least to most volatile:
- System prompt and tool definitions, which rarely change.
- Project context: CLAUDE.md and auto memory, loaded at session start.
- The conversation, which grows every turn.
New content goes at the end, so a normal turn reuses everything before it. It’s also why editing CLAUDE.md mid-session does nothing until /clear, /compact or a restart: the copy loaded at the start is part of the prefix.
What breaks it, and what doesn’t
Each model has its own cache, so switching models with /model re-reads the whole conversation uncached. Compacting replaces your history with a summary, so the conversation layer starts over by design. Changing the tool list can invalidate everything, for example connecting an MCP server when its tools aren’t deferred by tool search. And the first session after a Claude Code upgrade usually starts cold.
Plenty is safe: editing files, changing permission mode, invoking skills and commands, and /rewind, which truncates back to a prefix that’s already cached. A subagent builds a cache of its own and leaves yours alone.
The docs’ advice: pick your model and effort level at the top of a session, and save /compact for natural breaks between tasks.
The catch: it expires
A cached prefix expires after a stretch of inactivity, and every hit resets the timer. The API offers a five-minute and a one-hour lifetime. On a Claude subscription within your plan’s usage, the main conversation gets an hour by default; with an API key or a cloud provider it gets five minutes unless you set promptCacheTtl. Step away longer and your first turn back pays full price.
Run /usage to see how you’re doing: its Prompt cache (main) line shows the session’s hit ratio. And The Duel is a 90-second game about why re-sent context is the real cost of agentic work.