[KongchangAI]
· 2 min read· 1,023 words

Hidden Claude Code Setting: Enable Idle Compaction to Save Big

Hidden Claude Code Setting: Enable Idle Compaction to Save Big

Enabling Idle Compaction in Claude Code reduces full-price resend costs after idle cache expiry.

The article explains that Claude Code uses prompt caching to reduce billing for repeated context, but the cache expires after a few idle minutes, causing the entire context to be resent at full price. The fix is enabling Idle Compaction via `/config`, which compacts long conversation history before cache expiry so resends are smaller. Savings vary, defaults may change, and compaction may lose detail.

Claude Code users may be overlooking a toggle that directly affects their API bills. YouTube creator FlintEye points out in a recent short video: type /config in Claude Code, find the Idle Compaction option, and confirm it's enabled — this prevents your entire context from being resent at full price after long idle periods.

The video is short, but it points to a real cost trap.

The Root Cause: Prompt Cache Expires

Claude Code conversations rely on the prompt cache to reduce billing costs for repeated context. When the cache hits, previously sent content is reused at a discounted price; but according to FlintEye, the cache expires after a few minutes of idle time.

Type slash config.

Once the cache expires, the entire conversation context is resent as brand-new input on the next interaction, billed at full price. For long sessions that have accumulated numerous tool calls, large file contents, and command outputs, this resend cost is considerable — you just left your desk to grab a coffee, come back and type one sentence, and the bill is settled against the entire context.

Prompt Caching is an optimization mechanism provided by the Anthropic API: when the prefix portion of a request (such as system prompts, long documents, or conversation history) exactly matches a previous request, that portion can be billed at the discounted "cache write/read" rate rather than being recalculated at the standard input price each time. Caches typically have a time-to-live (TTL); Anthropic's default cache validity is about 5 minutes, and each hit resets the timer. As a CLI tool built on top of the API, Claude Code's long-session costs depend heavily on cache hit rate: once the TTL is exceeded without interaction, the cache expires, and the entire context of subsequent requests will be re-input at standard prices. Understanding this makes it clear why "a few minutes of idle time" translates directly into a bill spike.

What Idle Compaction Does

Idle Compaction works by proactively compacting overly long conversation history before the cache expires, slimming the context down to a smaller size. This way, even if the cache expires and a resend is needed, what gets sent is the compacted, streamlined version rather than the original full context.

Find idle compaction.

Put simply, it replaces "a large resend after cache expiry" with "a smaller resend after advance compaction." For developers who tend to keep Claude Code sessions running for long periods and switch tasks frequently, this difference grows with session length.

Context Compaction here differs from simple truncation: it typically involves the model summarizing/distilling earlier conversation turns, replacing the original mass of tool-call records and file snippets with a condensed text — significantly reducing token count while preserving key information. Compaction happens during idle periods rather than during interaction, so it doesn't slow down actual user operations; the trade-off is that fine-grained original content may be lost (for example, the complete output of a particular command, precise line numbers, or variable names). For tasks that rely on early details for subsequent reasoning, the compacted context may be insufficient for precise retrospection — which is exactly why a trade-off between cost and completeness is needed.

How to Enable It

Three steps to confirm:

  1. Type /config in Claude Code to open the configuration interface
  2. Find the Idle Compaction option
  3. Confirm the toggle is enabled

The prompt cache expires after a few idle minutes.

The whole process requires no config file editing and no environment restart. FlintEye's advice is straightforward: go check whether it's on.

Two Things to Keep in Mind

Savings vary from person to person. FlintEye explicitly states "savings vary" — the exact amount depends on session length, idle frequency, and context size. Users with short sessions and continuous operation may not notice much difference; users with long sessions and frequent interruptions benefit more.

Then your whole context is resent at full price.

Default state may change. The video specifically mentions "updates can change it" — that is, Claude Code version updates may adjust the option's default value or behavior. This means you can't assume it's always on; periodically rechecking in /config is the safer approach. Additionally, compacting history may itself lose some detailed context — if you rely on precise information from early conversations, you need to weigh cost against completeness.

It's worth distinguishing: Idle Compaction solves the problem of "excessive resend volume after cache expiry," not "cache expiry" itself. Even with this option enabled, once the cache expires, the compacted context is still rebilled at full price — only with a smaller base. If you want to further reduce idle costs, consider proactively ending the session or using /clear to reset the context before a long absence, so the next interaction starts from a clean state; conversely, if a task requires continuous multi-turn memory, try to keep your interaction rhythm within the cache TTL to avoid unnecessary idle gaps.

Summary

This is a typical "one-minute setting with long-term billing impact" configuration item. Its value isn't in complexity, but in the fact that most users don't even know the cache expires — let alone that there's a corresponding mitigation toggle. Spend thirty seconds opening /config to confirm, and the cost is virtually zero.

One-line Summary

Enabling Idle Compaction in Claude Code reduces full-price resend costs after idle-induced cache expiry.

Paragraph Summary

The article explains that Claude Code relies on prompt caching to reduce billing costs for repeated context, but the cache expires after a few minutes of idle time, causing the entire conversation context to be resent at full price on the next interaction — resulting in considerable expenses for long-session users. The mitigation is to enable Idle Compaction: find the option in /config and confirm it's on. It proactively compacts overly long conversation history before the cache expires, so what gets resent is a streamlined version rather than the full context. The author notes that savings vary with session length and idle frequency, and that version updates may change default behavior, so periodic rechecking is needed; compaction may also lose some detail, requiring a trade-off between cost and context completeness.

#Claude Code#Idle Compaction#prompt cache#API cost#context compaction#Anthropic API
Share:

Related articles