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 .…