Detailed Analysis
A Reddit post circulating in r/ClaudeAI has drawn attention to a practical, if underappreciated, technique for managing token consumption in Claude Code: disciplined use of the `/compact` command. The poster's core argument centers on two specific triggers for invoking compaction. First, when a session has sat idle for roughly 30 minutes or more, the prompt cache expires, meaning the next interaction forfeits the substantial discount (often cited around 90%) that cached tokens receive. Second, at the natural boundary between completed workflow steps, before pivoting to new work, compacting clears out granular tool outputs and intermediate reasoning that no longer serve the next phase of the task. Rather than treating `/compact` as a last resort for hitting context limits, the author reframes it as a proactive cost-management habit, particularly for users who maintain long-running, single-threaded sessions that may stretch across multiple days.
This tip reflects a broader tension that has emerged as Claude's models, and coding-focused agentic workflows in particular, have grown more capable and more expensive to run at scale. As models like Claude Opus and Sonnet are increasingly deployed in agentic loops involving repeated tool calls, file reads, search results, and multi-step reasoning, context windows fill quickly with data that was necessary in the moment but becomes dead weight for subsequent steps. Every retained token in context is a token that must be reprocessed on each turn, and when sessions run long, this compounds into significant expense, especially for developers on usage-based API billing rather than flat-rate subscriptions. The practical wisdom being shared here is less about a hidden feature and more about behavioral discipline: knowing when accumulated context has outlived its usefulness and intervening before costs balloon.
The mention of cache invalidation after periods of inactivity also points to an important but often overlooked mechanic in how Anthropic's prompt caching works. Prompt caching is designed to reward tight, iterative workflows, sessions where follow-up prompts arrive quickly enough to reuse the cached context, at a steep discount. When a user steps away for a coffee break, a meeting, or simply to think, that cache can silently expire, and the next message triggers a full-price reprocessing of the entire context. Few users intuitively grasp this timing sensitivity, so a workaround like proactively compacting after a lull effectively substitutes a smaller, cheaper reprocessing event for a larger, more expensive one. This is a good example of users developing folk knowledge and heuristics around the economic architecture of LLM APIs, translating an infrastructure detail into an actionable rule of thumb.
More broadly, this kind of grassroots optimization tip illustrates how the developer community using Claude Code has begun to treat context and token management as its own discipline, akin to memory management in traditional software engineering. As agentic coding tools become central to professional workflows, efficient context hygiene, knowing when to summarize, when to reset, and when to let go of stale information, is emerging as a core competency for power users, not unlike how developers learned to think about caching layers, garbage collection, or database indexing in earlier eras of computing. Anthropic and competing labs continue to iterate on native solutions such as automatic context compression and smarter cache management, but in the interim, user-driven heuristics like this `/compact` discipline fill the gap, helping cost-conscious teams extract more value out of increasingly powerful but token-hungry models.
Read original article →