Feature Request: Automatic Context Restoration After Autocompaction
Resolved 💬 11 comments Opened Aug 18, 2025 by SDS-Mike Closed Aug 22, 2025
Summary
Add functionality to automatically restore context after autocompaction by re-reading CLAUDE.md and the latest JSONL conversation history file.
Problem Statement
When Claude Code performs autocompaction to manage conversation length, valuable context is lost including:
- Project goals and requirements from
CLAUDE.md - Recent conversation history and decisions made
- Work progress and current state
This forces users to manually re-explain project context and recent work, reducing productivity in long coding sessions.
Use Case
During extended development sessions, developers often hit conversation length limits. Currently, after autocompaction:
- Claude loses awareness of project-specific instructions in
CLAUDE.md - Recent work context disappears
- Users must manually re-establish context
- Productivity is disrupted
Proposed Solution
Implement a post-compaction hook that automatically:
- Re-reads
CLAUDE.mdto restore project-level context - Loads latest JSONL conversation history from
~/.claude/projects/ - Restores conversation context by providing a summary of recent interactions
- Maintains conversation continuity without manual intervention
Implementation Details
Core Components
Context Restorer Class
- Handles reading
CLAUDE.mdfrom project directory - Finds and parses latest JSONL conversation file
- Generates context restoration summary
Autocompaction Hook
- Triggers automatically after compaction occurs
- Integrates with existing compaction workflow
- Provides fallback handling if restoration fails
Integration Points
- Modify existing compaction function to call post-compaction hook
- Add configuration option to enable/disable feature
- Include restoration status in compaction logging
Benefits
- Improved Developer Experience: Seamless continuation of work after compaction
- Reduced Friction: No need to manually re-explain context
- Better Continuity: Maintains project awareness across compaction boundaries
- Time Savings: Eliminates repetitive context re-establishment
Alternatives Considered
- Manual context reload command: Requires user intervention
- Larger context windows: Hardware/cost limitations
- More aggressive summarization: May lose important details
Additional Context
This feature would be particularly valuable for:
- Long debugging sessions
- Complex refactoring work
- Multi-file feature implementations
- Extended pair programming sessions
Acceptance Criteria
- [ ] Context automatically restored after autocompaction
- [ ]
CLAUDE.mdcontents available post-compaction - [ ] Recent conversation summary provided
- [ ] Feature can be enabled/disabled via settings
- [ ] Restoration failures handled gracefully
- [ ] Performance impact minimal (<1 second)
Related Issues
- Related to context management improvements
- Complements existing autocompaction feature
This issue has 11 comments on GitHub. Read the full discussion on GitHub ↗