[FEATURE] Interactive Context Compaction with Preview and User Approval

Status Closed — not planned
Maintainer reply None cached
Activity 9 comments · opened Oct 31, 2025 · closed Jan 25, 2026

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 <instructions> (which requires extensive typing with no preview). Users have reported in multiple issues (#3274, #5385, #6004, #7961) that auto-compaction often loses critical context, gets stuck in infinite loops, or disrupts workflows with poorly chosen compaction strategies.
The current options each have significant drawbacks: auto-compaction can unexpectedly remove important context, while /compact <instructions> requires writing detailed instructions blindly without seeing what the compacted context will look like.

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 <instructions>: Works but requires extensive typing, no preview, no iteration
Better auto-compact prompts (#7961): Improves automatic compaction but still lacks user visibility and control

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:

  1. Accept and compact
  2. Reject and modify (explain what to keep)
  3. 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

View original on GitHub ↗

9 Comments

github-actions[bot] · 11 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/7627
  2. https://github.com/anthropics/claude-code/issues/7821
  3. 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

BenNewman100 · 11 months ago

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

ohnotnow · 11 months ago

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.

github-actions[bot] · 10 months ago

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.

BenNewman100 · 9 months ago

Screw you bot

github-actions[bot] · 8 months ago

This issue has been automatically closed due to 60 days of inactivity. If you're still experiencing this issue, please open a new issue with updated information.

marcindulak · 8 months ago

This issue was closed incorrectly despite recent human comments. This behavior of the bot is reported at https://github.com/anthropics/claude-code/issues/16497. Please upvote that issue, so maybe it gets noticed.

hesreallyhim · 8 months ago

folks you can just go into the conversation log and trim it yourself before compaction. I have a library for this, if anyone is interested, I can make it public.

Also, @marcindulak I submitted a PR to fix the issue you referenced, see #20914 👍🏽 you know I got you

github-actions[bot] · 8 months ago

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.