Add lifecycle hooks for session clear and exit events

Resolved 💬 3 comments Opened Apr 14, 2026 by bb7642 Closed May 24, 2026

Problem

Hooks currently only fire on tool-call events (pre/post). There's no way to trigger actions when a session ends — either via /clear, exit, or terminal close.

Use case

I use CLAUDE.md to instruct Claude to save conversation history to markdown files and commit them to git at the end of each session. This works when I remember to ask, but there's no way to automate it. A pre-clear or pre-exit hook would allow running a shell command (or prompting Claude to act) before context is lost.

Proposal

Add hook events for session lifecycle:

  • pre-clear — fires before /clear wipes context
  • pre-exit — fires before the session terminates

These would follow the same settings.json hook format as existing tool hooks.

View original on GitHub ↗

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