Repository navigation
Description
Summary
Claude Code experiences configuration file corruption that causes repeated crashes and requires manual
intervention to resolve.
Environment
- Claude Code Version: Latest
- Operating System: Linux (Ubuntu-based)
- Node Version: v18+
- Project Type: TypeScript/Node.js application using MCP (Model Context Protocol)
Description
The Claude Code configuration/state files become corrupted during normal operation, leading to:
- Repeated crash loops (1200+ restarts observed)
- Service unavailability
- Manual file deletion required to restore functionality
Steps to Reproduce
- Run Claude Code in a project with active file monitoring
- Allow it to run continuously for several hours/days
- Perform normal development activities (file changes, analysis, etc.)
- Configuration file eventually becomes corrupted
- Service enters crash loop state
Expected Behavior
- Configuration files should remain valid during normal operation
- Service should handle corrupted files gracefully with automatic recovery
- No manual intervention should be required for continuous operation
Actual Behavior
- Configuration/state files become corrupted (invalid JSON)
- Service crashes when attempting to read corrupted files
- PM2 or process manager enters infinite restart loop
- Manual deletion of corrupted files required to restore service
Error Messages
SyntaxError: Unexpected token in JSON at position X
Error: Failed to parse configuration file
Process crashed with exit code 1
PM2: Process restarted 1200+ times
Workaround
Currently requires manual intervention:
Stop the service
pm2 stop claude-code
Remove corrupted files
rm -f /tmp/claude-code-state/.json
rm -f ~/.claude/config/.json
Restart service
pm2 restart claude-code
Impact
- Severity: High
- Frequency: Intermittent but recurring
- Service becomes completely unavailable
- Requires manual intervention defeating 24x7 operation goals
- Loss of productivity during downtime
Suggested Fix
- Implement robust error handling for configuration file parsing
- Add file validation before parsing (check file size, basic structure)
- Implement automatic backup/restore mechanism
- Add corruption detection and self-healing
- Use atomic file writes to prevent partial/corrupted writes
Additional Context
- Issue occurs more frequently under high load
- Large project analysis seems to correlate with corruption
- Files grow unbounded until corruption occurs
- No built-in monitoring alerts when corruption happens
Reproduction Files
Example of corrupted configuration structure:
{
"version": "1.0",
"projects": [
{
"path": "/path/to/project",
"analysis": {
// File cuts off here - incomplete JSON
Related Issues
- Service reliability for production use
- Need for high availability architecture
- Lack of automatic recovery mechanisms
Note: This issue prevents Claude Code from being used as a reliable 24x7 service without constant manual
monitoring and intervention.
Activity
pauljm commentedon Jul 2, 2025
I'm seeing this as well. Seems likely to be a concurrency issue as it happens when I run multiple instances of Claude Code in parallel.
steipete commentedon Jul 7, 2025
I run around 5-10 instances concurrently and see this happen almost every day. It seems once that json file goes >8MB claude craps out.
haasonsaas commentedon Jul 7, 2025
Echoing the above — I typically run no more than 2–4 instances at a time. However, every command input is being captured. Since I work extensively with cloud tooling, this results in a wide variety of commands being logged. When I mark these as "always allow," the configuration file quickly fills up and becomes corrupted once it hits around 8MB.
(Running on CC latest on 26.0 Beta)
mitsuhiko commentedon Jul 7, 2025
I run around 2-4 agents concurrently, but usually in different places, so I don't have to run on the same repository/folder. It's on Mac, and I see this failure mode of it corrupting the file. I think that it has to do with file size. I'm noticing this really only when the file gets very large that it will happen.
mergesort commentedon Jul 8, 2025
I usually run about 2-3 instances at a time, but I'm trying to run just one and still running into this bug. Since I saw a spate of logs ever time I launch Claude Code it asks me to reconfigure my environment, starting with light/dark mode, terminal setup, etc.
jfuginay commentedon Aug 14, 2025
I've implemented a fix for this configuration corruption issue. The solution includes atomic writes, automatic backups, and recovery mechanisms to prevent crash loops.
PR: #5798
The fix has been tested locally and all tests pass successfully.
steipete commentedon Aug 14, 2025
lol. I also got a few such PRs from him. Complete untested nonsense.
Fix: Prevent configuration file corruption (issue anthropics#2810)
Fix: Prevent configuration file corruption (fixes anthropics#2810)
6 remaining items
flcl0213-ship-it commentedon Dec 4, 2025
Root Cause:
The .claude.json configuration file became corrupted (similar to #5655). Deleting and letting VSCode recreate it resolved the issue immediately.
This solution worked on Windows 11 with the latest Claude Code extension.
jfuginay commentedon Dec 4, 2025
Depends on your definition of solved.
Some power users rely on saving and reusing things in their .claude.json
Having many claude code sessions makes the file become too large and corrupt much faster.
github-actions commentedon Jan 4, 2026
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.
georgiai1 commentedon Jan 5, 2026
I just got my file corrupted and have to start a new. Windows user here
llioor commentedon Jan 28, 2026
remove those files and try to login again
meesp123 commentedon Feb 26, 2026
this issue happened to me lately.
usl-cto commentedon Feb 26, 2026
Reproduction on Windows — v2.1.59 with Task tool subagents
Environment:
Trigger: Running a session that spawns 2+ parallel Task tool subagents (e.g., an Explore agent + a research agent). The main process + subagents = 3 concurrent writers to
~/.claude.json.Result: 36 corrupted backup files generated in a single session (~2 minutes), all with
JSON Parse error: Unexpected EOF. The corrupted files show:userIDhashes across files (each partial write produces inconsistent state)Interesting finding from cross-referenced issue #26717: The logs show that atomic write-rename was attempted but fails on Windows:
So the fix (atomic rename) exists in the codebase but is broken on Windows —
EPERMon rename suggests another process has the file open, and Windows doesn't allow renaming over open files (unlike POSIX). The lock file approach also fails because the lock is already held by a sibling process.Suggested fix for Windows: Use
fs.renamewith retry logic + exponential backoff, or useproper-lockfilewithretriesoption. Alternatively, have subagents delegate all config writes to the parent process via IPC rather than writing directly.Question: Is there a previous version of Claude Code that did not exhibit this issue? Would like to know if downgrading is a viable temporary workaround while this is being fixed.
DmitriyYukhanov commentedon Feb 26, 2026
I think 2.1.50 doesn't corrupt configs as per #28847 (comment)
Struggling from 2.1.59 ruining processes too.
patrikhuber commentedon Feb 26, 2026
The same is happening to me too on Windows. Running multiple Claude Code CLI instances was always fine, but since a restart this evening, the second terminal triggers
I'm on 2.1.59 as well, I've been for a day or so but it's possible I haven't opened multiple terminals until now.
duaneking commentedon Feb 28, 2026
I'm getting this all over the place for the last couple days and I absolutely hate it
patrikhuber commentedon Feb 28, 2026
It's fixed in the latest version, I haven't had it again since updating yesterday.
junaidtitan commentedon Mar 3, 2026
We kept hitting this with multiple Claude instances. Built cozempic to detect and auto-repair .claude.json corruption — open source.
Scans for invalid JSON, numStartups anomalies, and rapid backup file creation (the cascade pattern). Feedback welcome.