.claude.json corrupted with 'Unexpected EOF' when statusline is enabled — race condition

Resolved 💬 4 comments Opened Feb 26, 2026 by Oximito Closed Feb 27, 2026

Summary

The .claude.json configuration file gets corrupted with JSON Parse error: Unexpected EOF when a custom statusline command is configured in settings.json. This happens consistently when using Claude Code with an active statusline.

Steps to reproduce

  1. Configure a custom statusline in ~/.claude/settings.json
  2. Use Claude Code normally (run multiple commands)
  3. After a few minutes to hours of usage, the config file gets truncated

Environment

  • Claude Code version: 2.1.x
  • OS: Windows 11
  • Statusline: Custom PowerShell script

Error message

Claude configuration file at C:\Users\pedro\.claude.json is corrupted: JSON Parse error: Unexpected EOF
The corrupted file has been backed up to: C:\Users\pedro\.claude\backups\.claude.json.corrupted.[timestamp]

Root cause analysis

The issue is a race condition in how Claude Code handles .claude.json writes:

  • Claude Code performs non-atomic file writes (read → modify → write pattern)
  • The statusline script executes frequently and passes data via stdin
  • When both try to access the file simultaneously, one write operation gets interrupted mid-process, leaving the JSON file truncated

Evidence:

  • Bash.usageCount exploded from 7 to 1851 in corrupted version (indicating multiple rapid writes)
  • File truncated exactly at the JSON closing character, typical of interrupted write
  • Happened twice already in different sessions

Expected behavior

The config file should be updated atomically or with proper file locking to prevent concurrent write corruption.

Actual behavior

File gets truncated and Claude Code crashes on startup, requiring manual restoration from backup.

---
This is a critical stability issue for users with statusline configurations.

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗