SessionEnd hook doesn't fire on /exit command
Resolved 💬 3 comments Opened Jan 13, 2026 by mikemccabe Closed Feb 28, 2026
Description
The SessionEnd hook fires when exiting via ctrl-d but not when using the /exit slash command.
Steps to Reproduce
- Configure a SessionEnd hook in
~/.claude/settings.json:
{
"hooks": {
"SessionEnd": [
{
"hooks": [
{
"type": "command",
"command": "/bin/bash ~/.claude/session-end-hook.sh"
}
]
}
]
}
}
- Create a hook script that writes to
/dev/tty:
#!/bin/bash
input=$(cat)
session_id=$(echo "$input" | jq -r '.session_id // empty')
echo "To resume: claude --resume $session_id" > /dev/tty
- Start a claude session and exit with
/exit- hook does NOT fire - Start a claude session and exit with ctrl-d - hook DOES fire
Expected Behavior
SessionEnd hook should fire for both /exit and ctrl-d exits.
Documentation Note
The hooks documentation lists these SessionEnd reasons:
clearlogoutprompt_input_exitother
But the example JSON shows "reason": "exit" which isn't in this list. It's unclear whether /exit should use "exit", "other", or a new reason.
Environment
- macOS
- Claude Code CLI
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗