[BUG] `claude --print` produces no output when `CLAUDECODE` env var is unset inside a session
Resolved 💬 3 comments Opened Feb 28, 2026 by harupy Closed Mar 3, 2026
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Running claude --print hello from within a Claude Code session (e.g., via Bash tool) is blocked by the nested session check. When bypassing the check by unsetting CLAUDECODE, the command exits 0 but produces no output at all.
What Should Happen?
claude --print is a non-interactive subcommand. It should either work inside a Claude Code session without triggering the nested session guard, or produce correct output when the guard is bypassed.
Error Messages/Logs
⏺ Bash(claude --print hello)
⎿ Error: Exit code 1
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.
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.
⏺ Claude Code can't be launched inside another Claude Code session — it detects the nested session and blocks it.
You'd need to run claude --print hello from a separate terminal outside of this Claude Code session, or unset the
CLAUDECODE environment variable first:
⏺ Bash(unset CLAUDECODE && claude --print hello)
⎿ (No output)
Steps to Reproduce
- Start a Claude Code session
- Ask Claude to run
claude --print hellovia the Bash tool - Observe the nested session error
- Run
CLAUDECODE= claude --print "hello" 2>&1 - Command exits 0 but produces no output
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.63
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
VS Code integrated terminal
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗