Interactive mode never writes conversation transcript (.jsonl) when HOME/USERPROFILE is redirected (Windows, 2.1.218)

Status Open
Reported on v2.1.218
Maintainer reply None cached
Activity 0 comments · opened Jul 23, 2026

Summary

In interactive (TUI) mode, Claude Code never persists the conversation transcript (~/.claude/projects/<cwd-slug>/<session-id>.jsonl) when HOME/USERPROFILE point at a directory other than the real user profile. Print mode (-p) under the same redirected home writes the transcript fine, and interactive mode under the real home writes it fine.

Found while building an isolated Playwright test harness for an Electron app that hosts Claude Code sessions (temp home so tests never touch the real profile).

Environment

  • Claude Code CLI 2.1.218 (also observed on 2.1.216)
  • Windows 11, native (no WSL)
  • Node 22 host; CLI spawned both via node-pty and plain shells

Repro

  1. Create a temp dir T; copy the real ~/.claude.json and ~/.claude/.credentials.json into it (auth works; also reproduces with a minimal {"hasCompletedOnboarding":true} config).
  2. Launch interactive claude with env HOME=T, USERPROFILE=T (optionally APPDATA/LOCALAPPDATA under T — makes no difference), cwd = some work folder.
  3. Accept trust, submit a prompt, wait for the completed response, wait 45+ s.
  4. Look for T/.claude/projects/<slug>/<session-id>.jsonl.

Actual: the transcript file never appears — not in T, and not in the real profile either. Meanwhile Claude DOES create T/.claude/projects/<slug>/memory/, T/.claude/session-env/<session-uuid>/, T/.claude/backups/, T/.claude/cache/, and %LOCALAPPDATA%/claude-cli-nodejs/Cache/... — so the redirected home is clearly being honored for everything else. Hooks fire normally (SessionStart/UserPromptSubmit/Stop).

Expected: the conversation .jsonl is written under the (redirected) home like every other artifact, as it is in -p mode.

Isolation matrix (all on the same machine/CLI)

| Scenario | transcript written? |
|---|---|
| -p + redirected home | yes |
| -p + redirected home + full test-runner env inherited | yes |
| interactive (node-pty) + redirected home | no |
| interactive + redirected home + TEST_ENABLE_SESSION_PERSISTENCE=1, test-marker envs scrubbed | no |
| interactive + real home | yes |

Also ruled out: hard-kill timing (waited 45s+ after turn completion with the process alive; real-home interactive appends incrementally during the turn), cleanupPeriodDays (not set), stale paths in the copied .claude.json (repros with a minimal config).

Impact

Any tool that sandboxes Claude Code under a throwaway home (test harnesses, CI-style isolation, hermetic environments) silently loses conversation history — resume (--resume) has nothing to resume from and transcript-tailing integrations see nothing, with no error or warning anywhere.

View original on GitHub ↗