You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[FEATURE] Pre-exit Claude-action hook — let Claude perform actions before session ends #47612
I have searched existing requests and this feature hasn't been requested yet
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:
User types /exit
PreSessionEnd event fires
Claude receives the configured prompt and executes it — reading/writing files, calling tools as needed
Thank you for flagging the potential duplicates. Let me address each one:
#16886 — Genuine overlap. Both issues ask for a pre-exit hook where Claude can act autonomously (run a prompt, not just a shell command). My issue covers more use cases, but the core ask is the same. I'd support consolidating these if the maintainers agree.
#39085 — Partial overlap only. That issue asks for a user-facing reminder or prompt before exit — a UX nudge. My issue asks for Claude to act autonomously at session end without user interaction. Different emphasis, different solution space.
#12755 — Not a duplicate. That issue is specifically about shell-command hooks that block /exit via non-zero exit code. My issue explicitly cites #12755 and argues that mechanism is insufficient — it can prevent exit but cannot trigger autonomous Claude action. The two issues are complementary, not redundant.
Suggestion: If maintainers agree #16886 and #47612 are asking for the same thing, consolidation makes sense. But #39085 and #12755 address meaningfully different problems and should remain open independently.
Use case: auto-run verification/cleanup skills before session end
I run a verification-before-completion skill that audits uncommitted changes, stale TODO items, and plan file updates before I finish a session. Today I have to remember to invoke it manually — and I forget ~50% of the time.
A PreSessionEnd hook (or BeforeExit) that lets Claude execute a prompt/skill autonomously would solve this cleanly. The existing Stop hook fires a shell command after Claude responds — it can't trigger Claude to act (read files, run tools, update plans).
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.
Activity
github-actions commentedon Apr 13, 2026
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
SWSovereign commentedon Apr 14, 2026
Thank you for flagging the potential duplicates. Let me address each one:
#16886 — Genuine overlap. Both issues ask for a pre-exit hook where Claude can act autonomously (run a prompt, not just a shell command). My issue covers more use cases, but the core ask is the same. I'd support consolidating these if the maintainers agree.
#39085 — Partial overlap only. That issue asks for a user-facing reminder or prompt before exit — a UX nudge. My issue asks for Claude to act autonomously at session end without user interaction. Different emphasis, different solution space.
#12755 — Not a duplicate. That issue is specifically about shell-command hooks that block /exit via non-zero exit code. My issue explicitly cites #12755 and argues that mechanism is insufficient — it can prevent exit but cannot trigger autonomous Claude action. The two issues are complementary, not redundant.
Suggestion: If maintainers agree #16886 and #47612 are asking for the same thing, consolidation makes sense. But #39085 and #12755 address meaningfully different problems and should remain open independently.
luisbarcia commentedon Apr 27, 2026
Use case: auto-run verification/cleanup skills before session end
I run a
verification-before-completionskill that audits uncommitted changes, stale TODO items, and plan file updates before I finish a session. Today I have to remember to invoke it manually — and I forget ~50% of the time.A
PreSessionEndhook (orBeforeExit) that lets Claude execute a prompt/skill autonomously would solve this cleanly. The existingStophook fires a shell command after Claude responds — it can't trigger Claude to act (read files, run tools, update plans).What I'd configure:
{ "hooks": { "PreSessionEnd": [{ "type": "prompt", "prompt": "/verification-before-completion" }] } }This aligns with #47612's ask — the mechanism needs to be a Claude-action hook (prompt-based), not just a shell-command hook like the
Stopevent.github-actions commentedon May 30, 2026
Closing for now — inactive for too long. Please open a new issue if this is still relevant.
github-actions commentedon Jul 31, 2026
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.