Compact prompt should preserve historical context across multiple compactions
Problem
When auto-compact fires, the default prompt focuses on recent work. After 2-3 compactions in the same session, all reasoning, decisions, and context from earlier compactions is completely lost. The model doesn''t even know there WAS a previous compaction.
This forces users to either:
- Start new sessions after every major task (losing warm context)
- Accept progressive amnesia within long sessions
What we did (workaround)
Added Compact Instructions section to CLAUDE.md:
Also created a custom skill - a pre-compact brain dump. User runs it before /compact, model outputs everything important in a structured format, compactor sees it as the freshest message and weights it heavily.
Result: After 4+ compactions, the full road of the session is preserved - what we did, why, what was rejected, what''s next.
Proposed default behavior
The compact prompt should include ONE paragraph:
If this conversation contains a summary from a previous compaction (indicated by ''This session is being continued from a previous conversation''), extract key decisions, outcomes, and direction into a cumulative ''Historical Context'' section at the top of your new summary. Each compaction adds 3-5 sentences. Never discard entries from previous compactions.
Cost: ~50 tokens in the prompt, ~20-30 tokens per compaction entry in the summary.
Benefit: Sessions survive 6-8 compactions without losing the thread.
Session lifecycle (missing from docs)
Users need to understand the compaction quality tradeoff:
| Compactions | Quality | What happens |
|-------------|---------|-------------|
| 0-2 | Excellent | Almost no context loss |
| 3-5 | Good | Details fade, decisions preserved (with the fix above) |
| 6-8 | Acceptable | High-level road preserved, implementation details gone |
| 9+ | Degraded | Even cumulative summaries get compressed, signal-to-noise drops |
Recommendation for docs: Switch sessions when the task is DONE. One session = one task/feature. Not one session forever, not a new session every 30 minutes. Without this guidance, users either restart too often (losing warm context - files read, patterns learned, user preferences) or never restart (context becomes soup after 10+ compactions).
Why this matters
The compact prompt was probably designed for single-task sessions. But real usage is multi-hour, multi-task sessions with agents, reviews, deploys. The session as workspace pattern needs cumulative memory, not just recent-work snapshots. A trivial addition to the default prompt would fix this for everyone.
This issue has 7 comments on GitHub. Read the full discussion on GitHub ↗