ClaudeHack
0.000

Lower the /autocompact window so compaction happens before context rot

Context Management·14 hours ago·verified 14 hours ago·easy·~2 min setup·verified

Auto-compact waits until your context is nearly full, which is well past the point where answer quality starts sliding. Set the window lower and compact while the session is still sharp.

The problem

By the time auto-compact fires near the limit, you have already spent turns on a degraded context. Quality drops before the summary arrives, so the compaction preserves work that was already going wrong.

The hack

Run `/autocompact 500k` (or another size) to set how full the context window gets before Claude Code compacts automatically. The value saves to user settings and applies to the current session.

Why it works

Context rot sets in well before the window is full, so the default threshold optimizes for maximum runway rather than maximum quality. Choosing the trigger point yourself means compaction happens while the conversation is still worth summarizing.

Setup

1. Run `/autocompact` with no argument to see the current window. 2. Set a smaller size, for example `/autocompact 500k`. 3. Add `/statusline` and ask it to show the model and context percentage so you can watch the fill level. 4. Use `/context` to see what is actually consuming the window. 5. Pass `--autocompact 500k` at launch, or `auto` to return to the model-tuned default.

Code

# Session-only, without changing saved settings:
claude --autocompact 500k

# Or persist it in settings.json:
{ "autoCompactWindow": 500000 }

Prerequisites

Claude Code v2.1.221 or later for /autocompact and --autocompact.

Additional details

The window is expressed in tokens, from `100000` to `1000000`, not as a percentage — the underlying setting is `autoCompactWindow`, and `CLAUDE_CODE_AUTO_COMPACT_WINDOW` overrides it. Worth knowing before you tune this down aggressively: `/compact` reads the whole conversation it summarizes, so compacting a large context is itself a large request. If you want a fresh start rather than continuity, `/clear` costs nothing and Claude can pick the thread back up from the files in the repo.

Source

youtube·View original →·by Simon Scrapes

Does this still work?

0 said it works · 0 said it's broken

Related

Discussion

No comments yet. Be the first to say whether this worked for you.