Skip to content

Instantly share code, notes, and snippets.

@Nucs
Created December 15, 2025 15:42
Show Gist options
  • Select an option

  • Save Nucs/e4ed7c08dfdd517bbcdae5a10accce0e to your computer and use it in GitHub Desktop.

Select an option

Save Nucs/e4ed7c08dfdd517bbcdae5a10accce0e to your computer and use it in GitHub Desktop.
Claude Code hook to print SessionId and cli command "claude --resume <session_id>" for convenient copy for later resume or restart.
{
"hooks": {
"SessionEnd": [
{
"hooks": [
{
"type": "command",
"command": "node -e \"let i='';process.stdin.on('data',c=>i+=c);process.stdin.on('end',()=>{try{const d=JSON.parse(i);const r='claude --resume '+d.session_id+' --debug';const w=r.length+16;const ln='═'.repeat(w);console.error('\\n'+ln);console.error(' Dir: '+d.cwd);console.error(' Reason: '+d.reason);console.error(' Resume: '+r);console.error(ln);process.exit(2)}catch(e){}})\""
}
]
}
]
}
}
@Nucs
Copy link
Author

Nucs commented Dec 15, 2025

image

Just add the hook to your ~.claude\settings.json (create if not existent).
The hook doesn't (and can't) persist the arguments so just add your favorite ones in the hook.
The debug and dangerous permissions are not necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment