[BUG] CLAUDE_CODE_BRIDGE_SESSION_ID unset in an EnterWorktree-spawned session whose own naming embeds a working session id
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
$CLAUDE_CODE_BRIDGE_SESSION_ID (documented at code.claude.com/docs/en/env-vars as set while a session has an active Remote Control connection, in session_<id> form) is unset in a session that was spawned via the EnterWorktree tool. However, the worktree's own directory and branch name (bridge-cse_<id> / worktree-bridge-cse_<id>) embed that same id, and https://claude.ai/code/session_<id> built from it is a real, working link to the session. So the harness clearly knows the id — it used it to name the worktree — but never exposes it to the running process's environment under any documented variable name.
What Should Happen?
A documented, non-RC-gated env var (or $CLAUDE_CODE_BRIDGE_SESSION_ID itself, populated for EnterWorktree-spawned sessions too, not just live-RC-connected ones) should carry this id, so a session can reliably build a working link back to itself without parsing the harness's own internal directory/branch naming convention.
Error Messages/Logs
Steps to Reproduce
- Start a Claude Code session, have it use the
EnterWorktreetool (or start viaclaude remote-control --spawn worktree) to create a worktree. - Note the resulting directory/branch name has the shape
bridge-cse_<id>(orworktree-bridge-cse_<id>). - Inside that session, run
compgen -v | grep -iE 'claude|bridge|remote'—CLAUDE_CODE_BRIDGE_SESSION_IDis absent;CLAUDE_CODE_BRIDGE_OWNER_ACCOUNT_UUID,CLAUDE_CODE_BRIDGE_OWNER_ORG_UUID,CLAUDE_CODE_CHILD_SESSIONare present instead. - Visit
https://claude.ai/code/session_<id>(substituting the id from step 2) — it resolves to the actual running session.
Claude Model
None
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.263
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
Other
Additional Information
Discovered while building a PR-footer feature that tries to link back to the originating session; docs reference $CLAUDE_CODE_BRIDGE_SESSION_ID as the mechanism, but it doesn't fire for this spawn path even though the harness demonstrably has the id.