Skip to content

Edit tool changes to git-tracked files silently reverted during context compaction #34674

@Ascendral

Description

@Ascendral

Summary

When a long conversation triggers context compaction (message compression), uncommitted changes made via the Edit tool to git-tracked files are silently reverted to their git HEAD state. New files created with the Write tool are not affected.

Steps to Reproduce

  1. Start a Claude Code session in a git repository
  2. Make multiple Edit-tool changes to tracked src/ files across a long conversation
  3. Continue working until context compaction triggers (conversation approaches context limit)
  4. Check file contents after compaction — Edit-tool changes are gone

Observed Behavior

  • Edit-tool changes to tracked files disappear between tool calls after compaction
  • New files (untracked by git) survive compaction
  • Bash-written changes (e.g., echo >> file) also survive
  • Changes committed to git before compaction are never lost
  • No git hooks, file watchers, or external processes are responsible (verified)

Expected Behavior

Edit-tool changes should persist regardless of context compaction. The file system should not be modified by the compaction process.

Workaround

Commit immediately after every Edit-tool change:

git add <file> && git commit -m "description"

Or for multi-file atomic changes, write a Node.js script to /tmp/ using fs.writeFileSync, then chain:

node /tmp/fix.js && git add <files> && git commit -m "description"

Environment

  • Claude Code v2.1.74
  • Claude Desktop (macOS)
  • macOS 26 (Darwin 25.3.0)
  • Model: claude-opus-4-6
  • Plugins: typescript-lsp (not installed/running), pyright-lsp, others

Metadata

Metadata

Assignees

No one assigned

    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