Skip to content

Workers fail with "Claude Code cannot be launched inside another Claude Code session" (CLAUDECODE env var) #10

@RedcoatAsher

Description

@RedcoatAsher

Problem

Starting with Claude Code v2.1.71+, launching subtask send from within a Claude Code session fails immediately with:

Error: Claude Code cannot be launched inside another Claude Code session.
Nested sessions share runtime resources and will crash all active sessions.

Root Cause

Claude Code now sets CLAUDECODE=1 in its process environment. When subtask spawns a worker (which runs claude), the child process inherits this env var and hits the nesting guard:

if (process.env.CLAUDECODE && !process.argv.includes("--team-name")) {
  // prints error and exits
}

Workaround

Clearing the env var before spawning the worker process works:

CLAUDECODE="" subtask send <task> "prompt"

Suggested Fix

When subtask spawns worker processes, explicitly unset CLAUDECODE from the child process environment:

const env = { ...process.env };
delete env.CLAUDECODE;
// spawn worker with this env

Context

Environment

  • macOS (Darwin 25.3.0)
  • Node.js
  • subtask latest (installed via skill)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions