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

  1. Configure a SessionEnd hook in ~/.claude/settings.json:
{
  "hooks": {
    "SessionEnd": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "/bin/bash ~/.claude/session-end-hook.sh"
          }
        ]
      }
    ]
  }
}
  1. 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
  1. Start a claude session and exit with /exit - hook does NOT fire
  2. 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:

  • clear
  • logout
  • prompt_input_exit
  • other

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

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗