The prevailing assumption that compaction costs scale linearly with context size is wrong. Anthropic's prompt caching documentation clarifies that the decisive factor for /compact pricing is the state of the prompt cache at the moment the summarization request fires. While a warm cache allows Claude Code to read the conversation history at discounted rates, an expired cache forces the system to reprocess the entire history as uncached input. This distinction creates a twenty-fold price difference for the same command, depending entirely on session timing rather than data volume.
The Warm vs. Cold Cache Arithmetic
The cost mechanics rely on Anthropic's published pricing for Claude Opus 5.5 as of October 1, 2026. When the prompt cache is warm, input tokens are served at $0.20 per million. If the cache has expired, those same tokens cost $4 per million. For a session with 400,000 tokens of history, a warm cache results in an input cost of just $0.08. However, if the user returns after a break longer than the cache TTL, the summarization request pays full price, jumping to $1.60. This variance applies even though the underlying dataβthe conversation historyβremains identical in both scenarios.
Cache Lifetimes and Subscription Tiers
Cache duration is not uniform across all access methods. The Claude Code documentation specifies that main conversation requests retain a cache for one hour on Claude subscriptions within plan usage, but only five minutes for users on usage credits, API keys, or cloud providers. Compaction requests fall into a secondary bucket with a five-minute TTL across all payment types, yet they leverage the prefix-sharing mechanism established by the main conversation. Consequently, developers on API keys have a much narrower window to execute /compact before incurring the cold cache penalty compared to those on subscription plans.
What Survives and What Disappears
Compaction is not a lossless operation. The process replaces message history with a model-written summary, but specific context elements are restored from disk while others are permanently summarized away. Project-root CLAUDE.md files, auto memory, and the current plan survive because they are re-read from the filesystem. Conversely, path-scoped rules, nested CLAUDE.md files in subdirectories, and context previously injected by hooks are lost unless triggered again. Files larger than 5,000 tokens return only as path references, forcing costly re-reads if the model requires their content in subsequent turns.
Auto-Compact Triggers and Context Rot
Auto-compaction occurs near the model's context limit, typically around 967K tokens for 1M-window models or at the 200K boundary for smaller setups. Anthropic warns that waiting for this automatic trigger often results in lower-quality summaries due to 'context rot,' where the model is least intelligent at the end of a long session. The documentation advises running /compact at natural breaks between tasks rather than allowing it to fire mid-task. This manual control ensures the summarization happens when the model can still accurately predict the direction of the work, preserving critical details that an automated, late-stage summary might drop.
Key Takeaways
- Warm cache /compact costs $0.08 for 400K tokens; cold cache costs $1.60.
- Subscription users have a 1-hour main conversation cache window; API users have 5 minutes.
- Path-scoped rules and nested CLAUDE.md files do not survive compaction.
- Auto-compact fires at ~967K tokens on 1M models, often when context rot is worst.
- /clear is free and better for switching tasks; /compact is for mid-task continuity.
The Bottom Line
Stop treating /compact as a free utility and start treating it as a timed financial decision. The twenty-fold price swing proves that timing your compaction during a warm cache window is the single most effective cost control strategy in Claude Code.