Docs: Document the `SessionEnd` Hook
Subject: Docs: Document the SessionEnd Hook
Is your feature request related to a problem? Please describe.
The SessionEnd hook was introduced in version 1.0.85, but it is not mentioned in the official documentation. This prevents users from discovering and utilizing this hook for session cleanup, logging, or other automation tasks that should occur when a session is terminated.
Describe the solution you'd like
The official documentation for Claude Code hooks should be updated to include comprehensive details about the SessionEnd hook.
The following pages need to be updated:
- Get started with Claude Code hooks: The "Hook Events Overview" list should include
SessionEnd. - Hooks reference: A new section for
SessionEndshould be added under "Hook Events", detailing its functionality.
The new documentation for SessionEnd should cover:
- Trigger Conditions: When exactly does the hook fire? (e.g., on user exit,
Ctrl+D,/clear, etc.) - Input Payload: The JSON schema passed to the hook via stdin (e.g.,
session_id,transcript_path). - Matchers: Whether it supports any matchers (it's presumed to be a global event like
SessionStart). - Output Behavior: What is the expected output and can it affect the exit process?
- Example Use Case: A simple example, such as logging final session costs or cleaning up temporary files created during the session.
Additional context
The v1.0.85 changelog confirms the feature's existence:
Hooks: Introduced SessionEnd hook
Currently, the documentation only lists PreToolUse, PostToolUse, Notification, UserPromptSubmit, Stop, SubagentStop, PreCompact, and SessionStart.
Adding this documentation will help users build more robust and complete workflows with hooks. Thank you
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗