PostCompact Hook: Restore Agent State After Context Compaction
Releasebot·high signal
The new PostCompact lifecycle hook in Claude Code v2.1.76 fires after automatic context compaction, enabling a script to re-inject state the agent needed but lost during compaction. Practical use: write critical working state (current task, open files, in-flight decisions) to a sidecar file in a PreCompact hook, then restore it in PostCompact. This closes the long-standing session continuity gap where agents would lose task context mid-run on large codebases.