Remote Control causes repeated .claude.json corruption on Windows (MSYS/Git Bash)
Bug Description
Enabling Remote Control on Windows (MSYS_NT / Git Bash) causes repeated corruption of the .claude.json session state file. The user is forced to re-login multiple times per session. The corruption appears to be caused by concurrent read/write conflicts between the local process and the remote connection handler.
Environment
- OS: Windows 10 (MSYS_NT-10.0-19045 3.6.5-22c95533.x86_64)
- Shell: Git Bash / MSYS2
- Claude Code version: Latest (as of 2026-02-26)
- Subscription: Claude Max 5x
Steps to Reproduce
- Enable Remote Control on Windows (Git Bash environment)
- Use Claude Code normally in a terminal session
- Within minutes,
.claude.jsongets corrupted - User is forced to re-login
- Corruption recurs repeatedly — 11 corrupted files generated in a single ~30 minute window
Evidence
Multiple corrupted session files created in ~/.claude/backups/:
.claude.json.corrupted.1772104993804 (19KB)
.claude.json.corrupted.1772105217584 (19KB)
.claude.json.corrupted.1772105754963 (20KB)
.claude.json.corrupted.1772106046916 (20KB)
.claude.json.corrupted.1772106522555 (2KB)
.claude.json.corrupted.1772106523176 (2KB)
.claude.json.corrupted.1772106661164 (5KB)
.claude.json.corrupted.1772106661241 (5KB)
.claude.json.corrupted.1772106661474 (5KB)
.claude.json.corrupted.1772106736474 (5KB)
.claude.json.corrupted.1772106736570 (157B)
.claude.json.corrupted.1772106736739 (199B)
Note the timestamps — some corruptions happen within milliseconds of each other (e.g., 1772106661164, 1772106661241, 1772106661474), strongly suggesting a race condition between concurrent writers.
Impact
- Config files NOT affected:
settings.json,mcp.json,settings.local.jsonall survive — only session state is corrupted - Credentials lost: User must re-authenticate each time
- MCP tools: May require re-validation depending on timing
- Workaround: Setting
"enableRemoteConnections": falseinsettings.jsonprevents the issue
Expected Behavior
Remote Control should not corrupt the session state file. The session file writer should use atomic writes (write to temp file, then rename) and/or file locking to prevent race conditions, especially on Windows where file locking semantics differ from Unix.
Suggested Fix
- Use atomic file writes (write to
.claude.json.tmp, thenrename()) for the session state file - Add file locking (e.g.,
lockfileor WindowsLockFileEx) when Remote Control is active - Consider separating remote session state from local session state to avoid conflicts entirely
---
Filed via Claude Code on behalf of user
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗