[BUG] Bug Report: v2.1.59 corrupts `.claude.json` with multiple concurrent agents

Resolved 💬 3 comments Opened Feb 26, 2026 by guirgsilva Closed Feb 27, 2026

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?

Bug Report: v2.1.59 corrupts .claude.json with multiple concurrent agents

Description

After updating to v2.1.59, the global configuration file ~/.claude.json is being corrupted with a JSON Parse error: Unexpected EOF whenever multiple Claude Code agents are running concurrently. This behavior did not occur on the previous version.

Environment

  • Claude Code version: 2.1.59
  • OS: Windows 11
  • Install method: Native (not npm)
  • Executable path: C:\Users\<user>\.local\bin\claude.exe
  • Last updated: 2025-02-25

Steps to Reproduce

  1. Open 3 or more concurrent Claude Code sessions (multiple terminal windows)
  2. Let agents run tasks simultaneously
  3. On the next launch, Claude Code reports: Claude configuration file at C:\Users\<user>\.claude.json is corrupted: JSON Parse error: Unexpected EOF

Expected Behavior

Concurrent agents should handle read/write access to .claude.json safely, using file locking or atomic writes to prevent corruption.

Actual Behavior

With 4 concurrent processes observed:

Handles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName
-------  ------    -----      -----     ------     --  -- -----------
    345      51   952624     615472      38.23  17960   1 claude
    324      43   632432     479672       7.69  21040   1 claude
    337      48   825428     575620      34.92  22760   1 claude
    312      40   669724     481756       3.06  23504   1 claude

The file gets truncated mid-write, resulting in an incomplete JSON. Claude Code auto-backs up the corrupted file and attempts to restore from the latest backup, but the cycle repeats on every session.

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" "...claude.json"

Additional Context

  • This is a regression from the previous version — multiple concurrent agents worked without issues before v2.1.59
  • The .claude.json has autoUpdates: false set, so the update happened via native installer
  • Workaround attempted: restoring backup manually — does not solve the issue as corruption repeats
  • The root cause appears to be a race condition / missing file lock when multiple processes attempt to write to the shared config file simultaneously

Suggested Fix

Implement atomic writes (write to temp file + rename) and/or file locking when persisting changes to .claude.json, similar to how other Electron/Node apps handle concurrent config access.

What Should Happen?

Concurrent Claude Code agents should safely share access to .claude.json using atomic writes (write to a temp file, then rename) and/or file locking, preventing race conditions that truncate the file and cause JSON corruption.

Error Messages/Logs

Steps to Reproduce

Open 2 or more terminal windows in the same user session
Run claude in each terminal simultaneously
Let the agents perform tasks concurrently for a few minutes
Close and reopen any of the sessions
Claude Code reports: JSON Parse error: Unexpected EOF on .claude.json

Claude Model

None

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

v2.1.59

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

PowerShell

Additional Information

_No response_

View original on GitHub ↗

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