Desktop app: Bash tool file writes silently revert even with sequential execution

Resolved 💬 3 comments Opened Mar 28, 2026 by j2e7 Closed May 1, 2026

Description

Follow-up to #40341. The file vanishing issue is more severe than initially reported. It is NOT limited to parallel Bash tool calls — sequential writes also revert silently.

Updated Reproduction

In a single Claude Desktop session (macOS), over ~90 minutes:

  1. Files created via cat > path << 'EOF' in sequential (non-parallel) Bash tool calls
  2. Verified with ls -la in the same Bash call — all showed correct sizes and timestamps
  3. Verified again in a separate Bash call minutes later — files had reverted or vanished entirely

Specific observations:

  • 4 cat >> appends to an existing file (lessons-learned.md) — all 4 appends lost. File reverted from 25,618 bytes to 21,797 bytes. Original content intact, only new appends disappeared.
  • 4 new files created in brain/ subdirectories via cat > — vanished 3 separate times across the session despite recreation each time.
  • Python script writes (open(path, 'w')) to the same directories survived every time. Only Bash tool cat writes are affected.
  • Files created via cat > in a single Bash call with && chaining also vanished.
  • The sync command after writes appears to fix the issue (forces OS filesystem flush).

Root Cause Hypothesis

The Bash tool's process lifecycle does not ensure filesystem writes are flushed (fsync/sync) before the process context is torn down. The OS write buffer shows the file as existing (so ls -la passes), but the actual disk write hasn't completed when the Electron wrapper cleans up the child process. Python's open().write().close() likely triggers an implicit flush on file handle close, which is why Python writes survive.

Impact

This causes real data loss in production use. Files appear saved, pass verification, then silently revert to their pre-write state. Users only discover the loss when they access the file later. The silent nature makes it particularly dangerous — there is no error, no warning, and the in-session verification passes.

Workaround

Adding && sync after every cat write in the Bash tool forces the OS to flush pending writes to disk. This appears to prevent the reversion. Users should also verify file sizes in a separate Bash tool call, not the same one that performed the write.

Environment

  • Claude Desktop app (macOS Sequoia 15.4, Apple Silicon)
  • APFS filesystem
  • Claude Code version 2.1.85
  • Model: Claude Opus 4.6 (1M context)
  • Session duration: ~90 minutes
  • Multiple occurrences across the session, not a one-time event

View original on GitHub ↗

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