Edit tool changes silently reverted when Bash tool triggers file compilation

Resolved 💬 3 comments Opened Apr 4, 2026 by Rifampin Closed Apr 4, 2026

Description

The Edit tool reports successful file modifications, but the changes are silently reverted when a subsequent Bash tool call triggers a process that reads those files (e.g., cargo test, cargo clippy, cargo fmt).

Reproduction

  1. Use the Edit tool to modify a tracked file (e.g., add new functions to a Rust source file)
  2. Edit tool reports: "has been updated successfully"
  3. Immediately verify via Bash grep — change is on disk
  4. Run cargo test --workspace via Bash tool
  5. A system-reminder appears: "Note: file.rs was modified, either by the user or by a linter"
  6. Check file via Bash — changes are gone, file reverted to pre-Edit state

Key observations

  • Edit tool writes ARE reaching disk — immediate Bash grep/head confirms the content is there
  • Bash-based writes (echo >>, sed -i) survive the same cargo test call — only Edit tool changes are reverted
  • The revert coincides with a system-reminder claiming the file was "modified by a user or a linter"
  • Multiple files affected simultaneously — both lib.rs and render.rs revert in the same cargo test run
  • The issue is reproducible within a single session — tested 3 times with the same result
  • Untracked (new) files created via Write tool are NOT affected — only modifications to existing tracked files
  • Git stashes, hooks, filters, smudge/clean, worktrees, and file watchers were all ruled out

Environment

  • Claude Code CLI (claude-opus-4-6, 1M context)
  • Linux 6.17.0-19-generic
  • Files: Rust source files in a cargo workspace
  • The Bash command that triggers the revert does not itself modify the files — it only reads/compiles them

Expected behavior

Edit tool changes should persist through subsequent Bash tool calls that read (but don't write to) the same files.

Actual behavior

Edit tool changes are silently reverted. Claude Code appears to restore a cached/stale version of the file when it detects the file was "accessed" during a Bash compilation step, overwriting the Edit tool's changes.

Workaround

Apply changes via sed/patch through the Bash tool instead of the Edit tool. Bash-based writes are not affected.

View original on GitHub ↗

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