◉CLAUDE LABJP
●2.1.336 — Claude Code 2.1.336 fixes a freeze on edits that rewrite thousands of lines. Long diffs now show line counts, and ctrl+o opens the full diff●MCP WEB — 2.1.335 adds claude mcp add --web: on paid plans, register a remote MCP server as a claude.ai connector from your terminal●OPUS 4.5 — claude-opus-4-5 retires on 2027/1/22, 49 days from now. The replacement is claude-opus-5-5●CLEANUP — People report a disk cleanup session deleting things it should have kept. Deciding what may be deleted up front is the open question●NEW — New: Split a pre-release app into three areas for Claude Code, verify findings, then fix●PLAN — Upgraded to Pro but nothing changed? Check the screens between payment and plan activation in order●2.1.336 — Claude Code 2.1.336 fixes a freeze on edits that rewrite thousands of lines. Long diffs now show line counts, and ctrl+o opens the full diff●MCP WEB — 2.1.335 adds claude mcp add --web: on paid plans, register a remote MCP server as a claude.ai connector from your terminal●OPUS 4.5 — claude-opus-4-5 retires on 2027/1/22, 49 days from now. The replacement is claude-opus-5-5●CLEANUP — People report a disk cleanup session deleting things it should have kept. Deciding what may be deleted up front is the open question●NEW — New: Split a pre-release app into three areas for Claude Code, verify findings, then fix●PLAN — Upgraded to Pro but nothing changed? Check the screens between payment and plan activation in order
Articles/Claude Code
⟐ Claude Code/2026-10-20Intermediate

You Stepped Away and Came Back to a Summary — Spotting Idle Compaction and Keeping the Details You Can't Lose

Leave a long conversation for about an hour and Claude Code swaps it for a summary. Checked against the docs as of November 2026: when it runs (terminal, VS Code, the desktop Code tab), how to tell it happened, and how to choose between turning it off, moving the threshold, and keeping the details outside the conversation.

Claude Code299compactionprompt caching5troubleshooting108CLAUDE.md9settings.json11hooks23

I was reading the v2.1.299 changelog one morning when a single line stopped me: a conversation over 200K tokens that sits idle for about 54 minutes gets compacted before its one-hour prompt cache expires. As an indie developer, I step away from a long session and come back to it almost every day — after lunch, after a call, after a walk to clear my head.

The first thing I want to say is that this is a feature, not a bug. But if Claude seems to have forgotten something you settled an hour ago, the cause may not be the model's mood. It may be this compaction.

Later releases widened where it runs, so I've rebuilt this piece against the current documentation (the idleCompaction entry in the settings reference and the "What survives compaction" section of the context window page) and the changelog, as of November 2026.

What is actually happening

Idle compaction replaces a long conversation with a summary while you're away. When you come back, your next message sends that summary instead of the whole conversation. The point is to spare you the wait and the cost of reprocessing everything once the one-hour prompt cache has expired.

According to the docs, it runs only when all five of these hold (checked against the official docs, November 2026):

ConditionDetail
SessionAn interactive terminal session, the VS Code extension's chat panel, or the desktop app's Code tab when the session runs on your machine or over SSH
Auto-compactionautoCompactEnabled is on (the default)
Prompt cacheThe conversation uses the one-hour cache TTL
SizeContext has reached the threshold (200,000 tokens by default)
Idle timeAbout an hour since the last request, with the computer awake the whole time

The changelog said "about 54 minutes"; the docs say "about an hour." They describe the same intent — run just before the cache expires.

Short conversations, or sessions you keep nudging, are never touched. It's the conversations you've grown carefully over a long afternoon that qualify, which is exactly what makes it awkward.

How it changed between versions

The behavior has shifted several times since I first read about it, so which lines apply depends on the version you're on.

VersionChange
2.1.290First version that honors "idleCompaction": false and CLAUDE_CODE_IDLE_COMPACT_MIN_TOKENS
2.1.299Idle compaction starts in the terminal
2.1.300cache_creation_5m_tokens and cache_creation_1h_tokens added to the OpenTelemetry api_request event
2.1.302An Idle compaction row in /config; the post-compaction notice says how to turn it off
2.1.314Extended to VS Code and the desktop Code tab; also runs for subscribers with telemetry off, and on Bedrock, Vertex, Foundry and LLM gateways once the one-hour cache is on
2.1.318Fixed a conversation being replaced by a reply that wasn't a summary
2.1.332Fixed idle compaction being skipped for subscribers well under their weekly limit

Three common misreadings

"It's a terminal thing." Not since 2.1.314. The VS Code chat panel and the desktop Code tab are covered too, and long editor sessions are precisely the ones that grow past the threshold.

"Raising the threshold will keep my sessions safe." The docs point out that a conversation on a 200K context window auto-compacts before it ever reaches 200,000 tokens. In practice, the default threshold is reached mainly by 1M-context sessions. Raising it to 400,000 only matters there; on a 200K window it changes nothing. If you actually want idle compaction on 200K conversations, you lower the threshold, to something like 150,000. The floor is 100,000 — anything smaller is raised to that.

"Compaction wipes my CLAUDE.md." The project-root CLAUDE.md, auto memory, and the plan written in plan mode are re-read from disk after compaction. What disappears is whatever lived only in the conversation, plus things that load on demand: rules with paths: frontmatter and CLAUDE.md files in subdirectories get summarized away with everything else.

Telling whether it happened

A compaction leaves a notice in the conversation, worded differently per surface:

  • Terminal: a line starting with Compacted while idle, before the prompt cache expired
  • VS Code chat panel: a notice containing a summary written while you were away
  • Desktop Code tab: the same notice inside a row labeled with Claude Code notice; switch to the Verbose view mode if you can't see it

If you missed the notice, the Prompt cache (main) line in the Session block of /usage is a secondary clue. Compaction is counted there as an "expected rebuild," so a count that went up while you were away means some compaction ran. Manual /compact and ordinary auto-compaction bump it too, though, so the notice text is what settles it.

Next, check which settings file is actually in effect. Settings live at three levels, and the precedence is local (.claude/settings.local.json), then shared project (.claude/settings.json), then user (~/.claude/settings.json).

The checking script in the first version of this article only looked at idleCompaction and the threshold. The docs, however, say idle compaction also stops when autoCompactEnabled is off or DISABLE_AUTO_COMPACT is set. The old script would leave you puzzled about why an "unset" config never compacts, so I added both:

#!/bin/bash
# Collect every setting that affects idle compaction, from the user, project and local levels plus the shell
echo "version: $(claude --version 2>/dev/null || echo 'claude not found')"
echo "shell env: DISABLE_AUTO_COMPACT=${DISABLE_AUTO_COMPACT:-unset}, CLAUDE_CODE_IDLE_COMPACT_MIN_TOKENS=${CLAUDE_CODE_IDLE_COMPACT_MIN_TOKENS:-unset}"
for f in "$HOME/.claude/settings.json" ".claude/settings.json" ".claude/settings.local.json"; do
  [ -f "$f" ] || { echo "$f -> (missing)"; continue; }
  # A missing key prints "unset", which means the default (true for both idleCompaction and autoCompactEnabled)
  jq -r --arg f "$f" '"\($f) -> idleCompaction=\(if has("idleCompaction") then .idleCompaction else "unset" end), autoCompactEnabled=\(if has("autoCompactEnabled") then .autoCompactEnabled else "unset" end), min_tokens=\(.env.CLAUDE_CODE_IDLE_COMPACT_MIN_TOKENS // "unset"), DISABLE_AUTO_COMPACT=\(.env.DISABLE_AUTO_COMPACT // "unset")"' "$f"
done

Run it from the project root. Here is real output from Linux (bash 5.1, jq 1.6) against a sample folder with a different value at each level. Claude Code itself isn't installed on that machine, hence the version line:

version: claude not found
shell env: DISABLE_AUTO_COMPACT=unset, CLAUDE_CODE_IDLE_COMPACT_MIN_TOKENS=unset
/home/me/.claude/settings.json -> idleCompaction=unset, autoCompactEnabled=true, min_tokens=unset, DISABLE_AUTO_COMPACT=unset
.claude/settings.json -> idleCompaction=unset, autoCompactEnabled=unset, min_tokens=400000, DISABLE_AUTO_COMPACT=unset
.claude/settings.local.json -> idleCompaction=false, autoCompactEnabled=unset, min_tokens=unset, DISABLE_AUTO_COMPACT=unset

Here the local false sits at the highest level, so idle compaction never runs in this project, and the 400,000 threshold in the shared file has no effect. The script doesn't read managed settings or the --settings flag; if your organization deploys settings, check those as well.

Narrowing down the cause

When something feels forgotten, I walk this table from the top. Having a fixed order keeps me from poking at settings in a panic.

SymptomLikely causeHow to checkFix
Right after returning, names and rejected options from before are goneIdle compaction replaced the conversation with a summaryLook for a Compacted while idle notice (or its VS Code / desktop wording)Move what you can't lose into CLAUDE.md; adjust the threshold or idleCompaction only if needed
You were gone briefly, yet context is missingOrdinary auto-compaction near the limit, or a manual /compactThe notice isn't the idle one; check usage with /contextKeep the conversation smaller rather than touching idle settings
Long idle stretches, never compactedA higher level sets false, or autoCompactEnabled is off, or DISABLE_AUTO_COMPACT=1Run the script aboveKeep the value only at the level you intend
No Idle compaction row in /configOlder than 2.1.302, or another settings source owns the keyclaude --version; look for managed settings or --settingsUpdate, or change the key where it's set
Only your path-scoped rules stop applying after compactionpaths: rules and nested CLAUDE.md files are summarized awayHas Claude touched a matching file since the compaction?Drop paths: or move the rule to the project-root CLAUDE.md

Turn it off, move the threshold, or keep it and offload

You have three options, and each trades the weight of your first message back against how much detail you lose.

OptionHowYou gainYou payGood for
Turn it off"idleCompaction": false, or the Idle compaction row in /config (2.1.302+)Every detail staysYour first message back reprocesses the whole conversation after the cache expiresWork where lost detail means redoing it
Move the thresholdCLAUDE_CODE_IDLE_COMPACT_MIN_TOKENS under envChoose which conversations qualify by sizeRaising it does nothing on a 200K window1M-context sessions you want kept up to a certain size
Keep it, offload the essentialsA work note in CLAUDE.md, or a SessionStart hookThe time and cost savingsA minute of effort before you step awayMost everyday work

Moving the threshold looks like this — here, lowering it so 200K conversations qualify:

{
  "env": {
    "CLAUDE_CODE_IDLE_COMPACT_MIN_TOKENS": "150000"
  }
}

If I had to put my rule in one line: when in doubt, don't turn it off — move out only what you can't afford to lose. Switching it off entirely makes the first message after a break heavier the longer the conversation is.

I'll own a mistake here. The first version of this article suggested raising the threshold to 400,000 as the gentler alternative to switching it off. Rereading the docs later, I realized that on a 200K window the default threshold is never reached in the first place, so for many readers that setting did nothing at all. That one stung a little. Now I check which context window a conversation runs on before I write any setting for it.

Moving what you can't lose out of the conversation

Before touching settings, there's one more thing worth questioning: does the information you'd hate to lose exist anywhere other than the conversation?

I always move three kinds of things out:

  • Options I rejected, and why (so the same idea isn't proposed again when I return)
  • Files and directories that must not be touched
  • Where the work stands — what's done and what's next

Option 1: a work note at the end of CLAUDE.md

The project-root CLAUDE.md is re-read after compaction, so anything there survives. Keep it apart from your permanent rules, in a small dated section, so it's easy to clear later:

## Work note (2026-10-20, delete when done)
- Rejected: regenerating every file on each build (diffs are enough)
- Do not touch: anything under scripts/legacy/
- Current state: log formatting is done; next is the retry cap on failure

The lowest-effort habit is to ask, right before stepping away, "write the current work note to the end of CLAUDE.md." I go deeper into what belongs in CLAUDE.md and at what granularity in designing CLAUDE.md.

Option 2: a separate notes file, read back after compaction

Sometimes CLAUDE.md is shared with a team and you'd rather not mix in personal notes. In that case, keep the note in something like .claude/work-notes.md and read it back with a SessionStart hook on the compact matcher. This is the "re-inject context after compaction" pattern from the official hooks guide, with a file read in place of a fixed string:

{
  "hooks": {
    "SessionStart": [
      {
        "matcher": "compact",
        "hooks": [
          {
            "type": "command",
            "command": "cat \"$CLAUDE_PROJECT_DIR/.claude/work-notes.md\" 2>/dev/null || true"
          }
        ]
      }
    ]
  }
}

Put it in your personal .claude/settings.local.json and the team's settings stay untouched. The hook's stdout is added to the compacted context.

I want to be candid about one gap. The "What survives compaction" table describes compaction in general, and I haven't yet confirmed in my own setup that this hook fires after an idle compaction specifically. There's also the PreCompact hook, whose stdout becomes instructions for the summary (matchers manual and auto), but I haven't confirmed which matcher an idle compaction counts as. So for anything I truly need to keep, I still prefer Option 1 — the project-root CLAUDE.md. The broader hook design is covered in Claude Code hooks: design decisions.

What tends to trip you up next

After compaction, Claude Code re-reads up to five of the files Claude read or edited in the session, most recently modified first. Files over 5,000 tokens come back only as a path, shown as Referenced file. If you stepped away mid-edit on a large file, that's why you may need to say "read that file again" when you return.

Idle compaction is also tuned to the one-hour life of the prompt cache. If you want to design around caching more deliberately, see prompt cache TTL and directory-level decisions. Since 2.1.300, the OpenTelemetry api_request event lets you split cache writes by their 5-minute and 1-hour lifetimes.

If you do change the setting, I'd suggest running the same kind of work for a few days before and after, and jotting down two things: how long the first reply takes when you return, and how many assumptions went missing. I don't yet have enough of my own records to say that turning it off was worth it.

In place of a summary

Keep the assumptions you can't lose in a file, not in the conversation. I hold to that whether compaction is on or off that day.

For today, before you next step away, try writing just one work note into the project-root CLAUDE.md.

Share

Thank You for Reading

Claude Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • ✦Copy-paste ready implementation code
  • ✦New advanced guides published daily
  • ✦$5/mo or $10 for lifetime access
View Membership →

If you found this article helpful, a small tip ($1.50) would mean a lot to us. Your support helps keep this site ad-free and covers server and hosting costs.

Related Articles

⟐ Claude Code2026-10-19
If You Wrote MCP Allow Rules as Just `mcp__servername` — After v2.1.299, Only Servers With `__` in Their Names Need a Recheck
Claude Code v2.1.299 changed MCP allow rules to match only the server they name. A bare mcp__servername is affected only when the server name contains __ or ends in _. Includes a short audit script.
⟐ Claude Code2026-10-05
I Wrote "I'll Do the Commits" in CLAUDE.md. The Next Morning git log Had One More Line.
When Claude Code commits despite being told not to: undo with git reset --soft, then stop it physically with permissions.deny plus a PreToolUse hook. Covers the git -c form that deny rules let through, and how to test the hook without starting Claude Code.
⟐ Claude Code2026-08-25
A One-Letter Typo in settings.json Is Ignored Without a Single Warning
I diffed claude doctor output between a settings.json with misspelled keys and a correct one. There was no difference at all. Here is what actually gets validated, what slips through, and a small check that catches typos before they cost you a day.