claude-code - 💡(How to fix) Fix Claude Code fills entire disk via /tmp/claude-{uid} temp files (771 GB crash loop) [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#46479Fetched 2026-04-11 06:19:13
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Timeline (top)
labeled ×4

Error Message

Claude configuration file at /Users/mini/.claude.json is corrupted: JSON Parse error: Unable to parse JSON string The corrupted file has been backed up to: /Users/mini/.claude/backups/.claude.json.corrupted.1775866517894 A backup file exists at: /Users/mini/.claude/backups/.claude.json.backup.1775865061735

Root Cause

Claude Code wrote ~771 GB of temporary files to /private/tmp/claude-501, filling a 1TB drive to 100% (101 MB free). This caused Claude Code itself to crash with "Configuration Error: invalid JSON" because it couldn't write to ~/.claude.json, which then triggered a restart loop creating even more temp files.

Fix Action

Workaround

sudo rm -rf /private/tmp/claude-501
cp ~/.claude/backups/.claude.json.backup.* ~/.claude.json
# reboot to clear any stuck processes

Code Example

Claude configuration file at /Users/mini/.claude.json is corrupted: JSON Parse error: Unable to parse JSON string
The corrupted file has been backed up to: /Users/mini/.claude/backups/.claude.json.corrupted.1775866517894
A backup file exists at: /Users/mini/.claude/backups/.claude.json.backup.1775865061735

---

tee: /Users/mini/.openclaw/logs/preflight.log: No space left on device
tee: stdout: No space left on device

---

sudo rm -rf /private/tmp/claude-501
cp ~/.claude/backups/.claude.json.backup.* ~/.claude.json
# reboot to clear any stuck processes
RAW_BUFFERClick to expand / collapse

Bug Report

Claude Code version: v2.1.101 OS: macOS Sequoia (Darwin 25.4.0), Mac Mini M2 Pro 32GB Filesystem: APFS, 926 GB volume

Problem

Claude Code wrote ~771 GB of temporary files to /private/tmp/claude-501, filling a 1TB drive to 100% (101 MB free). This caused Claude Code itself to crash with "Configuration Error: invalid JSON" because it couldn't write to ~/.claude.json, which then triggered a restart loop creating even more temp files.

Timeline

  1. ~/.claude.json was corrupted (truncated mid-write, likely during an SDK session refresh)
  2. Claude Code detects corrupted config → crashes
  3. On restart, writes temp files to /private/tmp/claude-501
  4. Crashes again → restarts → writes more temp files
  5. Disk fills to 100% → config writes fail even harder → infinite loop
  6. All other services on the machine were affected (tee: No space left on device, Telegram bot 409 conflicts, etc.)

Evidence from logs

Claude configuration file at /Users/mini/.claude.json is corrupted: JSON Parse error: Unable to parse JSON string
The corrupted file has been backed up to: /Users/mini/.claude/backups/.claude.json.corrupted.1775866517894
A backup file exists at: /Users/mini/.claude/backups/.claude.json.backup.1775865061735

This message repeated 50+ times in stderr, each iteration creating more temp data.

tee: /Users/mini/.openclaw/logs/preflight.log: No space left on device
tee: stdout: No space left on device

Impact

  • 771 GB of temp files written to /private/tmp/claude-501
  • Disk filled to 100%, all services on the machine affected
  • Required manual intervention: sudo rm -rf /private/tmp/claude-501 + reboot
  • ~45 minutes of downtime to diagnose and recover

Expected Behavior

  1. Claude Code should not write hundreds of GB to /tmp — there should be a size limit or periodic cleanup for temp files
  2. A corrupted ~/.claude.json should not cause an infinite restart loop — after N failures, Claude Code should stop retrying or recreate the config from the backup it already detects
  3. The backup detection message shows Claude Code knows a backup exists but doesn't auto-restore from it

Suggested Fixes

  • Add a max size cap for /tmp/claude-{uid} (e.g., 5 GB) with automatic cleanup of old temp files
  • On config corruption: auto-restore from backup after first detection instead of crash-looping
  • Add a circuit breaker: if Claude Code crashes N times within M minutes, stop restarting and log a clear error

Workaround

sudo rm -rf /private/tmp/claude-501
cp ~/.claude/backups/.claude.json.backup.* ~/.claude.json
# reboot to clear any stuck processes

extent analysis

TL;DR

To prevent Claude Code from filling the disk with temporary files and entering a restart loop, implement a size limit for temporary files and auto-restore the configuration from a backup when corruption is detected.

Guidance

  1. Implement temporary file size limit: Introduce a maximum size cap (e.g., 5 GB) for /tmp/claude-{uid} directories to prevent excessive disk usage.
  2. Auto-restore configuration from backup: Modify Claude Code to automatically restore the configuration from a detected backup when corruption is found, instead of crashing and restarting.
  3. Add a circuit breaker mechanism: Implement a circuit breaker that stops Claude Code from restarting after a specified number of crashes within a certain time frame, logging a clear error message instead.
  4. Monitor disk space and temporary files: Regularly monitor the disk space and temporary files to detect potential issues before they cause significant problems.
  5. Review backup and restore mechanisms: Ensure that the backup and restore mechanisms are functioning correctly and that backups are regularly created to prevent data loss.

Example

# Example of how to implement a simple cleanup script for temporary files
# This script assumes a maximum size of 5 GB for /tmp/claude-{uid} directories
find /private/tmp/claude-501 -type f -size +5G -delete

Note: This is a basic example and may need to be adapted to the specific requirements of Claude Code.

Notes

  • The suggested fixes and workaround are based on the information provided in the issue and may require modifications to the Claude Code application.
  • Implementing these changes may require additional testing to ensure they do not introduce new issues.

Recommendation

Apply the suggested fixes, including implementing a size limit for temporary files, auto-restoring the configuration from a backup, and adding a circuit breaker mechanism, as these changes address the root causes of the issue and can help prevent similar problems in the future.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING