Skip to content

Tell the user when Claude Code didn't load Leaf's hooks module - #5959

Merged
max-sixty merged 8 commits into
mainfrom
leaf-mod-display-missing
Nov 14, 2026
Merged

max-sixty merged 8 commits into
mainfrom
leaf-mod-display-missing

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

When Claude Code didn't load Leaf's hooks module into a session holding a page, Leaf's Stop hook now tells the user, once per Claude Code process. Claude Code refuses a module it can't validate and reports the refusal only in its debug log. When it refused hooks/claude-code.ts after #5907, sessions lost their band, turn-end clerk and thread forks, and all Max saw was the band gone.

The signal comes from the pages follower, which only the module starts: it now records the Claude Code process it runs in. A Stop that ends the turn of a session holding a page, in a process no follower has recorded, prints a systemMessage. It says what is off, gives the claude plugin validate <plugin root> command that says why, and suggests /reload-plugins once an update fixes it. The notice records the process too, so it shows once.

To weigh: the notice prints only on a Stop that ends the turn, since a Stop that continues it already prints its own output. A turn that ends within about a second of its own first claim could warn wrongly, because the follower for that claim may not have started yet; the harness docstring says so.

Max asked for this after the missing band. On Claude Code 2.1.325, a throwaway mod showed that the module's processes have the Claude Code process as their parent, the pid a hook's CLAUDE_PID names, and that Claude Code parses a Stop hook's systemMessage. Tests mark the module as running for the sessions they hook. The new test fails without the notice. test_hooks.py, test_stop_guard.py and test_forks.py pass. test_session_lifecycle.py's server-start tests flake under load with and without this change (3 runs each).

This was written by Claude Code on behalf of max-sixty

`pnpm run check:hooks` now also runs `claude plugin validate .` from a pinned
`@anthropic-ai/claude-code` (2.1.325), which reports what Claude Code would
refuse before loading `hooks/claude-code.ts`. Nothing in CI asked Claude Code
before: the module's tests run in a Node stand-in, and hooks/tsconfig.json
leaves the module out because its declarations aren't on npm.

#5907 read the route variables with `$.env.get(name)` in a loop. Claude Code
refuses a module whose `$.env.get` takes anything but a string literal
(2.1.305 already did), so since #5907 landed every session that loaded the
module from a current install had no band, no turn-end clerk and no thread
forks, with the refusal only in Claude Code's debug log. On main this check
fails with that refusal; on #5947, which spells each name out, it passes.

The package's postinstall copies its platform binary into place, so
pnpm-workspace.yaml allows its build.
A new `newest-harnesses` job, on the daily schedule and on dispatch, installs
`@anthropic-ai/claude-code@latest` and `@earendil-works/pi-coding-agent@latest`
and runs `pnpm run check:hooks`. The pins move with Dependabot's weekly npm
group, while a user's Claude Code updates itself as each release ships, so a
release that refuses `hooks/claude-code.ts` or changes the API `hooks/pi.ts`
uses now turns the daily run red for tend within a day.

Rehearsed locally on this branch's tree with #5947's module: Claude Code 2.1.325
and Pi 1.5.2 installed, and the check passed.
…f its own

Max asked for no new job. The daily scheduled `test` job now ends by
installing the newest Claude Code and Pi and running `pnpm run check:hooks`
again, after every step that reads `node_modules` has finished.
hooks/pi.ts depends on Pi's API, and the nightly scan read only Claude Code's and Codex's release notes.
Claude Code refuses a hooks module it can't validate and says so only in its
debug log, so a session in which it refused `hooks/claude-code.ts` lost its band,
its turn-end clerk and its thread forks, and the user saw only the band gone.

The pages follower, which only the module starts, now records the Claude Code
process it runs in. A Stop that ends the turn of a session holding a page, in a
process no follower has recorded, prints a `systemMessage` naming what is off,
the `claude plugin validate` command that says why, and `/reload-plugins` for
after a fix; it records the process too, so the user hears it once per process.

Tests mark the module as running for the sessions they hook, as they mark the
hooks. On Claude Code 2.1.325 the module's processes have the Claude Code
process as parent, the same pid a hook's CLAUDE_PID names, and Claude Code
parses a Stop hook's `systemMessage` (both probed with a throwaway mod).
@max-sixty
max-sixty merged commit c7d0076 into main Nov 14, 2026
5 checks passed
@max-sixty
max-sixty deleted the leaf-mod-display-missing branch November 14, 2026 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants