This repository was archived by the owner on Feb 14, 2026. It is now read-only.
fix(sdk): strip CLAUDECODE env var when spawning Claude Code#169
Open
cruzanstx wants to merge 1 commit intoslopus:mainfrom
Open
fix(sdk): strip CLAUDECODE env var when spawning Claude Code#169cruzanstx wants to merge 1 commit intoslopus:mainfrom
cruzanstx wants to merge 1 commit intoslopus:mainfrom
Conversation
Claude Code 2.1+ sets a CLAUDECODE environment variable and refuses to launch if it detects it already present, treating it as a nested session. Since happy-cli legitimately spawns Claude Code as a child process (not a nested session), the env var must be stripped before spawning. Without this fix, every remote session immediately crashes with "Claude Code process exited with code 1" and retries 3 times before giving up. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CLAUDECODEenvironment variable and blocks launch if it's already present (nested-session detection)process.envunchanged to the child Claude Code process, causing it to immediately exit with code 1CLAUDECODEfrom the child process environment before spawningRoot Cause
Claude Code 2.1.41 introduced nested-session detection that checks for the
CLAUDECODEenv var. Since happy-cli is itself launched by Claude Code (or inherits the env), the spawned child process sees this variable and refuses to start:The
getCleanEnv()path (used for command-only mode) already strips problematic env vars, but the normal spawn path passesprocess.envdirectly.Changes
src/claude/sdk/query.ts: Always deleteCLAUDECODEfrom the child process environment, regardless of spawn mode.Test plan
claude --versionstill works (command-only mode usesgetCleanEnv())🤖 Generated with Claude Code