[FEATURE] Pre-exit Claude-action hook — let Claude perform actions before session ends

Resolved 💬 4 comments Opened Apr 13, 2026 by SWSovereign Closed May 30, 2026

Preflight Checklist

  • [x] I have searched existing requests and this feature hasn't been requested yet
  • [x] This is a single feature request (not multiple features)

Problem Statement

There is currently no way for Claude to perform actions (file writes, tool calls) before a session ends. Hooks today only support shell commands, and even those don't reliably fire on /exit (#35892).

My concrete use case: I maintain project memory files that Claude reads at session start to pick up where we left off. Before every session ends, Claude needs to update those files with current status and next steps. Today, I have to remember to ask Claude manually before typing /exit. If I forget, context is lost and the next session starts cold.

This goes beyond what was requested in #12755 (closed/locked) and #9293 — those asked for shell-level pre-exit hooks. What's needed is the ability for Claude itself to be the actor during the exit flow.

Proposed Solution

Add a PreSessionEnd hook event where Claude receives and processes a configurable prompt before the session terminates.
Example configuration:
{
"hooks": {
"PreSessionEnd": [
{
"type": "prompt",
"prompt": "Update project memory files with current session status, decisions made, and next steps. Then offer to commit and push any uncommitted changes.",
"timeout": 30
}
]
}
}

Behavior:

  1. User types /exit
  2. PreSessionEnd event fires
  3. Claude receives the configured prompt and executes it — reading/writing files, calling tools as needed
  4. Session ends after Claude completes

Why this matters beyond my use case

  • Auto-commit reminders — detect and act on uncommitted changes (#12755's original ask)
  • Session summaries — write a summary of what was accomplished
  • Cleanup tasks — close temp files, stop background processes
  • Cost logging — capture /cost data to a file (#9293's original ask)

The common thread: a shell command can detect these situations, but only Claude can act on them intelligently.

Alternative Solutions

_No response_

Priority

Medium - Would be very helpful

Feature Category

Configuration and settings

Use Case Example

_No response_

Additional Context

_No response_

View original on GitHub ↗

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