Feature: SessionStart hook should fire on /branch with source:"branch" and branch_name
Use case
I run a homelab with long-lived orchestration sessions, one tmux window per Claude Code session. When I /branch a session to spin off a side effort (debug a service, explore an idea without polluting the parent's context), I want automation to react: open a named tmux window for the branch, register it in my external coordination system, and set per-branch identity so the branch announces itself correctly to the other agents.
Today none of that is possible, because no hook distinguishes a branched session from anything else.
Current behavior
/branchcreates a new session, but the hooks reference lists theSessionStartsources asstartup,resume,clear, andcompact. There is nothing for branch/fork, so my hooks can't tell "this session was just branched off X" apart from an ordinary startup./branchaccepts a name, but that name is not exposed to hooks at all.- The parent session id is likewise unavailable to the branched session (this was previously requested in #42656, which was closed as stale and is now locked, with the bot suggesting a new issue be filed — hence this one).
My only workaround has been copying the transcript .jsonl to a new uuid and resuming that, which lets my own tooling inject the metadata — but the sessions docs explicitly warn that the transcript format is internal and changes between releases, so I'd really rather not build on it.
Proposed behavior
When a session is created via /branch (or /fork), fire SessionStart with:
source: "branch"branch_name: the name given to/branch, if anyparent_session_id: the session id the branch was created from
That's enough for hooks to do everything in the use case above with zero reliance on internal file formats. Precedent already exists: compact-triggered sessions got parent_session_id handling discussed in #29094, so the plumbing for parent lineage appears to be there.
Related issues
- #42656 — hook event for
/branch+ parent session id access (closed stale, locked; this supersedes it) - #32631 — conversation branching spec including
/mergeand/tree; a branch source on SessionStart is the hook-side counterpart - #69712 — surfacing
/branchsessions in the agent view; same underlying need to treat branches as first-class, observable events - #60845 — persisting
forked_from_idlineage in the transcript - #73054 — companion request: CLI-invocable session branch; scripted branches should emit this same hook
Environment
Claude Code CLI on Linux, interactive tmux-based workflow, v2.x current.