Add SessionRename hook event
Feature Request
Problem
When a user runs /rename to set a custom session name, there's no hook event that fires. This makes it impossible to programmatically react to session renames — for example, syncing the session name to a tmux session name.
Current Workaround
The only way to detect a rename is by polling the JSONL transcript file for "type":"custom-title" entries via the statusLine command. This works but is architecturally backwards — polling for a rare, discrete event.
Proposed Solution
Add a SessionRename hook event that fires when /rename is executed. The hook input should include:
{
"session_id": "...",
"old_name": "...",
"new_name": "...",
"transcript_path": "..."
}
Context
/renamealready writes acustom-titleentry to the transcript JSONL- Since v2.1.47,
/renameemits OSC escape sequences to update the terminal tab title - The hook system already covers session lifecycle events (
SessionStart,SessionEnd) —SessionRenameis a natural addition - Other recent hook additions (
ConfigChange,WorktreeCreate,WorktreeRemove) set precedent for hooking into local CLI actions
Use Case
Syncing Claude Code session names to tmux session names, so tmux list-sessions shows meaningful names instead of claude-XXXXX. This also enables cleanup of stale tmux sessions when a session is resumed in a new terminal.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗