Nested session check blocks non-interactive subcommands like `claude plugin validate`
Summary
The nested session detection (CLAUDECODE env var check) blocks all claude subcommands when run from within a Claude Code session, including non-interactive utility commands like claude plugin validate. These commands don't create a competing session — they're stateless validation checks — but they're rejected with the same error as a full nested session.
Reproduction
- Open a Claude Code session
- From within the session (e.g., via a lint script), run:
``bash``
claude plugin validate plugin.json
- Result:
````
Error: Claude Code cannot be launched inside another Claude Code session.
Nested sessions share runtime resources and will crash all active sessions.
To bypass this check, unset the CLAUDECODE environment variable.
Expected behavior
Non-interactive subcommands (plugin validate, plugin list, --version, --help, etc.) should bypass the nested session check since they don't create a competing interactive session or share runtime resources.
Workaround
Clear the env var before invoking:
{
"scripts": {
"lint": "CLAUDECODE= claude plugin validate plugin.json"
}
}
Context
This commonly hits when claude plugin validate is used as a lint step in package.json scripts, which then get invoked by pre-commit hooks or pnpm pre-commit during a Claude Code session. The error message suggests the check is designed to prevent interactive nested sessions from crashing, but the blast radius catches read-only utility commands too.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗