Feature request: configurable auto-compaction rules

Resolved 💬 2 comments Opened Feb 25, 2026 by tomerab1 Closed Feb 25, 2026

Feature Request

Allow users to configure auto-compaction behavior in Claude Code.

Current Behavior

Auto-compaction triggers automatically when the context window fills up, with no user control over:

  • When it fires (threshold percentage)
  • What gets preserved vs. summarized
  • How the compaction summary is generated (custom instructions)

Proposed Behavior

Add configuration options (e.g., in settings.json or .claude/settings.local.json) such as:

  • Threshold: control at what context usage % compaction triggers
  • Preserve rules: define patterns or topics that should always be kept in full (e.g., "always preserve code snippets", "keep recent tool results")
  • Compaction instructions: custom prompt/guidance for how the summary should be generated (similar to how /compact <prompt> works, but applied automatically)

Use Case

During long sessions (e.g., multi-step infrastructure setup, monitoring configuration, debugging), important context gets lost during auto-compaction. Being able to define what matters most would significantly improve the experience for complex workflows.

Alternatives Considered

  • /compact with a custom prompt — works but requires manual intervention
  • CLAUDE.md — persists across sessions but isn't dynamic to the current task
  • Memory files — good for cross-session persistence but doesn't help within a session

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗