[BUG] After patch rejection, Claude Code can still apply unrelated source edits and leave strange artifacts

Resolved 💬 3 comments Opened Apr 2, 2026 by j32097072 Closed Apr 6, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

I asked Claude Code to apply a targeted patch or patch-based fix to a specific file.

When patch apply failed, Claude did not stop. It left reject artifacts (.rej / .orig) and then made additional manual edits not strictly tied to the failed patch operation.

In short: failed patch path was followed by unrelated edits, which left the repo in a mixed state.

What Should Happen?

If patch application fails, Claude should stop, report the failure clearly, and avoid introducing unrelated manual source edits. It should not leave reject/orig artifacts together with new edits that were not part of the original patch path.

Error Messages/Logs

Patch apply failed: patch context did not match target file.
Observed bad behavior: .rej/.orig artifacts were left, then unrelated manual edits were still applied.

Steps to Reproduce

  1. Open a clean repository workspace.
  2. Ask Claude to apply a patch whose context is intentionally stale (so apply should fail).
  3. Ask it to stop and report failure if patch application does not match context.
  4. Let the patch fail, then inspect the workspace.
  5. Reproduction matches if .rej / .orig files are left behind and Claude continues with unrelated manual edits instead of stopping.

Claude Model

Other

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.76

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

WSL (Windows Subsystem for Linux)

Additional Information

_No response_

View original on GitHub ↗

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