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:

  1. Automatically preserve session details before compression
  2. Choose between compression (summarization) vs full purge
  3. 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:
  1. Generate SESSION_RECORD_YYYY-MM-DD-HHMMSS.md in current project
  2. Include: all tasks, files modified, commits, decisions, errors, pending work
  3. 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 matters
  • purge: When context has become cluttered/confused, start fresh
  • checkpoint: 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

  1. No information loss: Compression/purging currently loses details permanently
  2. Auditability: Users can review exactly what Claude did in a session
  3. Continuity: Easy to resume work even after full context reset
  4. Collaboration: Session records can be shared with team members
  5. Debugging: When something goes wrong, the record shows what happened
  6. User control: Choice between compression behaviors based on workflow needs

Privacy Considerations

  • Session records may contain sensitive info
  • Default: add SESSION_RECORD*.md to .gitignore
  • Option: --compress-record=sanitized to 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.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗