fix(cli): prevent CLAUDE_CODE_ENTRYPOINT leak into local spawn (#452)

extractSDKMetadataAsync() calls query() which sets
CLAUDE_CODE_ENTRYPOINT='sdk-ts' on the current process env.
When claudeLocal() later spawns the claude CLI, the child
inherits this env var, causing Claude Code to treat the
session as SDK-launched. This makes the session invisible
to `claude --resume`.

Strip CLAUDE_CODE_ENTRYPOINT from the child env so the
local spawn uses its own default entrypoint.

Closes #450
This commit is contained in:
Haoqing Wang
2026-04-14 13:29:05 +08:00
committed by GitHub
parent fadc0def8f
commit 74377fafee
+8 -1
View File
@@ -76,8 +76,15 @@ export async function claudeLocal(opts: {
// Prepare environment variables
// Note: Local mode uses global Claude installation
//
// SDK metadata extraction (extractSDKMetadataAsync → query()) sets
// CLAUDE_CODE_ENTRYPOINT='sdk-ts' on the current process. If leaked
// into the local spawn, Claude Code thinks it was SDK-launched and
// excludes the session from `claude --resume`. Destructure it out
// so the child uses its own default entrypoint.
const { CLAUDE_CODE_ENTRYPOINT: _, ...cleanEnv } = process.env
const env = {
...process.env,
...cleanEnv,
DISABLE_AUTOUPDATER: '1',
...opts.claudeEnvVars
}