Claude Code Hook Architecture Expansion — PreCompact PostCompact PostToolUse
Claude Code v2.1.76 Hook Architecture Expansion
Three previously unused hook events now deployed in the Claude Code settings.json:
-
PreCompact (matcher:
auto|manual): Fires before context compaction. Injects a self-summary prompt forcing the model to state in-progress task, verification criteria, and route decisions before context is stripped. UseshookSpecificOutput.additionalContextfor model injection. -
PostCompact (matcher:
auto|manual): Fires after compaction, receives summary. Forces context re-anchoring — re-read MEMORY.md, recover task state, re-establish verification criteria. -
PostToolUse (matcher:
Write|Edit): Fires after every file write/edit. Runs/root/.claude/hooks/post-write-validator.pywhich validates JSON/YAML/TOML syntax immediately. UsessuppressOutput: truefor clean files to prevent transcript noise. InjectsSYNTAX ERRORcontext on validation failure.
hookSpecificOutput JSON schema: {"hookSpecificOutput": {"hookEventName": "<event>", "additionalContext": "<text>"}} — the mechanism for hooks to feed information back to the model.
Key insight: PreCompact + PostCompact together form session continuity insurance for long-running complex sessions where compaction would otherwise lose critical task state.
Related
- clawteam-openclaw-multi-agent-swarm-evaluation
- enterprise-capability-expansion-5-pillars-from-digital-employee-analysis
- claude-code-v2-1-78-root-restriction-non-root-user-workaround
claude-code-to-nova-enterprise-capability-expansion-20260323(archived)- upgrade-history-full