Remote Control causes repeated .claude.json corruption on Windows (MSYS/Git Bash)

Resolved 💬 4 comments Opened Feb 26, 2026 by PPDEGRET Closed Feb 26, 2026

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

  1. Enable Remote Control on Windows (Git Bash environment)
  2. Use Claude Code normally in a terminal session
  3. Within minutes, .claude.json gets corrupted
  4. User is forced to re-login
  5. 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.json all 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": false in settings.json prevents 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, then rename()) for the session state file
  • Add file locking (e.g., lockfile or Windows LockFileEx) 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

View original on GitHub ↗

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