Concurrent instances corrupt shared .claude.json config file

Resolved 💬 3 comments Opened Feb 26, 2026 by infonomu Closed Feb 26, 2026

Bug Description

When running multiple Claude Code instances simultaneously (e.g., working on two different projects in separate terminals), the shared global configuration file ~/.claude.json gets corrupted due to concurrent write race conditions.

Steps to Reproduce

  1. Open Claude Code in Terminal 1 for Project A (e.g., cd projectA && claude)
  2. Open Claude Code in Terminal 2 for Project B (e.g., cd projectB && claude)
  3. Use both instances actively at the same time
  4. Observe repeated corruption errors

Error Message

Claude configuration file at C:\Users\user\.claude.json is corrupted: JSON Parse error: Unexpected EOF
The corrupted file has been backed up to: C:\Users\user\.claude\backups\.claude.json.corrupted.<timestamp>
A backup file exists at: C:\Users\user\.claude\backups\.claude.json.backup.<timestamp>
You can manually restore it by running: cp "<backup_path>" "<config_path>"

Impact

  • Over a single work session (~4 hours), 256 corrupted backup files accumulated in ~/.claude/backups/
  • The error appears repeatedly during normal usage, interrupting workflow
  • While Claude Code auto-recovers from backups, the constant corruption/recovery cycle is disruptive

Root Cause Analysis

Both Claude Code instances read/write to the same ~/.claude.json file (which stores toolUsage, clientDataCache, tipsHistory, etc.). When two processes write simultaneously, one write partially overwrites the other, producing invalid JSON (truncated / unexpected EOF).

Environment

  • OS: Windows 11 Pro (10.0.26200)
  • Shell: Git Bash
  • Claude Code version: 2.1.56

Suggested Fix

Consider one or more of:

  • File locking: Use OS-level file locks (e.g., flock / LockFileEx) before writing
  • Atomic writes: Write to a temp file first, then atomically rename (prevents partial writes)
  • Per-instance state: Separate volatile per-instance data (like toolUsage, clientDataCache) from shared config
  • Merge on write: Read-modify-write with conflict detection instead of full overwrite

View original on GitHub ↗

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