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
- Use the Edit tool to modify a tracked file (e.g., add new functions to a Rust source file)
- Edit tool reports: "has been updated successfully"
- Immediately verify via Bash
grep— change is on disk - Run
cargo test --workspacevia Bash tool - A system-reminder appears: "Note: file.rs was modified, either by the user or by a linter"
- Check file via Bash — changes are gone, file reverted to pre-Edit state
Key observations
- Edit tool writes ARE reaching disk — immediate Bash
grep/headconfirms the content is there - Bash-based writes (
echo >>,sed -i) survive the samecargo testcall — 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.rsandrender.rsrevert in the samecargo testrun - 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.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗