Skip to content

fix(gemini): use AfterTool instead of PostToolUse for Gemini CLI hooks#824

Open
Tibsfox wants to merge 1 commit intogsd-build:mainfrom
Tibsfox:fix/gemini-hook-event
Open

fix(gemini): use AfterTool instead of PostToolUse for Gemini CLI hooks#824
Tibsfox wants to merge 1 commit intogsd-build:mainfrom
Tibsfox:fix/gemini-hook-event

Conversation

@Tibsfox
Copy link
Contributor

@Tibsfox Tibsfox commented Feb 28, 2026

Summary

Gemini CLI uses AfterTool as the post-tool hook event name, not PostToolUse (which is Claude Code's event name). The installer was registering the context monitor under PostToolUse for all runtimes, causing Gemini to print an "Invalid hook event name" warning on every run and silently disabling the context monitor hook.

The comment at install.js:2034 even noted the assumption: "Gemini shares same hook system as Claude Code for now" — this turned out to be incorrect for hook event names.

Changes

  • bin/install.js: Introduce postToolEvent variable that resolves to AfterTool when runtime === 'gemini', PostToolUse otherwise. Used for both the install and registration paths.
  • bin/install.js (uninstall): Clean up both PostToolUse and AfterTool entries for backward compatibility — users who installed with the old PostToolUse key need their stale entries removed on uninstall/reinstall.
  • hooks/gsd-context-monitor.js: Runtime-aware hookEventName in output metadata (detects Gemini via GEMINI_API_KEY env var).
  • docs/context-monitor.md: Document both event names, add Gemini-specific manual registration example.

Verification

  1. Install GSD for Gemini: npx get-shit-done-cc --gemini --global
  2. Check ~/.gemini/settings.json — context monitor should be under hooks.AfterTool, not hooks.PostToolUse
  3. Run gemini -p "ping" --output-format text — no "Invalid hook event name" warning
  4. Uninstall — both AfterTool and PostToolUse entries cleaned up

Backward Compatibility

  • Existing Gemini installs with PostToolUse entries: The uninstall path now cleans up both event names, so reinstalling will migrate to AfterTool automatically.
  • Claude Code / OpenCode installs: No change — they continue using PostToolUse.

Closes #750

🤖 Generated with Claude Code

Gemini CLI uses AfterTool as the post-tool hook event name, not
PostToolUse (which is Claude Code's event name). The installer was
registering the context monitor under PostToolUse for all runtimes,
causing Gemini to print "Invalid hook event name" warnings on every
run and silently disabling the context monitor.

Changes:
- install.js: use runtime-aware event name (AfterTool for Gemini,
  PostToolUse for others) when registering context monitor hook
- install.js: uninstall cleans up both PostToolUse and AfterTool
  entries for backward compatibility with existing installs
- gsd-context-monitor.js: runtime-aware hookEventName in output
- docs/context-monitor.md: document both event names with Gemini
  example

Closes gsd-build#750

Co-Authored-By: Claude Opus 4.6 <[email protected]>
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.

Gemini install uses invalid PostToolUse hook event (should be AfterTool)

1 participant