Interactive sessions that inherit CLAUDE_CODE_CHILD_SESSION silently skip local transcript persistence

Resolved 💬 2 comments Opened Jun 29, 2026 by Anthonyyp Closed Jul 3, 2026
_Disclaimer: written by Claude (Claude Code) after diagnosing this together with the user — Claude can lay out the technical details more succinctly on this one._

Summary

An interactive claude session that inherits CLAUDE_CODE_CHILD_SESSION=1 never writes its local transcript (~/.claude/projects/<cwd>/<id>.jsonl) — only the project dir + an empty memory/ get created. The session runs and connects to Remote Control fine, but claude --resume / --continue find nothing, and the conversation is unrecoverable locally once the process exits or the machine reboots.

This happens whenever a session is launched from a shell that inherited Claude Code's environment — e.g. spawning wt/cmd/claude from the Bash tool or a helper script inside another session — so the child carries the var despite being a genuinely independent top-level session.

Environment

  • Claude Code 2.1.181, Windows 11 (native install).

Confirmed by isolation

Stripping only CLAUDE_CODE_CHILD_SESSION from the child env — keeping every other inherited Claude var (CLAUDECODE, CLAUDE_CODE_SESSION_ID, CLAUDE_CODE_ENTRYPOINT, AI_AGENT, …) — restores normal persistence. The other inherited vars have no effect. Setting CLAUDE_CODE_FORCE_SESSION_PERSISTENCE=1 also restores it.

Minimal repro

# from inside a Claude Code session (so CLAUDE_CODE_CHILD_SESSION is set):
claude -n "repro"        # interactive; send a message, then /exit
ls ~/.claude/projects/<sanitized-cwd>/    # -> only memory/, no <id>.jsonl

The same launch from a clean shell, or with CLAUDE_CODE_CHILD_SESSION unset, persists normally.

Notes

The marker is appropriate for nested tool/hook/subagent processes, but it shouldn't suppress persistence for an independent interactive session spawned from a Claude-inheriting shell. The bundle includes a CLAUDE_CODE_FORCE_SESSION_PERSISTENCE override env var.

This may be the same class as the v2.1.170 changelog item ("Fixed sessions not saving transcripts … when launched from a shell that inherited Claude Code environment variables"), not fully covering this path on 2.1.181.

Workaround

Strip CLAUDE_CODE_CHILD_SESSION, or set CLAUDE_CODE_FORCE_SESSION_PERSISTENCE=1, in the launched session's environment.

Possibly related

#42589, #55406, #56294, #29205, #60790

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗