`SessionStart` hook reports original session ID instead of forked ID when using `--fork-session`

Resolved 💬 5 comments Opened Mar 26, 2026 by sekkr1 Closed May 22, 2026

Bug

When launching claude --resume <id> --fork-session, the SessionStart hook fires with session_id set to the original resumed session, not the newly created fork. transcript_path also contains the original ID. This makes it impossible for hooks to reliably track forked sessions.

Reproduction

# 1. Create a logging hook
cat > ~/.claude/hooks/test-fork.sh << 'EOF'
#!/usr/bin/env bash
INPUT=$(cat)
SID=$(printf '%s\n' "$INPUT" | jq -r '.session_id // empty')
TPATH=$(printf '%s\n' "$INPUT" | jq -r '.transcript_path // empty')
echo "$(date '+%H:%M:%S') PANE=$TMUX_PANE session_id=$SID transcript=$(basename "$TPATH" .jsonl)" >> /tmp/fork-test.log
EOF
chmod +x ~/.claude/hooks/test-fork.sh

# 2. Register it as a SessionStart hook in ~/.claude/settings.json

# 3. Start claude in a tmux pane, send a message to create the JSONL
#    Hook logs: session_id=ab1ee03f-... (correct)

# 4. Fork it
claude --dangerously-skip-permissions --resume ab1ee03f-e9cb-45f2-964f-0dfa0fcc84b2 --fork-session

# 5. Send a message in the fork to trigger JSONL creation

# 6. Check results

Observed behavior

# Hook log for the FORKED session:
15:17:47 PANE=%37 session_id=ab1ee03f-e9cb-45f2-964f-0dfa0fcc84b2 transcript=ab1ee03f-e9cb-45f2-964f-0dfa0fcc84b2

# But the actual fork created a DIFFERENT session:
$ comm -13 jsonl-before.txt jsonl-after.txt
/Users/dekel/.claude/projects/.../1a39ac7c-11c4-4712-9ea0-205652deb067.jsonl

| | Value |
|---|---|
| Hook session_id | ab1ee03f-... (the original — wrong) |
| Hook transcript_path | ab1ee03f-... (the original — wrong) |
| Actual fork JSONL created | 1a39ac7c-... (the real fork ID) |

Expected behavior

The SessionStart hook should report the new forked session's ID (1a39ac7c-...), not the original resumed session's ID.

Impact

Any SessionStart hook that tracks session IDs (e.g., for building fork-of-fork workflows, session persistence across tmux-resurrect, or session management UIs) gets the wrong ID for forked sessions. There is no workaround available purely through the hook system — the only current workaround is polling the filesystem for newly created .jsonl files and deducing the fork ID by diffing before/after snapshots, which introduces race conditions and complexity.

Environment

  • Claude Code v2.1.84
  • macOS Darwin 25.3.0
  • Tested in tmux with SessionStart hook

t. Clanker :robot:

View original on GitHub ↗

This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗