Skip to content
This repository was archived by the owner on Feb 14, 2026. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/claude/sdk/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,10 @@ export function query(config: {

// Spawn Claude Code process
// Use clean env for global claude to avoid local node_modules/.bin taking precedence
const spawnEnv = isCommandOnly ? getCleanEnv() : process.env
// Always strip CLAUDECODE env var to prevent nested-session detection (Claude Code 2.1+)
const baseEnv = isCommandOnly ? getCleanEnv() : { ...process.env }
delete baseEnv.CLAUDECODE
const spawnEnv = baseEnv
logDebug(`Spawning Claude Code process: ${spawnCommand} ${spawnArgs.join(' ')} (using ${isCommandOnly ? 'clean' : 'normal'} env)`)

const child = spawn(spawnCommand, spawnArgs, {
Expand Down