.claude.json becomes corrupted (Unexpected EOF) during tool use — non-atomic config writes
Description
During normal tool use (Search, litSearch), .claude.json becomes corrupted — JSON parser hits Unexpected EOF, indicating the file was truncated mid-write.
Reproduction
- Run Claude Code on Windows with active tool calls (Search/litSearch)
- Config becomes corrupted during or around tool execution / permission prompts
- Error:
parse error: Unexpected EOF - Message:
.claude.json corrupted.<timestamp> - Auto-backup created at
C:\Users\Cassie\.claude\backups\.claude.json.backup.<timestamp> - Suggested restore command points to wrong path (
C:\Users\Cassie\.claude.jsoninstead of the actual config location)
Root Cause (Suspected)
Non-atomic config writes. The file is written in-place rather than using the safe pattern (write temp → fsync → rename). Possible triggers:
- Permission allowlist updates writing to config mid-operation
- Concurrent writes from multiple Claude sessions/processes
- Interruption mid-write (crash, kill, forced stop)
- Bun crashes (documented 29 times in 30 days on #21576) truncating in-progress writes
Expected Behavior
- Config writes should be atomic (write to temp file → fsync → rename)
- Concurrent writes should be locked (file lock or single-writer pattern)
- Permission prompt updates should not corrupt the config file
- Restore command should point to the correct path
Additional Context
This has occurred multiple times. On Feb 24 (documented on #21576 as repro 22), a Bun crash corrupted .claude.json with the same "JSON Parse error: Unexpected EOF" — mid-write truncation during crash. The auto-backup system saved us, but without it all user config (permissions, settings, allowlists) would be permanently lost.
The fact that this also happens during normal tool use (not just crashes) suggests the write pattern itself is unsafe, independent of Bun stability issues.
Environment: Claude Code v2.1.58, Windows 11 Pro Build 26200, Bun v1.3.10
11 Comments
Live Reproduction — Within Minutes of Filing This Issue
Reproduced immediately. During a normal tool use (adding a BYPASS_RTH command to ibkr_data_service, running a Python ZMQ one-liner via Bash tool):
JSON Parse error: Unexpected EOF\C:\Users\Cassie\.claude\backups\.claude.json.corrupted.1772070805188\C:\Users\Cassie\.claude\backups\.claude.json.backup.1772070766357\C:\Users\Cassie\.claude.json\(should be inside \.claude/\directory)No Bun crash this time — this was during normal, healthy operation. The config file was corrupted by the write pattern itself, not by a crash interrupting a write.
Environment: Claude Code v2.1.58, Windows 11 Pro Build 26200, Bun v1.3.10
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
Massive New Evidence: 80+ Corrupted Backups in 1 Week
The scope of this bug is far worse than initially reported. Investigation of
~/.claude/backups/reveals:.claude.jsonfiles accumulated Feb 18-25, 2026Root Cause Confirmed: Race Condition
The clustering pattern (10-20 corruptions within one minute) proves this is a concurrent write race condition, not just crash-related truncation. Multiple Claude Code processes read/write
~/.claude.jsonwithout file locking. One process truncates the file mid-write while another reads.Reproduction
Open a new Claude Code window while another session is active. The corruption frequently triggers on startup when the new process writes to the config while existing processes are also accessing it.
Impact
Every upgrade or crash forces re-authorization of ALL permissions across ALL windows. On a machine running 8+ Claude Code sessions (common for power users), this is catastrophic — the config gets corrupted multiple times per hour.
This user is now paying extra usage tokens to repeatedly re-authorize permissions, re-set configurations, and file bug reports about config corruption caused by the product itself.
Environment: Claude Code v2.1.59, Windows 11 Pro Build 26200, 8+ concurrent sessions
Root Cause Found: BOM Encoding + Race Condition = Config Death Spiral
Investigation of 80+ corrupted backups in ~/.claude/backups/ revealed TWO interacting bugs:
Bug 1: BOM Encoding Kills the JSON Parser
Some .claude.json writes include a UTF-8 BOM (byte order mark, \ufeff). Bun's JSON parser cannot handle BOMs — it throws "Unrecognized token" or "Unexpected EOF" on perfectly valid JSON. The 11KB "corrupted" files in the backup directory are actually completely valid JSON — they just have a BOM prefix.
Verified: opening the largest "corrupted" file (11,073 bytes) with
encoding='utf-8-sig'parses perfectly. All 47 keys intact. The backup system marked a valid config as corrupt because of a 3-byte BOM.Bug 2: Recovery Creates a Death Spiral
When the parser fails on the BOM:
Evidence
Fixes Needed
Impact
User had to manually dig through "corrupted" backups to find their real config. Every version upgrade triggers re-authorization of ALL permissions across ALL windows because the config keeps getting replaced with empty skeletons. User is paying extra usage tokens to repeatedly re-authorize and file bug reports about config corruption.
Environment: Claude Code v2.1.59, Windows 11 Pro Build 26200, 8+ concurrent sessions
Repro 33: .claude.json Corruption Death Spiral — STILL happening on v2.1.59
This is the 33rd crash/corruption event in 32 days. Escalating because nothing has changed.
What happened today
Multiple windows simultaneously throwing:
The "backup" file Claude Code offers to restore? 234 bytes. A skeleton. It's restoring from its own corruption artifact — the exact death spiral I documented in my previous comment on this issue.
Result: forced re-sign-in and re-accept of every single permission, in every single window. Again.
The compound failure with #21576 (Bun crashes)
These two bugs are not independent — they form a feedback loop:
This is not a theoretical race condition. I have 80+ corrupted backup files in
~/.claude/backups/as physical evidence. They cluster 10-20 at a time within the same minute — concurrent writes, clear as day.What I'm doing to survive this
I should not have to do any of this:
A paying Max subscriber is running a cron job to protect a config file from the application that owns it. That is the state of things.
The four fixes I identified (still unfixed)
From my root cause analysis posted previously on this issue:
.claude.json.tmp, thenrename(). Prevents partial writes from being visible to concurrent readers. This is OS-101 stuff.flock()or equivalent to prevent concurrent read/write across multiple sessions. Standard practice for shared config files.None of these are architectural changes. None require refactoring. They are straightforward fixes to a data-destroying bug that hits multi-window users on every Bun crash.
By the numbers
| Metric | Value |
|--------|-------|
| Corruption events | 33 |
| Days tracked | 32 |
| Corrupted backups in ~/.claude/backups/ | 80+ |
| Size of "backup" being restored | 234 bytes (skeleton) |
| Size of actual valid config | ~11,073 bytes |
| Re-sign-ins forced | 33+ (once per event, per window) |
| Subscription tier | Max (paying for extra usage) |
| Version | 2.1.59 |
Ask
Please prioritize this. The root cause is documented. The fix is known. The reproduction is trivially reliable — open 3+ windows and wait for a Bun crash. The config file will be destroyed within seconds.
Every day this ships unfixed is another day I'm paying for a tool that deletes its own configuration and then "recovers" by restoring an empty file.
Cross-ref: #21576 (Bun crashes that trigger this), this issue's previous comments for full root cause analysis with evidence.
269 Corrupted Config Files in a Single Day — Feb 25, 2026
I need to report what I believe is the worst single-day incident documented for this bug.
Today's numbers:
.claude/backups/in ONE DAY.claude.jsonreduced to a 234-byte skeleton after every crash — all auth tokens, permissions, tool allowlists, and project settings destroyedThe death spiral — this is the core architectural problem:
The auto-recovery system is actively making this worse. Here is what happens:
.claude.jsongets corrupted to a 234-byte skeleton (just{}with a version field)The recovery system has no concept of config validity. It treats a 234-byte skeleton the same as a 15KB fully-configured file. There is no checksum, no minimum-size validation, no schema check — nothing to distinguish a healthy config from a corrupted one.
What I have had to build myself to keep this product functional:
.claude.jsonthat the watchdog restores fromI am paying for a Max subscription plus additional usage credits. I should not need to build infrastructure around a commercial product to prevent it from destroying its own configuration file.
Cumulative damage this month: 34 crashes across 32 days, 80+ config corruptions prior to today, 269 corruptions today alone, 4 full system lockups requiring hard power-off. Version v2.1.59.
The fix is straightforward:
Zero Anthropic staff have responded to this issue despite months of reports from multiple users. At what point does config corruption on every crash become a P0?
Update: 276 Config Corruption Events Today. Auto-Recovery Is Actively Harmful.
Date: 2025-02-25
Version: v2.1.59
Corruption events today: 276
Crashes today: 18+
It Happened Again — In This Very Session
The .claude.json corruption occurred again during today's crash (Repro 35, see #21576). The file was truncated from its full 11,442-byte configuration to a 234-byte skeleton — the same pattern as every previous report.
276 Corruption Events Today
The backup directory contains 276 corrupted/backup files created just today. This is not an occasional glitch. This is a systematic, repeated failure occurring roughly once every 2-3 minutes of active use.
The Auto-Recovery Is An Anti-Pattern
Here is the critical problem that makes this worse than just a crash:
.claude.jsonto a 234-byte skeleton.claude.json.backup.1772086898114cp .claude.json.backup.1772086898114 .claude.jsonThe recovery mechanism is not just useless — it is actively harmful. It gives the user false confidence that their config has been restored, when in reality they are copying a corrupted skeleton over a corrupted skeleton. The only way to actually recover is to have an independent, manual backup that was never touched by Claude Code's backup system.
What Should Happen Instead
Evidence
This is the same corruption pattern reported in every previous update on this issue. The file is being truncated during a crash, and the "backup" is being created from the already-truncated state.
Cross-Reference
278 Config Corruption Events in ONE DAY — Corruption Getting WORSE (Feb 25, 2026)
The corruption is accelerating and the nature of it is changing. This is no longer "just" replacing configs with clean skeletons. It's now producing malformed partial writes.
Today's Numbers
~/.claude/backups/New Corruption Pattern: Malformed Partial Writes
Previous corruption behavior: config file gets replaced with a clean skeleton (annoying but recoverable).
New behavior as of today: Config went from 11,442 bytes to 1,252 bytes — this is neither the original file nor a clean skeleton. It's a partially corrupted write. The file was truncated mid-write, producing a malformed JSON fragment that isn't even valid.
To make it worse: the auto-recovery mechanism suggested restoring from a backup file that is itself corrupted. The corruption is poisoning the backup chain. When your recovery mechanism points you to a corrupt backup, you have no safety net left.
Timeline
This has been documented for 32 days. The corruption rate is increasing:
The pattern is clear — this is getting worse with each release, not better.
Impact
Every corruption event requires manual intervention. With 278 in one day, that's approximately one every 3 minutes during active use. Combined with the 20+ Bun crashes (#21576) that are now cascading into crashing other applications (IB Gateway trading platform had to be restarted), this tool is actively hostile to sustained use.
Support ticket #215473249874164 — open for weeks with zero response.
Cross-ref: #21576 (20+ crashes today, repros 35-36), #21875, #16157
Contesting Duplicate Label
The suggested duplicates (#28806, #3117, #26717) do not cover this issue. Here's why:
This issue documents a specific, actionable root cause that none of the suggested duplicates identify:
.claude.json, causing JSON parse failures. None of the suggested duplicates mention BOM encoding as a root cause.write-to-temp → fsync → atomic rename, which is the standard pattern for preventing exactly this class of corruption. None of the suggested duplicates propose a root cause fix.The suggested duplicates are generic "config file issues" or "settings not persisting" reports. This issue is the only one with:
Please remove the
duplicatelabel. Closing this as a duplicate of issues that don't identify the root cause means the actual bug will never be fixed.Duplicate of #28847
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.