Feature request: PreCompression hook to persist context before automatic compression
Resolved 💬 4 comments Opened Mar 21, 2026 by arnopix Closed Apr 18, 2026
When a long conversation approaches context limits, Claude Code automatically compresses prior messages. This compression is aggressive and often loses important details — architectural decisions, task state, reasoning behind changes.
Proposal
Add a PreCompression hook event that fires before context compression occurs. This would allow users to run a script that extracts and saves key context (current plan, decisions made, task progress) to a persistent file (e.g. a .md summary), so the information survives compression and remains available.
Use case
- Long-running sessions where important decisions accumulate over time
- Teams using
CLAUDE.mdas a knowledge base — a pre-compression hook could auto-update it - Users who keep sessions open indefinitely and rely on context continuity
Currently available hook events (PreToolUse, PostToolUse, Notification, etc.) don't cover this scenario.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗