[BUG] Repeated .claude.json corruption on Windows with multiple terminals (race condition)
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?
.claude.json is repeatedly corrupted with JSON Parse error: Unexpected EOF when running multiple Claude Code terminals simultaneously on Windows. This worked fine in previous versions with the same multi-terminal setup.
Auto-recovery restores from backup, but the file gets corrupted again within seconds. 37+ corrupted backup files accumulated in ~2 hours.
Root cause: Multiple claude.exe processes write to .claude.json concurrently without file locking or atomic write. Corrupted files show truncated JSON (77~957 bytes vs ~6265 bytes normal). Sub-millisecond collision timestamps confirm the race
condition (e.g., two corruptions 1ms apart).
What Should Happen?
Multiple Claude Code instances running concurrently on Windows should safely share .claude.json without file corruption. This worked correctly in previous versions with the same multi-terminal setup.
Error Messages/Logs
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}
37+ corrupted backup files accumulated in ~2 hours.
Corrupted files show truncated writes (race condition evidence):
- 77 bytes: only first JSON field written
- 157 bytes: partial write (2 fields)
- 957 bytes: partial write
- ~6265 bytes: full valid file
Sub-millisecond collision timestamps confirm concurrent writes:
- 1772089539292 and 1772089539293 (1ms apart)
- 1772089575308 and 1772089575311 (3ms apart)
3 claude.exe processes running simultaneously:
claude.exe PID 21040 722MB
claude.exe PID 10532 863MB
claude.exe PID 14760 631MB
Steps to Reproduce
- Open 2-3 Claude Code terminals on Windows (e.g., CLI + IDE integration)
- Use them concurrently
- Observe repeated corruption warnings on session start
- Check ~/.claude/backups/ for accumulating .claude.json.corrupted.* files
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.59
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
IntelliJ IDEA terminal
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗