Skip to content

v1.4.0 — Claude Code hooks: survive auto-compact

Choose a tag to compare

@fahmymohsen777-cmd fahmymohsen777-cmd released this 02 Dec 18:49

Added — Claude Code hooks: survive auto-compact

Anthropic moved Claude Code's auto-compact trigger for 1M-context models from ~97% of the window down to 40%, and compaction replaces the whole conversation with a summary — early-session detail is lost. DevOS memory lives on disk; v1.4 wires it into that lifecycle:

  • devos hooks install merges two hook entries into ./.claude/settings.json — a PreCompact hook and a SessionStart hook (matchers compact and startup). Existing settings and other hooks are preserved; re-running is idempotent. devos hooks with no argument prints the snippet for manual installation.
  • devos hook precompact saves a session snapshot — timestamp, trigger, session id, transcript path, git branch + uncommitted-file count — into the project's DevOS store (last 10 retained).
  • devos hook sessionstart injects a compact recall briefing as additionalContext: the latest snapshot, the top project memories, and a one-line knowledge-graph summary, capped at ~110 lines / 6 KB. Prints nothing when there is nothing worth injecting.
  • Both hook entry points are fail-soft by contract: garbage or missing stdin is tolerated, errors are swallowed, exit code is always 0.

Honest limit: the snapshot is a briefing, not the full transcript.

Tests

New hooks.test.ts (9 tests). Totals: 186 pass / 0 fail / 25 todo across 211 tests (scanner 131/0/25, CLI 17, all other suites green).

Install: npx devos-os hooks install