[BUG] ~/claude.json race condition with multiple Claude CLI sessions active in different directories
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?
I have been using multiple Claude CLI windows in different projects for months. Suddenly today I'm experiencing this issue repeatedly.
Claude Code v2.1.59
Opus 4.6 · Claude Max
Claude CLI Error:
Claude configuration file at C:\Users\joe\.claude.json is corrupted: JSON Parse error: Unexpected EOF
The corrupted file has been backed up to: C:\Users\joe\.claude\backups\.claude.json.corrupted.1772119104739
A backup file exists at: C:\Users\joe\.claude\backups\.claude.json.backup.1772119081716
You can manually restore it by running: cp "C:\Users\joe\.claude\backups\.claude.json.backup.1772119081716"
"C:\Users\joe\.claude.json" --- I keep getting this. my disk has 197GB free. I am running 2 claude CLI sessions
on the machine in different directories and on different projects - could they be corrupting each other?
● Yes, that's almost certainly the cause. Both CLI sessions share the same ~/.claude.json file, and when they write to
it concurrently there's a race condition — one session truncates the file while the other is mid-write, resulting in
the corrupted/truncated JSON (hence "Unexpected EOF").
This is a known limitation. The Claude CLI doesn't use file locking on that config file.
Workaround options:
- Run only one session at a time — simplest fix
- Restore the backup when it happens — the CLI already tells you the command:
cp "C:\Users\joe\.claude\backups\.claude.json.backup.1772119081716" "C:\Users\joe\.claude.json"
There's no fix you can apply on your end to prevent the race condition — it would need to be addressed in the CLI
itself. If it's happening frequently, I'd suggest filing an issue at https://github.com/anthropics/claude-code/issues.
What Should Happen?
You should do basic multi-process locking on file access as I would expect from a junior programmer. Or, create a separate .json file for each CLI using well-known techniques, or separate into global/local .json files. This is an absurd bug to encounter.
Error Messages/Logs
Claude configuration file at C:\Users\joe\.claude.json is corrupted: JSON Parse error: Unexpected EOF
The corrupted file has been backed up to: C:\Users\joe\.claude\backups\.claude.json.corrupted.1772119104739
A backup file exists at: C:\Users\joe\.claude\backups\.claude.json.backup.1772119081716
You can manually restore it by running: cp "C:\Users\joe\.claude\backups\.claude.json.backup.1772119081716"
"C:\Users\joe\.claude.json
Steps to Reproduce
- open multiple claude cli interfaces on your computer.
- attempt to use them as the claude developers suggest and work on multiple projects or aspects simultaneously
- fun error ensues.
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
not sure, but this error appeared recently
Claude Code Version
2.1.59 (Claude Code)
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
PowerShell
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗