[FEATURE] Expose CLAUDE_CODE_ENVIRONMENT_KIND to child processes (Bash tool, hooks, plugins)
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
When building plugins/skills for Claude Code, there is no way to detect whether the session is running in remote control mode (e.g., accessed from the mobile app or web) vs locally.
I maintain a commit plugin that opens $EDITOR (emacsclient) for the user to review the commit message before committing. When the user is connected via Remote Control from the Android app, emacsclient launches on the server side where the user cannot interact with it, causing the session to hang indefinitely.
I need to conditionally skip the editor launch when the session is remote, but there is currently no environment variable or API available to child processes to determine the session type.
The internal variable CLAUDE_CODE_ENVIRONMENT_KIND exists and is set to "bridge" for remote control sessions, but it is not propagated to child processes spawned by the Bash tool.
Proposed Solution
Expose CLAUDE_CODE_ENVIRONMENT_KIND as an environment variable to all child processes spawned by Claude Code, including:
- Bash tool executions
- Hook scripts
- MCP server processes
This would allow plugins and skills to check the value and adapt their behavior accordingly. For example:
"local"or unset → launch$EDITORnormally"bridge"→ skip editor, use alternative workflow
Alternative Solutions
- Checking
SSH_CONNECTIONorDISPLAYenvironment variables — unreliable because a user may SSH from another PC for normal local use, or use a terminal-based editor. - Using a local config file to toggle behavior — impractical because the same user switches between local and remote clients dynamically.
- Asking the user each time — poor UX for local sessions where the editor always works fine.
- Using a timeout on the editor — cannot distinguish between "user is editing" and "editor opened but nobody can interact with it".
Priority
Medium - Would be very helpful
Feature Category
API and model interactions
Use Case Example
- I have a Claude Code commit plugin that generates a commit message and opens
$EDITORfor review - When working from my PC, emacsclient opens and I edit the message — works perfectly
- When I switch to the Android app (Remote Control), the same plugin launches emacsclient on the server where I cannot see or interact with it
- The session hangs until timeout (600 seconds)
- With
CLAUDE_CODE_ENVIRONMENT_KINDexposed, the plugin could detect"bridge"mode and skip the editor step, using the AI-generated message directly
Additional Context
Related issues:
- #17188 — Expose Session Metadata via Environment Variables and API
- #25642 — Expose session ID as
$CLAUDE_SESSION_IDenvironment variable
The variable CLAUDE_CODE_ENVIRONMENT_KIND already exists internally, as seen in the bridge session spawn code (referenced in #28839). The request is simply to propagate it to child processes.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗