Skip to content

[FEATURE] Add --no-auto-compact command switch to Disable the auto-compaction #6689

Closed

Description

@DuaneNielsen

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.

Activity

  1. changed the title [-][FEATURE] Disable auto-compaction flag[/-] [+][FEATURE] Add --no-auto-compact command switch to Disable the auto-compaction[/+] on Aug 27, 2025
  2. github-actions commented on Aug 27, 2025

    @github-actions

    Found 1 possible duplicate issue:

    1. [Feature Request] Support custom pre-compact, compact, and post-compact commands to run instead of default after context window is 95% full #3349

    This issue will be automatically closed as a duplicate in 3 days.

    • If your issue is a duplicate, please close it and 👍 the existing issue instead
    • To prevent auto-closure, add a comment or 👎 this comment

    🤖 Generated with Claude Code

  3. coygeek commented on Aug 27, 2025

    @coygeek

    +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 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

  4. kcosr commented on Aug 28, 2025

    @kcosr

    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.

  5. dalito commented on Oct 12, 2025

    @dalito

    /context with auto-compact set to true:

    Image

    After setting auto-compact to flase via /config command the /context command shows that the previously reserved context is now available:

    Image

    This is great but not a replacement for the feature request.

  6. ShanePresley commented on Oct 17, 2025

    @ShanePresley

    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.

  7. richservo commented on Oct 18, 2025

    @richservo

    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!!!!

  8. github-actions commented on Dec 9, 2025

    @github-actions

    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.

  9. QuintinWillison commented on Dec 14, 2025

    @QuintinWillison

    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. 🤦

  10. PaulRBerg commented on Dec 20, 2025

    @PaulRBerg

    It seems this is set across the board in ~/.claude.json and I can't find documentation for it.

    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.json

  11. jb747 commented on Jan 14, 2026

    @jb747

    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.

  12. yurukusa commented on Mar 29, 2026

    @yurukusa

    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):

    exit 2

    Install 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:

    [ -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.

  13. bcherny commented on Aug 17, 2026

    @bcherny
    Collaborator

    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

    🤖 Generated with Claude Code

  14. github-actions commented on Oct 7, 2026

    @github-actions

    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.

  15. locked as resolved and limited conversation to collaborators on Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions