claude-code
claude-code copied to clipboard
Feature Request: Add Context Pruning as Alternative to Compacting
Problem Statement
Currently, Claude Code appears to only offer context compaction/summarization when managing conversation history. This requires Claude to process and summarize the entire context, which can be unnecessary and inefficient in many scenarios where users simply want to retain recent messages.
Proposed Solution
Implement a context pruning feature that allows users to keep only the most recent X messages without requiring Claude to process or summarize the pruned content. This would be a lightweight alternative to the existing compaction feature.
Use Cases
- After creating a plan or task list: When I've just finished outlining a plan or creating a task list, I often only need to keep that recent output plus a few preceding messages for context
- Starting a new phase of work: When transitioning to a different aspect of a project, older context becomes irrelevant
- Performance optimization: Avoid unnecessary API calls for summarization when simple truncation would suffice
- Cost reduction: Eliminate token usage for summarization when not needed
Suggested Implementation
Option 1: Command-based pruning
/prune --keep-last 5
This would keep only the last 5 message pairs (user + assistant)
Option 2: Interactive pruning
/prune --from-message <message-id>
Keep everything from a specific message onward
Option 3: Smart pruning with markers
Allow users to set "checkpoint" markers in the conversation:
/checkpoint "Task list created"
/prune --from-checkpoint
Benefits
- Faster context management: No need to wait for Claude to process and summarize
- More predictable: Users know exactly what context is retained
- Cost-effective: No API tokens spent on summarization
- User control: Direct control over what stays in context
- Preserves exact content: No risk of losing important details through summarization
Additional Considerations
- Could coexist with the current compaction feature - users choose based on their needs