Skip to content

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

Closed as not planned

Description

@max-sixty

Environment

  • Platform (select one):
    • Anthropic API
    • AWS Bedrock
    • Google Vertex AI
    • Other:
  • Claude CLI version: 1.0.35
  • Operating System: macOS
  • Terminal: 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

Activity

  1. jezweb commented on Jun 27, 2025

    @jezweb

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

    Image

    it eventually becomes unusable.

  2. elee1766 commented on Jun 27, 2025

    @elee1766

    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....

  3. pipedexplumbing commented on Jul 2, 2025

    @pipedexplumbing

    No update?

  4. jezweb commented on Jul 3, 2025

    @jezweb

    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.

  5. Liu-Eroteme commented on Jul 4, 2025

    @Liu-Eroteme

    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

  6. abh commented on Jul 7, 2025

    @abh

    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.

  7. jezweb commented on Jul 7, 2025

    @jezweb

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

  8. elee1766 commented on Jul 7, 2025

    @elee1766

    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

  9. juburr commented on Jul 17, 2025

    @juburr

    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.

  10. Liu-Eroteme commented on Jul 25, 2025

    @Liu-Eroteme

    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

  11. elee1766 commented on Jul 25, 2025

    @elee1766

    .. 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

  12. jezweb commented on Aug 23, 2025

    @jezweb

    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

  13. github-actions commented on Dec 4, 2025

    @github-actions

    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.

  14. github-actions commented on Jan 4, 2026

    @github-actions

    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.

  15. github-actions commented on Jan 11, 2026

    @github-actions

    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.

  16. locked as resolved and limited conversation to collaborators on Jan 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:coreautocloseIssue will be closed automaticallybugSomething isn't workinghas reproHas detailed reproduction stepsplatform:macosIssue specifically occurs on macOS

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions