Make Claude Code hook wiring less invasive and self-contained#15
Merged
Conversation
Drop the PreToolUse hook that spawned a process before every tool call,
and scope PostToolUse to mutating tools (Edit|Write|MultiEdit|
NotebookEdit|Bash) so read-only tools never spawn anything.
Add hooks/hooks.json and a statusLine entry in plugin.json so the
marketplace plugin auto-wires hooks and the statusline via
${CLAUDE_PLUGIN_ROOT}, with no manual settings.json editing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Reduces the Claude Code adapter's footprint and makes the marketplace plugin wire itself with no manual
settings.jsonediting.Why
The adapter wired four hooks, two with
matcher: "*":PreToolUse/*spawnedbunbefore every tool call (Read, Grep, Glob, everything) just to set a "thinking" state — latency on every tool, for a mood the post-action states already cover.PostToolUse/*spawnedbunafter every tool, including read-only ones that don't change the pet's mood.Changes
PreToolUseand deletedhooks/pre-tool-use.sh. (Thethinkingevent stays incore/events.ts— the Pi adapter still emits it.)PostToolUsefrom"*"to"Edit|Write|MultiEdit|NotebookEdit|Bash", so read-only tools never spawn a process.hooks/hooks.jsonso/plugin install campyauto-wires the three lean hooks (SessionStart, scopedPostToolUse,Stop) via${CLAUDE_PLUGIN_ROOT}.statusLineblock toplugin.jsonso the statusline is plugin-provided too.CLAUDE.mdto match.Net: 4 hooks → 3, the only per-tool hook fires on mutating tools instead of everything, and the marketplace install is self-contained.
Testing
npm run typecheckcleanhooks.jsonandplugin.jsonvalidated as JSON