[FEATURE] Pre and/or Post Compaction warning/hook
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
- Feature: Pre-compaction warning/hook
- Problem: Context compaction happens without warning, losing critical session details that summaries don't capture
- Impact: Complex multi-session work requiring strict methodology (like tree-ordered implementation) loses discipline across compactions
Proposed Solution
Either a warning when compaction is approaching, or a hook that triggers automatic session export before compaction occurs. Alternatively, use compaction is a scaled manner where the most recent 30 minutes is full detail chat and survices the compaction without summarization. Next 30 min, some summarization, next ... so you progressively summarize more and more to the level you have today. reasonable since information that old is stale, anyway. well, other than the inital discussion at the start of a session. I am working on a large grammar related project and keep running into Claude Code having the details of a task compacted away so I have to spend 15 minutes reorienting him with export I hopefully created and documentation.
Alternative Solutions
_No response_
Priority
High - Significant impact on productivity
Feature Category
Developer tools/SDK
Use Case Example
Claude Code Generated based on this issue arising again:
---
Use Case: Tree-Ordered AST Formatter Implementation
Context: Building an Ada code formatter that requires implementing ~334 AST node handlers in strict tree order (root to leaves). Implementing out of order
causes the "emission chain problem" - upstream changes break downstream handlers, requiring exponential rework.
What happened:
- Session 1: User and Claude (with GPT consultation) create detailed implementation plan - strict tree order starting from Compilation_Unit (root) →
Library_Item (Level 1) → deeper nodes
- Plan documented in CLAUDE.md and implementation_spec.md
- Work begins correctly
- Compaction occurs
- Session resumes from summary: "implementing Phase 1 handlers systematically"
- Claude continues adding handlers - but in arbitrary order (Representation, Renamings, Parameters) instead of tree order
- User catches this after ~15 handler packages added out of order
- Discovery: Level 1 nodes (Library_Item, Subunit) were never implemented - all deeper work may need revisiting
Impact: Hours of work potentially invalidated because the summary lost "strict tree order" nuance. User had reminded Claude multiple times during the project,
but each compaction reset the discipline.
What would have helped: Recent context (last 30 min) staying full-detail through compaction, preserving the active methodology.
Additional Context
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗