Skip to content

[Bug] .claude.json corruption from concurrent instances on same machine #29003

@alanxchen85

Description

@alanxchen85

Description

Running multiple Claude Code instances simultaneously on the same Windows machine causes repeated .claude.json corruption due to write race conditions.

Environment

  • Claude Code v2.1.59
  • Windows 11 (10.0.26100)
  • Two concurrent instances in different repos/workspaces on the same machine

Steps to Reproduce

  1. Open two Claude Code sessions on the same machine (different repos)
  2. Use both actively (both writing to ~/.claude.json for internal state)
  3. Within minutes, one or both sessions report: Claude configuration file at C:\Users\<user>\.claude.json is corrupted: JSON Parse error: Unexpected EOF

Observed Behavior

  • 16 corruptions in approximately 1 hour of dual-instance usage
  • Auto-recovery system correctly detects corruption, backs up the bad file, and restores from last good backup
  • Both sessions continue functioning after recovery
  • The cachedGrowthBookFeatures object in .claude.json is the primary area of conflict — it gets truncated mid-write

Impact

  • Feature flag cache loss: Restored backup contains stale feature flags. Remote Control (claude remote-control) stops working because the restored cachedGrowthBookFeatures predates the feature gate being enabled for the account.
  • Noise: Repeated error messages disrupt workflow
  • State loss: Any .claude.json state written between the last backup and the corruption is lost

Expected Behavior

Concurrent Claude Code instances should safely share ~/.claude.json without corruption. Possible fixes:

  • Atomic writes (write to temp file, then rename — rename is atomic on most filesystems)
  • Per-instance state files (each instance gets its own cache file)
  • File locking

Evidence

Backup directory shows the pattern clearly:

# 16 corrupted files in ~1 hour, sizes vary (157 bytes to 18KB = truncation)
.claude.json.corrupted.1772099857550  (18243 bytes)
.claude.json.corrupted.1772099904936  (2565 bytes)
.claude.json.corrupted.1772101307584  (8710 bytes)
.claude.json.corrupted.1772101699755  (9348 bytes)
.claude.json.corrupted.1772101751603  (9427 bytes)
.claude.json.corrupted.1772101751657  (9427 bytes)
.claude.json.corrupted.1772101805772  (11686 bytes)
.claude.json.corrupted.1772101811912  (11686 bytes)
.claude.json.corrupted.1772101930972  (5769 bytes)
.claude.json.corrupted.1772102754102  (7564 bytes)
.claude.json.corrupted.1772102754200  (157 bytes)
.claude.json.corrupted.1772102760103  (2645 bytes)

Use Case

Multi-agent development workflows where multiple Claude Code instances operate on different projects simultaneously. This is a growing use case with Agent Teams support.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions