[BUG] CLAUDE_CODE_BRIDGE_SESSION_ID unset in an EnterWorktree-spawned session whose own naming embeds a working session id

Status Open
Reported on v2.1.263
Maintainer reply None cached
Activity 0 comments · opened Sep 9, 2026

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

  1. Start a Claude Code session, have it use the EnterWorktree tool (or start via claude remote-control --spawn worktree) to create a worktree.
  2. Note the resulting directory/branch name has the shape bridge-cse_<id> (or worktree-bridge-cse_<id>).
  3. Inside that session, run compgen -v | grep -iE 'claude|bridge|remote' — CLAUDE_CODE_BRIDGE_SESSION_ID is absent; CLAUDE_CODE_BRIDGE_OWNER_ACCOUNT_UUID, CLAUDE_CODE_BRIDGE_OWNER_ORG_UUID, CLAUDE_CODE_CHILD_SESSION are present instead.
  4. 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.

View original on GitHub ↗