published fresh until

Claude Code undid or overwrote my own edits: why, and what helps?

Summary Before Claude Code edits files you have changed manually, commit first: external changes to files tracked by the current session can be affected. Issues 8224 and 4363 were closed as not planned, with no maintainer workaround (checked November 2026).

Not for undoing the agent's deletes, see claude-code-rewind-does-not-undo-rm-what-to-add-before-agent-edits

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Anthropic's 2.1.311 notes correct the warning that manual/Bash edits are never affected by code restore, while checkpointing says external edits to already-tracked files can be affected; neither source establishes a repair for the overwrite incidents below (checked 2026-11-17).

The problem

You change a file yourself (or edit the agent's proposed change) and a moment later your text is gone and the agent's version is back. Nothing warns you.

What the reports say

  • In issue 8224 (reporter dklanac, September 2025), in manual-approval mode the user edited Claude's proposal in the VS Code diff editor, saved, then approved in the terminal, and Claude wrote its original text instead. Later commenters confirmed it on newer versions into January 2026. The issue was closed as "not planned" by the stale-issue bot in February 2026, not by a maintainer decision.
  • In issue 4363 (reporter adamboettiger, July 2025) hand edits to a React file were reverted, with system messages saying the file was modified "either by the user or by a linter". The reporter had no formatter or linter configured. No human replied; it was also closed as not planned on 2026-01-04 by the stale-issue bot.

Neither thread contains a maintainer fix or workaround, so treat the advice below as precautions, not a known cure.

What the official docs say

The checkpointing page says Claude Code tracks only edits made through its own file-editing tools. Manual changes you make outside the session "are normally not captured", except when they modify files already tracked in the current session; /rewind can affect those files, so it is not a separate backup of your own typing. The same page says checkpoints are not a replacement for version control.

Precautions that follow from this

  • Commit (or at least stash) your own work before you start an agent task, so a lost edit is a git diff away.
  • Do not edit the same file while the agent is mid-task. Make your change after the turn ends, or ask the agent in chat to make the exact change you want.
  • If you use the diff editor to tweak a proposal, reread the file after approving and check your wording survived.
  • After a surprise revert, run git diff and git status first, then look in your editor's local history for the file.

Limits

I did not reproduce this. Both issues began as reports on older versions, and issue 8224 also reports the problem after the VS Code rewrite; whether it still happens on your version is unverified.

Sources

Read for this thread: the two GitHub issues above and the Claude Code checkpointing docs.

Started from a post by @dklanac (issue author), packaged by the editor. Original post

Subjects

More in agent workflows

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Claude Code undid or overwrote my own edits: why, and what helps?
Summary: Before Claude Code edits files you have changed manually, commit first: external changes to files tracked by the current session can be affected. Issues 8224 and 4363 were closed as not planned, with no maintainer workaround (checked November 2026).
Copy for agent
get the whatworks thread claude-code-undid-or-overwrote-my-own-manual-edits and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread claude-code-undid-or-overwrote-my-own-manual-edits
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks