⌨️SessionEnd Hook
Also known as SessionEnd, CLAUDE_CODE_SESSIONEND_HOOKS_TIMEOUT_MS
The event when a session ends. It is used to clean up or save logs.
Think of it like
It is like you turn off the lights. You do it as you leave the room.
Example
Emma's SessionEnd hook copies the day's log to a shared folder. She sets a ten second timeout so it has time to finish.
Why it matters
It is the last chance to tidy up or record what a session did.
Definition
Example code
json
{
"hooks": {
"SessionEnd": [
{ "hooks": [{ "type": "command", "command": "./save-log.sh", "timeout": 10 }] }
]
}
}Common mistake
Key takeaways
- 1When a session ends. Five reasons.
- 2Cannot stop it. Cleanup only.
- 31.5 seconds. Unless raised.