You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[FEATURE] Add --no-auto-compact command switch to Disable the auto-compaction #6689
Allow the user to disable the auto-compact, and fully manage the context and continuation process themselves if they want.
This would be a very simple feature to implement. Just add a flag --no-auto-compact
I'm quite certain that 80% of users, and definitely 100% of power users already manage their own context via saving and restoring plans from files. And there are already scripts in the community that manage continuation better than anthropics current implementation.
Embrace the community here and I'm sure you will be rewarded.
Reacted by Fabrizio Sabatini, David Linke, Fritz Obermeyer, Leni_v, ShanePresley, Isaac Weber, Benjamin Kobjolke, FredericOdermatt, Bright, Petr Tripolsky and 37 more
changed the title [-][FEATURE] Disable auto-compaction flag[/-][+][FEATURE] Add --no-auto-compact command switch to Disable the auto-compaction[/+]on Aug 27, 2025
I've also run into situations where the auto-compaction kicks in when I'm trying to carefully manage a long context for a complex task. Having a startup flag for this would be super convenient, especially for scripting or when launching claude with a specific, long-running goal in mind.
In case you weren't aware (and for anyone else finding this thread), you can actually disable this behavior in the current version, though not via a command-line flag. You can run the /config slash command in an interactive session and toggle the "Auto-compact enabled" setting to off. It seems to remember this setting between sessions, which helps.
I found it mentioned in the Manage costs effectively documentation:
Compact conversations:
Claude uses auto-compact by default when context exceeds 95% capacity
Toggle auto-compact: Run /config and navigate to "Auto-compact enabled"
Use /compact manually when context gets large
This also pairs well with the manual /compact command, which lets you decide exactly when to shrink the context, and even provide custom instructions on what to focus on during the compaction.
So while it's not a command-line flag, you can at least disable it globally for your user. For scripting, you'd have to remember to have it disabled beforehand, which is where your --no-auto-compact flag would still be a great addition for guaranteeing the behavior of a script.
But I totally agree, having a command-line switch for this would be a power-user feature that fits the "Unix philosophy" vibe of the tool perfectly. Hope the team considers it
Reacted by Duane, 2spring, ShanePresley, Hoyong Jeong, Dmitriy Polomoshnov, David Asaf, Daniel Storm, vtorcs, Grisha Szep, xseymour and 1 more
To add to this, with the new /context command I can see that I have around 25% free context when the auto-compact occurs. This is wasteful for me. I don't want to compact manually or automatically. I prefer to leave things in a good state and /clear providing fresh context when I resume.
It seems this is set across the board in ~/.claude.json and I can't find documentation for it.
disabled
$ jq .autoCompactEnabled ~/.claude.json false
enabled
$ jq .autoCompactEnabled ~/.claude.json null
I tried overriding it with claude --settings to no avail. In it's current form, I don't see a way to override it at invocation or at a project level but I absolutely agree such a feature would be useful.
Auto compact is about the WORST thing about Claude code!!!! Drives me crazy, it WASTES tokens for nothing and often causes problems because it doesn't give full context. I've found that escaping it before it starts allows me to copy the last relelevent lines of conversation and it picks up PERFECTLY. Dalito you're my hero!!!!
Reacted by David Linke, SHIVAM PRASAD and testing0mon21
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
This is, by a country mile, the biggest pain point I am finding with Claude Code. When I'm deep into refining a plan, suddenly compaction kicks in and all the nuance and detail that I cared about is lost.
UPDATE: Looks like this might be controlled via /config and persisted to ~/.claude.json (global state) rather than ~/.claude/settings.json (user preferences) as I had initially and naievely assumed. 🤦
Most users may lack sufficient data to rate the last compaction at the point where they are asked it so the value of the metric may not be high relative to the amount of irritation created by the constant prompting.
Hook workaround: block auto-compaction with PreCompact
In addition to the autoCompactEnabled: false flag in ~/.claude.json mentioned above, you can use a PreCompact hook for more granular control — e.g., block compaction conditionally, or save context before allowing it. compact-blocker.sh (unconditional block):
Conditional variant — block only when a flag file exists:
[ -f /tmp/allow-compact ] &&exit 0
exit 2
This way you can touch /tmp/allow-compact when you're ready for compaction, and rm /tmp/allow-compact when you want to preserve full context.
You can also combine this with a pre-compact checkpoint hook that saves uncommitted changes to git before compaction fires, so nothing is lost even when compaction is allowed.
You can turn auto-compact off today: set DISABLE_AUTO_COMPACT=1 in your environment, or set "autoCompactEnabled": false in settings (also toggleable in /config as "Auto-compact"). Manual /compact keeps working. Docs: https://code.claude.com/docs/en/env-vars
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.
Activity
[-][FEATURE] Disable auto-compaction flag[/-][+][FEATURE] Add --no-auto-compact command switch to Disable the auto-compaction[/+]github-actions commentedon Aug 27, 2025
Found 1 possible duplicate issue:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
coygeek commentedon Aug 27, 2025
+1, this is a really thoughtful feature request.
I've also run into situations where the auto-compaction kicks in when I'm trying to carefully manage a long context for a complex task. Having a startup flag for this would be super convenient, especially for scripting or when launching
claudewith a specific, long-running goal in mind.In case you weren't aware (and for anyone else finding this thread), you can actually disable this behavior in the current version, though not via a command-line flag. You can run the
/configslash command in an interactive session and toggle the "Auto-compact enabled" setting to off. It seems to remember this setting between sessions, which helps.I found it mentioned in the Manage costs effectively documentation:
This also pairs well with the manual
/compactcommand, which lets you decide exactly when to shrink the context, and even provide custom instructions on what to focus on during the compaction.So while it's not a command-line flag, you can at least disable it globally for your user. For scripting, you'd have to remember to have it disabled beforehand, which is where your
--no-auto-compactflag would still be a great addition for guaranteeing the behavior of a script.But I totally agree, having a command-line switch for this would be a power-user feature that fits the "Unix philosophy" vibe of the tool perfectly. Hope the team considers it
kcosr commentedon Aug 28, 2025
To add to this, with the new
/contextcommand I can see that I have around 25% free context when the auto-compact occurs. This is wasteful for me. I don't want to compact manually or automatically. I prefer to leave things in a good state and/clearproviding fresh context when I resume.dalito commentedon Oct 12, 2025
/contextwith auto-compact set to true:After setting auto-compact to flase via
/configcommand the/contextcommand shows that the previously reserved context is now available:This is great but not a replacement for the feature request.
ShanePresley commentedon Oct 17, 2025
It seems this is set across the board in
~/.claude.jsonand I can't find documentation for it.disabled
$ jq .autoCompactEnabled ~/.claude.json falseenabled
$ jq .autoCompactEnabled ~/.claude.json nullI tried overriding it with
claude --settingsto no avail. In it's current form, I don't see a way to override it at invocation or at a project level but I absolutely agree such a feature would be useful.richservo commentedon Oct 18, 2025
Auto compact is about the WORST thing about Claude code!!!! Drives me crazy, it WASTES tokens for nothing and often causes problems because it doesn't give full context. I've found that escaping it before it starts allows me to copy the last relelevent lines of conversation and it picks up PERFECTLY. Dalito you're my hero!!!!
github-actions commentedon Dec 9, 2025
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
QuintinWillison commentedon Dec 14, 2025
This is, by a country mile, the biggest pain point I am finding with Claude Code. When I'm deep into refining a plan, suddenly compaction kicks in and all the nuance and detail that I cared about is lost.
UPDATE: Looks like this might be controlled via
/configand persisted to~/.claude.json(global state) rather than~/.claude/settings.json(user preferences) as I had initially and naievely assumed. 🤦PaulRBerg commentedon Dec 20, 2025
Yep. It's an undocumented boolean flag in the ugly
~/.claude.json:{ "autoCompactEnabled": false }it would be really great to have a CLI flag for enabling/disabling it, as well as a bespoke flag that users can set in
settings.jsonjb747 commentedon Jan 14, 2026
Most users may lack sufficient data to rate the last compaction at the point where they are asked it so the value of the metric may not be high relative to the amount of irritation created by the constant prompting.
yurukusa commentedon Mar 29, 2026
Hook workaround: block auto-compaction with PreCompact
In addition to the
autoCompactEnabled: falseflag in~/.claude.jsonmentioned above, you can use a PreCompact hook for more granular control — e.g., block compaction conditionally, or save context before allowing it.compact-blocker.sh(unconditional block):exit 2Install in
.claude/settings.json:{ "hooks": { "PreCompact": [ { "hooks": [ { "type": "command", "command": "bash /path/to/compact-blocker.sh" } ] } ] } }Conditional variant — block only when a flag file exists:
This way you can
touch /tmp/allow-compactwhen you're ready for compaction, andrm /tmp/allow-compactwhen you want to preserve full context.You can also combine this with a pre-compact checkpoint hook that saves uncommitted changes to git before compaction fires, so nothing is lost even when compaction is allowed.
bcherny commentedon Aug 17, 2026
You can turn auto-compact off today: set
DISABLE_AUTO_COMPACT=1in your environment, or set"autoCompactEnabled": falsein settings (also toggleable in/configas "Auto-compact"). Manual/compactkeeps working. Docs: https://code.claude.com/docs/en/env-vars🤖 Generated with Claude Code
github-actions commentedon Oct 7, 2026
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.