Menu

Leave a session handoff when Claude Code exits, with a SessionEnd hook
📰

Leave a session handoff when Claude Code exits, with a SessionEnd hook

DEV Community: productivity·Vildanden·10 days ago
#ocPVIsLw
#devtoproductivity#devto#dev#claude#changed
Long article (554 words) — no AI summary yet.
Reading 0:00
15s threshold

A Claude Code session can end while the next person — or your future self — still has to reconstruct the branch, the dirty tree, and what was mid-flight. A SessionEnd hook runs when the session exits, so you can write a short local handoff without remembering to paste a recap.

Keep the hook local, fast, and free of network calls.

The hook

Save this as .claude/hooks/session_end_handoff.py and make it executable:

#!/usr/bin/env python3 import json import subprocess import sys from datetime import datetime , timezone from pathlib import Path

try : json . load ( sys . stdin ) except json . JSONDecodeError : pass

def git ( * args : str ) -> str : try : result = subprocess . run ( [ "git" , * args ] , text = True , stdout = subprocess . PIPE , stderr = subprocess . DEVNULL , timeout = 4 , ) return result . stdout . strip ( ) if result . returncode == 0 else "" except ( OSError , subprocess .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.