[FEATURE REQUEST]: Selective Context Compaction
[FEATURE REQUEST]: Selective Context Compaction
Problem Statement
Currently, Claude Code offers only a nuclear "Compact" option that rebuilds the entire conversation from scratch. This is like having only git rebase -i --root when you often just need git rebase -i HEAD~5.
When working on complex tasks, verbose debugging sessions or iterative implementations can generate 50+ messages that become noise once completed. The current options are:
- Keep all the noise (degrades performance)
- Compact everything (loses valuable context from earlier work)
Proposed Solution
Add selective context compaction - the ability to compact a specific range of the conversation, not just from the beginning.
Git Analogy
Think of context management like git without files:
- Current:
/compact=git rebase -i --root(compact everything) - Proposed:
/compact from:42=git rebase -i HEAD~5(compact recent section)
Use Case
Scenario: I'm refactoring an authentication system. After initial planning and setup (messages 1-20), I spend an hour debugging a specific issue with 50 back-and-forth messages. Once fixed, those 50 messages are just noise.
Current workflow: Either keep all 70 messages (cluttered) or compact everything and lose the valuable planning context.
Proposed workflow: Compact messages 21-70 into "Fixed auth token validation bug" while preserving the initial planning context.
Implementation Ideas
- Add a
fromparameter to the existing/compactcommand - Always compacts from the specified point to the end of conversation
- UI enhancement: Add a picker/selector to let users choose where to compact from
- Reuse existing compaction logic entirely - just with a starting point parameter
- Keep the existing behavior for summaries and additional instructions
Additional Context
This aligns with how developers already think about git history management. It enables surgical context cleanup without losing valuable conversation history.
Related to existing issues about context management (#42, #92, #2304) but specifically addresses range-based compaction rather than auto-compaction or configuration.