Prompt caching in Claude Code, explained for developers
Short answer: Claude Code caches the repeated start of your context automatically. Cached tokens are much cheaper. Idle gaps and edits near the start of the context break the cache.
What gets cached
Each turn starts with the same material: system instructions, tools, CLAUDE.md and the conversation so far. Claude Code caches that shared start, so the next turn reads it from cache instead of paying full price for it again.
Why it matters
Cache reads cost a small fraction of fresh input. In a long, steady session most of your context is cached, which is a large part of why long sessions are affordable at all.
What breaks the cache
- Idle gaps. Caches expire after a short idle period. Come back after lunch and the next turn pays full price.
- Editing early context. Changing CLAUDE.md or tool setup mid-session changes the start of the context, so everything after it is fresh again.
- Switching models. Each model has its own cache.
Habits that keep it warm
- Work in focused bursts in one thread.
- Settle CLAUDE.md and MCP setup before a long session, not during it.
- After a long break on a long thread, consider a handoff note and a fresh thread instead.
See your cache at work
CTO reads your local session logs and shows how much of each session came back from cache, and tells you when a habit is breaking it.
Questions
Do I need to turn on prompt caching in Claude Code?
No. Claude Code caches automatically.
Why did one turn cost much more than the others?
Usually the cache expired after an idle gap or the start of the context changed, so the whole context was billed fresh.
Try CTO free. Paste this in a terminal, then fully quit and reopen Claude Code:
claude plugin install --marketplace tokencoach/token-coach token-coach