Repository navigation
Closed
Labels
area:corebugSomething isn't workingSomething isn't workinghas reproHas detailed reproduction stepsHas detailed reproduction stepsplatform:macosIssue specifically occurs on macOSIssue specifically occurs on macOS
Description
Bug Description
Claude configuration file at /Users/quentin/.claude.json is corrupted: Unexpected end of JSON input
Claude configuration file at /Users/quentin/.claude.json is corrupted
The corrupted file has been backed up to: /Users/quentin/.claude.json.corrupted.1751911760442
A backup file exists at: /Users/quentin/.claude.json.backup
You can manually restore it by running: cp "/Users/quentin/.claude.json.backup" "/Users/quentin/.claude.json"
Environment Info
- Platform: darwin
- Terminal: iTerm.app
- Version: 1.0.43
- Feedback ID: b11b25e6-c041-475e-9b26-bcd1cc971646
Errors
[{"error":"Error: Command failed: security find-generic-password -a $USER -w -s \"Claude Code\"\nsecurity: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.\n\n at genericNodeError (node:internal/errors:984:15)\n at wrappedFn (node:internal/errors:538:14)\n at checkExecSyncError (node:child_process:891:11)\n at execSync (node:child_process:963:15)\n at ED (file:///Users/quentin/.nvm/versions/node/v20.19.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:702:3921)\n at file:///Users/quentin/.nvm/versions/node/v20.19.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:623:9038\n at Q (file:///Users/quentin/.nvm/versions/node/v20.19.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:526:13327)\n at hJ (file:///Users/quentin/.nvm/versions/node/v20.19.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:623:8184)\n at S_ (file:///Users/quentin/.nvm/versions/node/v20.19.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:623:7265)\n at NB (file:///Users/quentin/.nvm/versions/node/v20.19.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:623:11432)","timestamp":"2025-07-07T14:46:12.617Z"},{"error":"AbortError: The operation was aborted\n at abortChildProcess (node:child_process:725:27)\n at EventTarget.onAbortListener (node:child_process:795:7)\n at [nodejs.internal.kHybridDispatch] (node:internal/event_target:831:20)\n at EventTarget.dispatchEvent (node:internal/event_target:766:26)\n at abortSignal (node:internal/abort_controller:370:10)\n at AbortController.abort (node:internal/abort_controller:392:5)\n at Timeout._onTimeout (file:///Users/quentin/.nvm/versions/node/v20.19.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:2584:7702)\n at listOnTimeout (node:internal/timers:581:17)\n at process.processTimers (node:internal/timers:519:7)","timestamp":"2025-07-07T14:46:18.346Z"},{"error":"SyntaxError: Unexpected non-whitespace character after JSON at position 63\n at JSON.parse (<anonymous>)\n at file:///Users/quentin/.nvm/versions/node/v20.19.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:618:9952\n at Q (file:///Users/quentin/.nvm/versions/node/v20.19.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:526:13327)\n at $w2 (file:///Users/quentin/.nvm/versions/node/v20.19.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1350:10306)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)","timestamp":"2025-07-07T14:52:43.088Z"},{"error":"MaxFileReadTokenExceededError: File content (29511 tokens) exceeds maximum allowed tokens (25000). Please use offset and limit parameters to read specific portions of the file, or use the GrepTool to search for specific content.\n at uz6 (file:///Users/quentin/.nvm/versions/node/v20.19.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1428:432)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async Object.call (file:///Users/quentin/.nvm/versions/node/v20.19.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1423:4919)\n at async hq6 (file:///Users/quentin/.nvm/versions/node/v20.19.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1933:11470)\n at async Jz1 (file:///Users/quentin/.nvm/versions/node/v20.19.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1933:8191)\n at async Gz1 (file:///Users/quentin/.nvm/versions/node/v20.19.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1913:775)\n at async gq6 (file:///Users/quentin/.nvm/versions/node/v20.19.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1933:7335)\n at async fq6 (file:///Users/quentin/.nvm/versions/node/v20.19.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1933:6820)\n at async C$ (file:///Users/quentin/.nvm/versions/node/v20.19.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1933:5217)\n at async C$ (file:///Users/quentin/.nvm/versions/node/v20.19.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1933:5939)","timestamp":"2025-07-07T15:12:23.684Z"}]Reacted by Cory Logan, Mint McQueen, noops888, Dmytro Prokhorov, Paul Berg, TallaHigh and benjaminhdd
Metadata
Metadata
Assignees
Labels
area:corebugSomething isn't workingSomething isn't workinghas reproHas detailed reproduction stepsHas detailed reproduction stepsplatform:macosIssue specifically occurs on macOSIssue specifically occurs on macOS
Activity
terryso commentedon Jul 9, 2025
same issue
You can manually restore it by running: cp "/Users/quentin/.claude.json.backup" "/Users/quentin/.claude.json"
not work
tomnewton commentedon Jul 14, 2025
This popped up for us last week - really bad. Causing a lot of api key creation too for our team is which is less than ideal.
mintmcqueen commentedon Jul 17, 2025
Same. Haven't confirmed the cause, but I've got a stack of 35 corrupted ~/.claude.json config files piled up over 3 weeks.
noops888 commentedon Jul 24, 2025
The same issue just randomly appeared for me in the last two days on both macOS and Linux. This is particularly infuriating because ~/.claude.json seems to be the only place to store global mcp server configurations where they will stick. They do not work in .mcp.json or settings.json
Related: #1788
sfearl1 commentedon Jul 26, 2025
Same happened to me yesterday around the same time the update for agents was pushed. IIRC, I ended a session and restarted a few minutes later and had to log back in. I tried to continue my previous session but there weren't any sessions to resume. Noticed all of my MCP servers were missing too so I tried to restore config from backup but it was just a copy of the corrupted one. Now I'm getting random messages it's still corrupted.
torronen commentedon Aug 19, 2025
same on ubuntu 24.04 Claude configuration file at /home/{user}/.claude.json is corrupted: Unexpected end of JSON input
I am usnsure of the reason. I don't think there were multiple claude session executing (could have been open but should have been idle)
cp "/home/{user}/.claude.json.backup" "/home/{user}/.claude.json" ro selecting "reset with default settings" does not help
claude doctor also opens the above screen and can't reset it with default configuration. No error messages after selecting that option, the same screen just shows up next time.
config file appears empty
EDIT: It could have been out of disk space. Unable to verify right now, but I will update if reappears.
louis030195 commentedon Oct 2, 2025
same all break all the time
i looked into this file, such a bad design to put all the context and every single data in a json file ...
why is the config mixed with cache, and prompts and everything else? insane
lulzkiller666 commentedon Oct 9, 2025
I complete broke mine, and the backup is broken also - I tried removing claude, and the files, but when i reinstall claude the original (standard) file does not come back ?
github-actions commentedon Dec 7, 2025
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
brennon commentedon Dec 11, 2025
This isn't stale! Happens for me consistently, too.
pentafive commentedon Dec 19, 2025
Additional Evidence: Linux/WSL2 + Infinite Loop Symptom
I can confirm this issue occurs on Linux/WSL2 as well, with an additional symptom not yet documented: lock contention can cause the TUI to enter an infinite event loop.
Environment
6f257eef-bc05-4588-aeac-7a818b3845d1Reproduction Scenario
Setup: 4 concurrent Claude Code sessions running in different project directories (legitimate parallel workflow - PDF conversion, issue tracking, etc.)
Trigger Sequence:
Error streaming, falling back to non-streaming mode: Connection error.Runaway Loop Symptoms
The session began cycling through these operations at ~6.6 ops/second (vs normal ~1.5/sec):
UserPromptSubmit with query: undefined)~/.claude.jsonDebug log evidence:
FileHistory: Making snapshotentries.claude.json.tmp.<PID>.<timestamp>Impact
kill -9to recoverConnection to Settings Corruption
I believe this same lock contention mechanism may explain settings file corruption I documented in a separate issue (#14522). During a previous incident with the same multi-session setup, the permissions array in
settings.local.jsoncontained fragmented bash commands split across multiple JSON entries:This looks like a partial JSON write that got interrupted by lock contention, leaving a corrupted permissions array.
Suggested Fix
In addition to the file locking improvements discussed in this thread, the event loop should have:
Happy to provide the full debug log (sanitized) if helpful.
nathanschram commentedon Jan 18, 2026
Additional evidence from Linux (Ubuntu, v2.1.12)
Confirming this issue on Linux with 5 concurrent Claude sessions. Debug logs show the root cause appears to be lock file contention:
Lock file location:
~/.local/state/claude/locks/2.1.12.lockThe lock errors occur repeatedly (10+ times per session) when multiple Claude instances are running, which likely causes session data to fail to save properly.
Environment:
yokoya1006 commentedon Feb 26, 2026
Still reproducing on v2.1.59 (Windows / Git Bash / MINGW64)
Running 2 terminal sessions (main + background agents from Task tool with run_in_background: true), the cascading
corruption loop appeared within minutes.
Evidence of sub-100ms write collisions:
.claude.json.corrupted.1772070379728
.claude.json.corrupted.1772070379760 (+32ms)
.claude.json.corrupted.1772070379786 (+26ms)
.claude.json.corrupted.1772070379834 (+48ms)
The corruption loop is self-reinforcing: Process A writes → Process B reads mid-write → B detects corruption → B backs
up & rewrites → Process C reads mid-write → repeat. All terminals become unusable until every process except one is
killed.
Note: v2.1.59 fixed the OAuth token race condition for multiple instances (per CHANGELOG), but .claude.json itself
still has no atomic write or file locking.
Environment: Windows 10 (MINGW64_NT-10.0-26100), Claude Code 2.1.59, 2 terminals + 3 background agents
Emmanuel-Samuel commentedon Feb 26, 2026
Still reproducing on v2.1.59 (Windows 11 Pro / Git Bash).
Running multiple Claude Code sessions (including worktree-based sessions), the
.claude.jsoncorruption loop triggers repeatedly, forcing re-authentication on every new terminal.Backup directory shows multiple corrupted files created within seconds of each other, confirming the concurrent write race condition.
Environment:
This is a major UX issue — every new terminal requires a full re-login, breaking workflow continuity. Would appreciate atomic writes or file locking being prioritized.
nicoarcu11 commentedon Feb 27, 2026
Still having this issue
kvirani commentedon Feb 27, 2026
Same.
ENV: Windows 11. pwsh. Claude CLI. Multi-project and about 5-6 sessions open across 2 projects. 2.1.62 (Claude Code)
github-actions commentedon Mar 7, 2026
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.