[FEATURE] Interactive Context Compaction with Preview and User Approval
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
Currently, context compaction in Claude Code happens either automatically (with unpredictable results and potential loss of important context) or manually via /compact
Proposed Solution
I propose an interactive, collaborative compaction workflow that triggers at a user-configurable threshold (e.g., 80% or 90% context capacity):
Proactive Trigger: When context reaches the configured threshold, Claude pauses and initiates an interactive compaction session Claude Proposes Compaction Strategy: Claude analyzes the current context and proposes:
What would be preserved (critical ongoing work, recent decisions, active files) What would be summarized (completed tasks, resolved issues, older discussion) What would be removed (redundant information, outdated attempts)
User Review & Iteration: The user can:
Accept the proposal and proceed with compaction Reject and provide feedback (e.g., "Keep the discussion about error handling", "The database migration context is still relevant") Modify by requesting alternative strategies
Iterative Refinement: Claude adjusts the proposal based on user feedback and presents a revised strategy until approval Configuration: Users can set their preferred threshold in settings:
json {
"context": {
"interactiveCompactionThreshold": 85,
"enableInteractiveCompaction": true
}
}
Alternative Solutions
Current auto-compact: Unpredictable, can lose important context, prone to infinite loops and corruption (#3274, #5385, #6004)
Manual /compact
Priority
Medium - Would be very helpful
Feature Category
Interactive mode (TUI)
Use Case Example
Example Interaction:
⚠️ Context at 85% (170k/200k tokens) ⎿ I recommend compacting now. Here's my proposal:
📦 PRESERVE (65k tokens): • Current task: Implementing OAuth flow • Recent architectural decisions (last 15 messages) • Active files: auth.service.ts, oauth.controller.ts • Unsaved changes and working tree state
📝 SUMMARIZE (45k tokens → 8k): • Completed: Database schema updates (compress to summary) • Resolved: Import path refactoring discussion • Tool outputs: Earlier test runs and lint results
🗑️ REMOVE (60k tokens): • Failed attempt: Redis caching approach (abandoned) • Outdated: Initial project structure discussion • Redundant: Repeated file readings
Would you like to:
- Accept and compact
- Reject and modify (explain what to keep)
- Show detailed view
Additional Context
This proposal bridges the gap between fully automatic (no visibility) and fully manual (no preview) compaction. It leverages Claude's intelligence to propose good strategies while giving users final control. This would particularly benefit:
Long debugging sessions where context accumulates Multi-step refactoring tasks Complex feature implementations requiring extended context
Related issues: #92, #3274, #5329, #5385, #6004, #6066, #7961
Found 3 possible duplicate issues:
- https://github.com/anthropics/claude-code/issues/7627
- https://github.com/anthropics/claude-code/issues/7821
- https://github.com/anthropics/claude-code/issues/10691
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
Those are similar proposals thst some minor over lap, but the core of this feature request is and interactive compact process that none of these other issues propose
I've been searching through the issues after being bitten by similar 'compact - ohno!' issues. I had been thinking of suggesting an 'officially named skill' that told claude how to compact things. Fallback to anthropic default if there's no custom skill set up.
But being able to tell it in broad terms things I don't care about, or things to prioritise would be a big unlock. I'm not sure how the compact process works (which I guess is part of the problem) - but even being able to tweak it a bit would be a help.
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.
Screw you bot