Race condition: .claude.json corruption when running multiple instances concurrently
Resolved 💬 27 comments Opened Feb 26, 2026 by HardRockTech Closed Feb 26, 2026
Description
Running multiple Claude Code instances simultaneously causes repeated .claude.json corruption due to concurrent writes without file locking or atomic write operations.
Environment
- Claude Code version: 2.1.59 (also observed on earlier versions back to at least ~2.1.56)
- OS: Windows 11 Pro 10.0.26200
- Shell: Windows Powershell
Steps to Reproduce
- Open 5+ terminal windows
- Run
claudein each - Use them concurrently for normal work
- Observe repeated corruption warnings on startup and during sessions
Observed Behavior
Each instance detects the corruption, backs up the broken file, and recovers — but this produces:
- Hundreds of
.claude.json.corrupted.*backup files in~/.claude/backups/(305 files accumulated in a single day) - Spam warning messages on every startup:
````
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>
- The corrupted files show truncated JSON (partial writes caught mid-stream)
Expected Behavior
Multiple concurrent instances should be able to coexist without corrupting the shared config file. No warning spam, no backup file accumulation.
Suggested Fix
_Redacted by Claude Code maintainers to avoid confusion as users find this issue_.
Impact
- Not data-losing — Claude Code recovers gracefully each time
- Annoying — constant warning messages disrupt workflow
- Disk clutter — hundreds of small backup files accumulate rapidly
- Legitimate workflow — running multiple instances in parallel (e.g., one per project/repo) is a common power-user pattern that should be supported
27 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
Very severe issue.
Once you open claude code and if has update, close it right away and run this, check version after each launch
claude install 2.1.50Disabling update with env variable doesnt work for me
Same here. Almost impossible to work with multiple instances of Claude Code at the same time.
I am also encountering the same problem, it is significantly affecting my work, and I am very anxious.
Thanks @georgiai1 the downgrade works. This week Claude Code has been terrible. Regressions, bugs, asks for confirmations 100 times in any task, does not follow Claude.md instructions...
Update 4:10PM: We have escalated this to a hotfix and we are working on deploying it as quickly as possible.
---
Update 2:47PM ET: We believe we've found the smoking gun and are planning to have a fix in today's scheduled release. I will keep you all posted. Apologies for the inconvenience here.
---
Update 1:55PM ET: We may need to address this with today's scheduled release. We believe the fact that this corrupts config writes prevents our feature flag changes from propagating for a number of users.
---
Update 1:47PM ET: There are some ongoing reports of this issue, and our investigation continues.
---
Update 12:39PM ET: we have remotely disabled a non-essential feature that we believe was contributing to a significant number of config writes. This should prevent almost all contention.
---
Update 12:21pm ET: we think we have a root cause for why writes to the global config increased so much, and are working on a mitigation. We are not yet sure if this will require a deploy. Thanks for your patience. In the meantime, we are also going to take a holistic look at our config read-write concurrency management to try to prevent this in the future.
---
Hey folks, can confirm this behavior and I'm working on a fix. Thanks for reporting. I'm arbitrarily considering this the canonical issue for this problem and will close duplicates after resolving.
This issue (and its near-duplicates) have revealed several vicious-cycle feedback loops in how Claude Code reads/writes its config that I am going to try to thoroughly address. These issues are especially present on Windows which has different file locking strategies than POSIX-compliant systems.
Confirming this on Windows 11, Claude Code 2.1.59 (native binary), Opus 4.6.
Running 2 concurrent sessions from Git Bash. Got the corruption error twice within minutes of each other — restored from backup the first time, then got the same error again in a new session immediately after.
The corrupted file was valid JSON but stripped down to ~27 lines (missing
oauthAccount,tipsHistory,toolUsage,cachedGrowthBookFeatures, etc.) with a differentuserIDhash — consistent with a session writing a fresh minimal config after failing to parse the file mid-write by another session.Backup at
~/.claude/backups/had the full 163-line config intact. Manualcprestore works but this is happening frequently enough to need an alias for it.@stevenpetryk Sir, can I pet that dawg?
Ah, this is a common misconception: I actually _am_ the dog in that picture, and the man is just somebody who wanted to pose with me. Claude Code lets me code without opposable thumbs though, so all is well.
Removing
platform:windowsbecause this behavior is technically reproducible on all platforms, but Windows just has especially prone-to-deadlock filesystem behavior.Alright gang, we've remotely disabled a non-essential feature that we believe was causing excessive config writes. How do things seem? (Restarting Claude Code is recommended, but no update is needed).
Cross-posting from #28809 (closed as duplicate of this issue) to preserve root cause analysis and evidence.
Evidence from 32 days of tracking
Scale: 278+ corruption events in a single day (Feb 25), 36 Bun crashes in 32 days across v2.1.50→59, 4 full computer lockups.
Root Cause Analysis
We identified three compounding failure modes, not just concurrent writes:
1. UTF-8 BOM Corruption
Bun's JSON parser rejects valid
.claude.jsonfiles that have a UTF-8 BOM (\xef\xbb\xbf) prepended. When Claude Code encounters this, it declares the file "corrupted" and triggers the backup/restore cycle — even though the JSON content is perfectly valid. A simpleencoding='utf-8-sig'read would handle this silently.2. Non-Atomic Writes (the race condition you identified)
.claude.jsonis written in-place without:fsync()before renameflock/LockFileEx)This means ANY interruption during a write (crash, concurrent session, antivirus lock) produces a partial/empty file.
3. Auto-Recovery Death Spiral (the worst part)
When Claude Code detects corruption, it:
~/.claude/backups/.claude.json.backup.*.claude.jsonwith a 234-byte skeleton (just{"version":1}essentially)cp backup... .claude.json) restores a skeleton, wiping all permissions, auth tokens, and settingsThe recovery mechanism is actively harmful — it replaces corrupted-but-recoverable configs with empty skeletons, then poisons the backup pool with those skeletons.
The Fix
Standard pattern used by every serious config manager:
Workaround
We built a watchdog script that monitors
.claude.jsonevery 30s and restores from a known-good "golden backup" stored in git. It catches ~10 corruptions per hour during active use. This should not be necessary.Evidence threads: #28809 (closed), #21576 (36 crash repros), #21875 (WinDbg analysis), #29050 (single-session corruption)
@ThatDragonOverThere thank you, but rest assured all duplicates have been incorporated into our analysis.
There are some ongoing reports of this issue, and our investigation continues. ~~We may need to fix this in the 2.1.60 release scheduled for today. Sorry again for the disruption.~~ Edit: we are going to hotfix this, which means it will likely go out as 2.1.61.
I have to re-auth in every terminal, every instantiation of
claudeeven in the same terminal. It's brutal.We believe we've found the smoking gun and are planning to have a fix in today's scheduled release. I will keep you all posted. Apologies for the inconvenience here.
We are escalating this to a hotfix to get it remediated faster. I have also created a status page incident—apologies, I should have done that earlier.
Root Cause Analysis (decompiled source)
Decompiled the bundled JS from the binary and traced the exact code path:
1.
writeFileAtomic— the non-atomic fallbackThe write function correctly uses temp file +
renameSync. But on Windows,renameSyncfails with EPERM when another process has the target open. The code falls back to a directwriteFileSync:2.
saveGlobalConfig— lock failure fallbackUses
proper-lockfilewithlockSync(). When locking fails,saveGlobalConfigcatches the error and falls back to a completely unlocked, non-atomic write:3. The cascade
Unexpected EOFoauthAccount)Suggested fixes
fs.copyFile+fs.unlink.File.Replacesemantics on Windows — the native atomic file swap.tengu_config_stale_writeabort the write — it already detects stale writes but only logs telemetry.toolUsage,clientDataCache,cachedGrowthBookFeaturesto a separate file to reduce contention on auth config.---
Workaround: Config Guard (PowerShell, tested)
Polling-based background script that auto-repairs corruption and restores
oauthAccount. Verified on Windows 11 + PowerShell 7 + .NET 9.File.ReplaceoauthAccountback via string manipulation (noConvertTo-Jsonround-trip)~/.claude/guard-auth-cache.json(survives terminal restarts)<details>
<summary><b>guard.ps1</b> (save to <code>~/.claude/guard.ps1</code>)</summary>
</details>
Auto-start — add to pwsh
$PROFILE:Requires PowerShell 7+ (
pwsh) forFile.Replace.Just to keep y'all in the loop, we continue to work on getting this deployed.
Surprisingly today it's been pretty okay despite no change in Claude Code version and continuing the same sessions from yesterday that we're having constant corruption. Starting new sessions also worked without corruption. Just wanted to share in case this is surprising to the maintainers.
Thanks @Nantris — this issue is mostly prevalent when people are multi-Claude drifting, single sessions are probably fine.
All, we've released 2.1.61 which should fix this problem. Please run
claude updateto get the latest.This was a disruptive error, so I wanted to share the action items we are going to take:
Thank you so much for your patience here.
@stevenpetryk — thank you for the incident response today and for shipping v2.1.61. First meaningful engagement in 33 days of reporting. The config corruption fix is confirmed working.
However: the Bun crash that CAUSES the config corruption is still unfixed. Repro 49 was on v2.1.61 — same TUI escape, same
[I[O[codes. 30 crashes today alone.The user has switched from the native Bun binary to npm install (Node.js runtime) as a workaround. If the crashes stop on Node.js, that conclusively proves the issue is in Bun's N-API bridge, not in Claude Code's application code.
The root cause analysis is on #21875 (WinDbg dumps, vtable corruption) and oven-sh/bun#27471 (comprehensive Bun bug filed today with 49 repros). Both have zero responses.
The config fix was the right move. The next step is acknowledging the Bun crash itself — #21576 has 49 repros with zero Anthropic staff comments.
If
Claudecommands hang after this issue, check whether~/.claude.jsonis marked read-only. On Windows, removing the read-only attribute fromC:\Users\<user>\.claude.jsonfixed it for me.#claude #hanging #freeze #hangs #terminal
Running multiple Claude instances is what led us to build cozempic — the session detection was the first problem we hit, and .claude.json corruption was next.
\
cozempic doctor\now detects corrupted config files and session files and can auto-repair them:\
\\\pip install cozempic
cozempic doctor # detect issues
cozempic doctor --fix # auto-repair with backup
\
\Also added a \
--session\flag to the guard daemon so you can target a specific session by ID instead of relying on auto-detection (which breaks with multiple instances):\
\\\cozempic guard --daemon --session <session-id>
\
\Open source — feedback welcome if anyone's running multi-instance setups.
Auto-Updater Is Itself a Vector for Breaking User Configurations
Related to the Bun crash issue (#21576): the auto-updater silently downgraded me from v2.1.62 (Node.js npm install) to v2.1.61 (Bun native binary) overnight on Mar 3 by re-downloading the native binary to
~/.local/bin/claude.exe.This is relevant to config corruption because:
autoUpdatesChannelonly accepts"latest"or"stable", with no"disabled"or"none"option. Users cannot protect their configurations from being overwritten by the updater.The auto-updater making silent, non-consensual changes to the installed binary is a config corruption vector in its own right. If it can silently swap the entire runtime binary, user-side configuration stability is fundamentally undermined.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.