[BUG] Silent transcript loss + missing --resume entry via inherited CLAUDE_CODE_CHILD_SESSION (dev server started from a Claude shell)

Open 💬 0 comments Opened Jul 2, 2026 by bohyunkang

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?

A session runs and responds completely normally, but on /exit nothing is written to ~/.claude/projects/..., and the session never appears in claude --resume. There is no warning, so it is indistinguishable from data loss.

The cause is not a version regression. It is inherited stale Claude env vars: in an affected shell CLAUDE_CODE_CHILD_SESSION=1 is set and CLAUDE_CODE_SESSION_ID points to a session that is already dead.

Trigger: I routinely start a long-lived process (a Vite dev server / Storybook) from inside a Claude session shell, because the agent can't background them. That process inherits CLAUDE_CODE_SESSION_ID + CLAUDE_CODE_CHILD_SESSION=1. Once the original session dies, any claude launched as a descendant of that process is treated as a child of the dead session and writes no transcript.

I initially ran claude install stable and the problem went away, so I thought it was a latest-channel regression. That was misleading — downgrading merely restarted the process tree and broke the poisoned inheritance chain. The mechanism still ships on the current version.

What Should Happen?

The session should persist its transcript to ~/.claude/projects/... and appear in claude --resume.

At minimum, if CLAUDE_CODE_CHILD_SESSION=1 but the referenced CLAUDE_CODE_SESSION_ID has no live owner / no existing transcript directory, Claude Code should emit a warning (or fall back to a fresh session) instead of silently persisting nothing. Right now silent loss is indistinguishable from a crash.

Error Messages/Logs

(none — no error is shown; the failure is silent)

Steps to Reproduce

  1. In a Claude session, from the agent's shell start a long-lived process and leave it running:

``
npm run dev # e.g. a Vite dev server / Storybook
``

  1. /exit that session.
  2. From the still-running dev server's shell (or any descendant of it), launch claude.
  3. Use it normally, then /exit.
  4. Run claude --resume → the session from step 4 is missing; no .jsonl was written under ~/.claude/projects/...; no warning was shown.

Verified on my machine that step-4 shells carry the inherited vars:

$ env | grep CLAUDE
CLAUDE_CODE_CHILD_SESSION=1
CLAUDE_CODE_SESSION_ID=<id of an already-dead session>

Claude Model

None

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.187 (Claude Code)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

iTerm2

Additional Information

Same underlying mechanism as #68534 (reported there on Linux / JetBrains integrated terminal). Filing separately because this is a clean macOS + iTerm2 repro and includes the key data point that downgrading looked like a fix but was only a process-tree reset — the inheritance behavior is still present on the current release.

View original on GitHub ↗