SessionEnd hook event — fires once on true session exit, supports agent/prompt hook types
Problem
The current Stop event fires after every response turn, making it unsuitable for end-of-session work. There is no hook event that fires once when the user genuinely exits or closes a Claude Code session. The agent and prompt hook types — which can invoke Claude reasoning — are restricted to tool events (PreToolUse, PostToolUse, PermissionRequest), leaving session-lifecycle events limited to dumb shell commands.
Requested Changes
- Add a
SessionEndevent (or rename/repurpose a variant ofStop) that fires exactly once when the user closes the session, not after every turn. Distinguish it from the existing intra-sessionStopevent. - Allow
agentandprompthook types onSessionEnd, so an intelligent summary/checkpoint can be written automatically without user intervention.
Concrete Use Case
A user wants an automatic session checkpoint — Claude writes a "where we left off" summary to a notes file on exit. This requires reasoning, not just a shell script. Currently impossible without a manual slash command.
Suggested Companion Feature — GDG-Style Output Versioning
For any hook or slash command that writes a file, consider supporting a generation-versioned filename pattern (inspired by IBM OS/360 Generation Data Groups) as an option — e.g., NOTES.G0001V00.md, NOTES.G0002V00.md — so writes never overwrite prior state. Users concerned about destructive overwrites could opt into this naming scheme via a hook output field or slash command convention. This gives a recoverable audit trail without requiring git for every personal notes file.
Workaround Today
Manual /checkpoint slash command in ~/.claude/commands/checkpoint.md. Works, but requires user discipline at session close.
---
Suggested by KG5ZSH — filed via Claude Code
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗