Feature Request: Context Management Options (--compress-record, --context-mode)
Resolved 💬 3 comments Opened Jan 28, 2026 by greogory Closed Jan 28, 2026
Summary
Add CLI flags and configuration options for users to control context window management behavior, specifically around compression/purging and automatic session record creation.
Problem
When context compression or purging occurs, valuable session information is lost permanently. Users have no way to:
- Automatically preserve session details before compression
- Choose between compression (summarization) vs full purge
- Ensure continuity across long sessions
Proposed Solution
1. --compress-record / --comprec
Automatically create a comprehensive session record file before context compression occurs.
claude --comprec # Enable for this session
claude --compress-record=auto # Auto-create when context < 10%
claude --compress-record=prompt # Prompt user before compression
claude --compress-record=off # Default current behavior
Behavior:
- When context window reaches threshold (configurable, default 5-10%), automatically:
- Generate
SESSION_RECORD_YYYY-MM-DD-HHMMSS.mdin current project - Include: all tasks, files modified, commits, decisions, errors, pending work
- Then proceed with compression
2. --context-mode
Let users choose between compression and full purge.
claude --context-mode=compress # Default: summarize and continue
claude --context-mode=purge # Full clear, start fresh
claude --context-mode=checkpoint # Save record, then purge
Use cases:
compress(default): Long-running sessions where continuity matterspurge: When context has become cluttered/confused, start freshcheckpoint: Best of both - save everything, then clean slate
3. Configuration File Support
{
"context": {
"compress_record": true,
"record_threshold_percent": 8,
"record_location": "docs/session-records/",
"mode": "compress"
}
}
Session Record Format Example
# Session Record: [Project] - YYYY-MM-DD HH:MM
## Summary
[Auto-generated summary of session goals and outcomes]
## Tasks Completed
- [x] Task 1
- [ ] Task 2 (pending)
## Files Modified
| File | Action | Commit |
|------|--------|--------|
| src/main.cpp | Modified | abc1234 |
## Commits Made
- `abc1234` - commit message
## Key Decisions
- Decision 1: chose X over Y because...
## Pending Work
- Item 1
## Context for Next Session
[What the next session needs to know]
Benefits
- No information loss: Compression/purging currently loses details permanently
- Auditability: Users can review exactly what Claude did in a session
- Continuity: Easy to resume work even after full context reset
- Collaboration: Session records can be shared with team members
- Debugging: When something goes wrong, the record shows what happened
- User control: Choice between compression behaviors based on workflow needs
Privacy Considerations
- Session records may contain sensitive info
- Default: add
SESSION_RECORD*.mdto.gitignore - Option:
--compress-record=sanitizedto strip sensitive patterns
Current Workaround
Users can manually create session records before compression, but this is easy to forget and not integrated with context management.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗