/clear does not fire SessionStart hook despite assigning a new session ID

Resolved 💬 3 comments Opened Feb 25, 2026 by ustunb Closed Mar 1, 2026

Summary

/clear assigns a new session_id (confirmed via /status), but does not fire the SessionStart hook event. This means any SessionStart hooks that set up per-session state — environment variables via $CLAUDE_ENV_FILE, directories, logging — are never re-invoked after /clear.

Reproduction

  1. Configure a SessionStart hook that logs to a file:

``json
{
"hooks": {
"SessionStart": [{
"matcher": "",
"hooks": [{
"type": "command",
"command": "INPUT=$(cat); echo \"$(date +%H:%M:%S) session_id=$(echo $INPUT | jq -r .session_id)\" >> /tmp/hook-debug.log"
}]
}]
}
}
``

  1. Launch a session — hook fires, log entry appears
  2. Run /status — note the session ID
  3. Run /clear
  4. Run /status — session ID has changed
  5. Check /tmp/hook-debug.logno new entry after /clear

Expected behavior

/clear should fire SessionStart with the new session ID, since it creates a new session. This would allow hooks to:

  • Update environment variables exported via $CLAUDE_ENV_FILE
  • Create per-session state directories
  • Reset session-scoped logging

Evidence

Tested systematically across 8 conditions (4 launch methods × 2 interaction states), 3 runs each (24 total executions). /clear never fires SessionStart in any case:

| Launch method | /clear (no interaction) | /clear (after interaction) |
|---|---|---|
| claude (fresh) | no hook fired | no hook fired |
| claude --resume | no hook fired | no hook fired |
| claude --continue | no hook fired | no hook fired |
| claude --resume --fork-session | no hook fired | no hook fired |

Impact

Any SessionStart hook that persists the session ID (e.g., via export VAR=... >> $CLAUDE_ENV_FILE) produces a stale value after /clear. The variable in subsequent Bash tool calls still holds the pre-clear session ID.

Environment

  • Claude Code v2.1.52
  • macOS Darwin 24.6.0

View original on GitHub ↗

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