Upstream feature: Claude Code hooks (session briefing and abandoned-approach guard) #22
Labels
No labels
upstream-feature
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
tim/omnimem#22
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Seen in upstream v7.0.3 (2026-10-21, Rust rewrite, still current in v7.0.5): https://code.squarecows.com/ric/omnimem/releases
What upstream does:
omnimem hookprovides Claude Code hooks that (1) put a project briefing into each session automatically and (2) block a tool call that repeats an abandoned approach (the graveyard check runs before the tool call, not only when the model remembers to callwarn_if_abandoned).Why it may fit: today both depend on the model following CLAUDE.md instructions (
briefingat session start,warn_if_abandonedbefore an approach). Hooks make them deterministic. The Python server already has the data (briefing,abandoned_approachesfast path); this would be a small client-side script or CLI entry point that calls the MCP tools and prints hook JSON.Rough size: small to medium. A hook script (SessionStart briefing, PreToolUse abandoned check) plus docs in
claude_config/and tests with the existing fakes. Open question: what the PreToolUse matcher keys on, since a tool call is not an "approach" text.Upstream version looked at: v7.0.5. Next run starts from there.
Close this issue if you do not want it. Comment
okto approve it for implementation.Ok.
Shipped as v6.11.1 (PRs #30, #32; release PRs #31, #33). Use 6.11.1, not 6.11.0: the v6.11.0 tag build failed in its test stage (the test image did not copy
claude_config/), so that tag has no images and no release; 6.11.1 carries the same code plus the fix.What it is:
claude_config/hooks/omnimem_hook.py, one stdlib-only file talking to the server over MCP.SessionStartinjects a read-only briefing, dead ends first.PreToolUsedenies a mutating tool call that puts an abandoned approach in place, with the reason and what worked instead.new_string,content, a mutating Bash command), neverold_string, as a whole abandoned name on word boundaries, ignoring case and separators. Reads are never blocked;ls vendor/kestrel-rspasses,cargo add kestrel-rsdoes not.warn_if_abandoned(query, project?, proposal?)andbriefing(read_only=True).Decisions to look at:
MCP_TRANSPORT=http. The deprecated SSE transport is not supported (the script says so on stderr and does nothing). The shipped default is stillsse.MCP_AUTH_TOKENbearer viaOMNIMEM_TOKEN; never sent over cleartext http to a non-loopback host.session-endhook (writes a session log; redaction and dedup it needs are unmeasured) and an installer.Verified against the real server (bearer auth on) under Python 3.13 and 3.12, and in the exact CI test image. A bug found on the way: ruff at py314 rewrote
except (A, B):into the 3.14-only form and broke the script on the user'spython3; pinned to py39 for that directory inruff.tomlwith two tests. The guard's effect on the dead-end benchmark is not measured (the 27% figure is for the prototype). Docs:docs/claude-code-hooks.md.