Track Claude Code compaction events. Know when to
/reset. MIT.
Claude Code auto-compacts long conversations. Each compaction compresses old context into an AI-generated summary. Early precise instructions become vague hints. After 16+ rounds, your original rules may be gone — and the model doesn't know it.
Compaction count is invisible by default. This tool makes it visible.
Tracking 459 sessions across 6 weeks (June–July 2026):
| Compactions | Sessions | Zone |
|---|---|---|
| 0 | 430 | — |
| 1–5 | 14 | Warm-up |
| 6–10 | 3 | Sweet spot |
| 11–20 | 6 | Decay |
| 21–50 | 4 | High-risk |
| 51+ | 2 | Critical |
U-shaped curve: compliance peaks at 3–8 compactions (enough context to learn your workflow; early rules not yet compressed away), then declines. After 16 compactions, instruction fidelity drops sharply.
L8→L12 cliff: Controlled experiment (100 API calls, 5 adversarial rules × 5 degradation levels) confirms the production data — full compliance drops from 80% to 20% when instructions degrade past a critical semantic threshold. Format constraints survive longer than semantic ones.
python compact-counter.py
# Session abc123: 7 compactions ● sweet spot
# Session def456: 23 compactions ● consider /reset~200 lines, stdlib only. Reads compact-state.json from your Claude Code data directory.
This tool was born from the hermes-workspace governance research. Compaction count is a feature in the L4 Drift Predictor — when sessions cross 16 compactions, the risk model flags potential rule decay. The controlled experiment (compact_fidelity_decay.py in hermes-workspace) validated the production finding with deterministic scoring.
- hermes-workspace — Research hub: 16 experiments, 5-layer governance architecture, compaction decay experiment
- paper-validator — One-command governance audit. Compaction count feeds L4 Drift Predictor.
- digital-twin-trainer — QLoRA + DPO training pipeline
- DEV.to — 31 articles · 掘金 — 中文技术写作
MIT