[BUG] `.claude.json` is trucated directly, and so occasionally gets corrupted

Status Closed — not planned
Maintainer reply None cached
Activity 15 comments · opened Jun 25, 2025 · closed Jan 4, 2026

Environment

  • Platform (select one):
  • [x] Anthropic API
  • [ ] AWS Bedrock
  • [ ] Google Vertex AI
  • [ ] Other: <!-- specify -->
  • Claude CLI version: <!-- output of claude --version --> 1.0.35
  • Operating System: <!-- e.g. macOS 14.3, Windows 11, Ubuntu 22.04 --> macOS
  • Terminal: <!-- e.g. iTerm2, Terminal App --> Alacritty

Bug Description

I occasionally get my .claude.json wiped. I _think_ that's happening because claude truncates it directly when writing an edit. and so if one process hasn't completed writing when another attempts to read, it'll get a corrupted file, and then wipes the whole thing

this becomes really evident when mounting it as a file to a container; if lots of claudes are running, and .claude.json is large, the container is fairly likely to get less than a full file given docker's mount performance

Expected Behavior

have claude do an atomic rename of .claude.json

View original on GitHub ↗

15 Comments

jezweb · 1 year ago

is this why mine is full of 'pasted comments' ?

!Image

it eventually becomes unusable.

elee1766 · 1 year ago

yeah this happens to me multiple times a day during regular usage (working on 2-3 code bases)

it's sort of upsetting that a conversation history/state is stored here where my settings and mcps are also configured....

pipedexplumbing · 1 year ago

No update?

jezweb · 1 year ago

ive not seen it happen again but ive also not let claude touch the file except for the single terminal prompt command for injecting a new mcp server. ie, i never ask it to do anything to the file.

Liu-Eroteme · 1 year ago

Same here. I tried setting up a claude slash command that uses the !command syntax to run a script to fetch and summarize all my todo comments in parallel before handing over to the interactive instance, but running it once corrupts the .claude.json file multiple times...

which isn't just annoying because it kills my settings, it's annoying because it clutters up the summary with more Claude configuration file at /home/liu/.claude.json is corrupted errors than actual summaries.

I don't even need atomic writes, just a flag to run non-interactive claude (claude -p) without permission to edit the .claude.json file

abh · 1 year ago

Not sure if there's a new bug with this, but for me it just started this week.

% ls -latr .claude.json*
-rw-r--r--  1 ask  staff   980305 Jul  1 10:00 .claude.json.corrupted.1751389239208
-rw-r--r--  1 ask  staff   977247 Jul  1 19:48 .claude.json.corrupted.1751424481835
-rw-r--r--  1 ask  staff   976846 Jul  1 19:48 .claude.json.corrupted.1751424482017
-rw-r--r--  1 ask  staff   968884 Jul  1 22:31 .claude.json.corrupted.1751434288805
-rw-r--r--  1 ask  staff   936743 Jul  2 00:04 .claude.json.corrupted.1751439890877
-rw-r--r--  1 ask  staff   936874 Jul  2 00:15 .claude.json.corrupted.1751440514983
-rw-r--r--  1 ask  staff   936874 Jul  2 00:15 .claude.json.corrupted.1751440515066
-rw-r--r--  1 ask  staff   936874 Jul  2 00:15 .claude.json.corrupted.1751440515299
-rw-r--r--  1 ask  staff   730546 Jul  3 21:45 .claude.json.corrupted.1751604331479
-rw-r--r--  1 ask  staff   580402 Jul  4 00:49 .claude.json.corrupted.1751615384768
-rw-r--r--  1 ask  staff   624408 Jul  4 11:24 .claude.json.corrupted.1751653468680
-rw-r--r--  1 ask  staff   601032 Jul  4 11:52 .claude.json.corrupted.1751655143464
-rw-r--r--  1 ask  staff   601920 Jul  4 18:16 .claude.json.corrupted.1751678176115
-rw-r--r--  1 ask  staff        0 Jul  5 13:29 .claude.json.corrupted.1751747390118
-rw-r--r--  1 ask  staff        0 Jul  5 15:54 .claude.json.corrupted.1751756063643
-rw-r--r--  1 ask  staff  3929299 Jul  5 16:48 .claude.json.corrupted.1751759307055
-rw-r--r--  1 ask  staff  3929299 Jul  5 16:48 .claude.json.corrupted.1751759327534
-rw-r--r--  1 ask  staff  4123299 Jul  5 18:59 .claude.json.corrupted.1751767150687
-rw-r--r--  1 ask  staff  4028822 Jul  6 04:19 .claude.json.corrupted.1751800751712
-rw-r--r--  1 ask  staff  4030997 Jul  6 12:34 .claude.json.corrupted.1751830489178
-rw-r--r--  1 ask  staff        0 Jul  6 21:24 .claude.json.corrupted.1751862259470
-rw-r--r--  1 ask  staff  4049065 Jul  6 22:15 .claude.json.corrupted.1751865324414
-rw-r--r--  1 ask  staff        0 Jul  6 22:15 .claude.json.corrupted.1751865324696
-rw-r--r--  1 ask  staff  4052332 Jul  6 22:30 .claude.json.corrupted.1751866201455
-rw-r--r--  1 ask  staff        0 Jul  6 22:30 .claude.json.corrupted.1751866201509
-rw-r--r--  1 ask  staff  4052332 Jul  6 22:30 .claude.json.corrupted.1751866201511
-rw-r--r--  1 ask  staff       99 Jul  6 22:30 .claude.json.backup
-rw-r--r--  1 ask  staff      179 Jul  6 22:30 .claude.json

For what it's worth, the files I spot checked were all valid JSON according to jq.

jezweb · 1 year ago

i ended up deleting a pile of files like that, not sure maybe from claude crashing?

elee1766 · 1 year ago

me too. they appeared for me on reboot when i guess i restarted my computer without closing every claude code session gracefully.

i dont really care that much about losing like the prompt history. maybe being able to set mcps in settings would make it okay? https://docs.anthropic.com/en/docs/claude-code/settings#settings-files

juburr · 1 year ago

Whenever I have Claude Code doing something heavy, it can eat A LOT of disk space. Running out of disk space is one reason that causes an immediate panic & results in .claude.json being wiped. The next time you start Claude it complains that it's corrupt and wants you to setup from scratch again.

Liu-Eroteme · 1 year ago
Whenever I have Claude Code doing something heavy, it can eat A LOT of disk space. Running out of disk space is one reason that causes an immediate panic & results in .claude.json being wiped. The next time you start Claude it complains that it's corrupt and wants you to setup from scratch again.

definitely not that - I ran into this issue on a 2tb partition that was maybe 10% full

.. I'm pretty sure it's parallel claude code instances - but it might've been fixed, because I haven't run into it since tbh - might try to reproduce on monday

elee1766 · 1 year ago
.. I'm pretty sure it's parallel claude code instances - but it might've been fixed, because I haven't run into it since tbh - might try to reproduce on monday

i think what was causing it for me is that i would kill every claude code instance at once with a killall command after being done working in parallel between 3-4 sessions, and them all trying to save at once broke things, but this also hasnt happened to me in a while so maybe its fixed and we can all rejoyce

jezweb · 1 year ago

Used claude code to clear it. By asking to clean the file because it was too large.


Your .claude.json file is 101 MB and contains 90 projects, all of which are:
     - Unnamed projects
     - Have no timestamp information
     - Appear to be empty or orphaned project entries

     Safe Cleanup Strategy:

     1. Create a backup of the current file
     2. Remove all 90 unnamed/empty projects while preserving:
       - All configuration settings (user ID, MCP servers, etc.)
       - Any named projects (currently none found)
       - All non-project data
     3. Verify the cleaned file works correctly
     4. Keep the backup for 30 days as a safety measure

     Expected Results:

     - File size reduction: From 101 MB to ~0.03 MB (99.9% reduction)
     - No loss of important settings or active projects
     - Claude Code will continue working normally

     Steps I'll execute:

     1. Create timestamped backup: .claude.json.backup-YYYYMMDD
     2. Create cleaned version removing all unnamed/empty projects
     3. Replace original file with cleaned version
     4. Verify file integrity and Claude Code functionality

Still don't know what causes it

github-actions[bot] · 8 months ago

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.

github-actions[bot] · 7 months ago

This issue has been automatically closed due to 60 days of inactivity. If you're still experiencing this issue, please open a new issue with updated information.

github-actions[bot] · 7 months ago

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.