Feature request: reason-based filtering for SessionEnd hook matchers

Status Fixed / completed
Maintainer reply None cached
Activity 1 comment · opened Jun 30, 2026 · closed Aug 17, 2026

Currently, SessionEnd hooks fire on all session-end events including /clear and /compact. There's no way to opt out of specific reasons at the config level — the only workaround is to inspect the $REASON env var inside the hook script and exit early.

It would be useful to support reason-based filtering in the matcher field, e.g.:

"SessionEnd": [{
  "matcher": "reason!=clear",
  "hooks": [{ "type": "command", "command": "bash session-close.sh" }]
}]

This would allow hooks that do expensive work (git squash, push, Slack notification) to cleanly opt out of /clear and /compact firings without guard logic scattered across hook scripts.

Current workaround: check [[ "$REASON" == "clear" ]] at the top of the hook script and exit 0.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗