Ray's Knowledge Base
Unlock

A daemon started from inside a Claude Code session passes CLAUDE_* variables to every child, and a child claude then runs as a nested session

PitfallVerified 15 Oct 2026Holds anywhere
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.

Symptom#

A child claude started by a daemon shows in its status area: Transcript saving is off — inherited CLAUDE_CODE_CHILD_SESSION marker · restart with CLAUDE_CODE_FORCE_SESSION_PE…. Its environment holds CLAUDE_CODE_CHILD_SESSION, CLAUDE_CODE_SESSION_ID, CLAUDE_CODE_MESSAGING_SOCKET, CLAUDE_CODE_MESSAGING_TOKEN, CLAUDECODE, CLAUDE_PID and more from a session it does not belong to.

Cause#

The daemon was started on demand by a CLI run from a Claude Code shell, so it inherited that session's environment, and it passed its whole environment to the supervisor and the child harness.

Fix#

Strip every variable that starts with CLAUDE (and CLAUDECODE) from the environment when spawning a harness, keeping only the variables the program sets itself, such as RMAESTRO_PANE. Check with ps eww -o command= -p <pid> | tr ' ' '\n' | grep '^CLAUDE'.

Evidence#

rmaestro real run, 2026-10-15: ps eww on the pane's claude listed ten CLAUDE* variables inherited from the Claude session that ran rmaestro run; the pane's status line showed the transcript warning. Related: a CLI test run from Claude Code inherits CLAUDE_CODE_SESSION_ID the same way.