Skip to content

SessionEnd hook does not fire with /clear as documentation states. #6428

Closed as not planned

Description

@jeremynsl

Docs say:
SessionEnd

Runs when a Claude Code session ends. Useful for cleanup tasks, logging session statistics, or saving session state.

The reason field in the hook input will be one of:

**clear - Session cleared with /clear command**
logout - User logged out
prompt_input_exit - User exited while prompt input was visible
other - Other exit reasons

However, I spent a long time testing with --debug and couldn't make SessionEnd fire on /clear command. The SessionStart does fire of course since its a new session after clearing. I'd expect /clear to fire SessionEnd and then SessionStart in succession.

Activity

  1. mysehyunhope commented on Nov 24, 2025

    @mysehyunhope

    It looks like this issue has been solved in version 2.0.50. I’ve been testing it since I saw this bug report and can confirm that Claude now invokes SessionEnd and SessionStart.

    claude code cli, ubuntu(wsl)

  2. github-actions commented on Dec 25, 2025

    @github-actions

    This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

  3. kyakumithis commented on Jan 16, 2026

    @kyakumithis

    Same issue on Windows 11 with v2.1.9.

    SessionEnd hook doesn't trigger for any exit method (/clear, /exit, Ctrl+D, or closing VS Code window).

    I've posted detailed findings including test results on #17885, and submitted a full bug report at #18500 with Windows-specific details.

    Key finding: On Windows, even Ctrl+D does NOT trigger the hook (unlike macOS where it reportedly works).

  4. bkjou commented on Feb 16, 2026

    @bkjou

    Related: filed #26052 requesting a PreClear hook event as a broader solution. Even if SessionEnd is fixed to fire on /clear, a dedicated PreClear hook would give users a reliable pre-clear interception point for session logging and state preservation.

  5. seanmartinsmith commented on Apr 24, 2026

    @seanmartinsmith

    adjacent context from testing /clear identity behavior on v2.1.119, windows 11:

    net effect: tools doing session identity tracking across /clear (mcp servers, external session indexers, hook-based attribution) have to read the transcript filesystem directly since no env/process signal rotates. a SessionEnd:clear event plus a refreshed pid file would close the identity-resolution gap.

  6. github-actions commented on May 28, 2026

    @github-actions

    Closing for now — inactive for too long. Please open a new issue if this is still relevant.

  7. github-actions commented on Jul 27, 2026

    @github-actions

    This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.

  8. locked as resolved and limited conversation to collaborators on Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:corebugSomething isn't workinghas reproHas detailed reproduction stepsstaleIssue is inactive

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions