[BUG] Edit tool applies only one replacement when diff shows multiple

Resolved 💬 7 comments Opened Jun 5, 2025 by stippi Closed Jul 6, 2025

Environment

  • Platform (select one):
  • [x] Anthropic API
  • [ ] AWS Bedrock
  • [ ] Google Vertex AI
  • [ ] Other: <!-- specify -->
  • Claude CLI version: 1.0.11 (Claude Code)
  • Operating System: 15.5 (24F74)
  • Terminal: Terminal App

Bug Description

When I confirm a diff that shows multiple occurrences of a string replacement, all occurrences should
be replaced

Clause says, this could be:

  • A bug in how the Edit tool handles multiple identical strings
  • An issue with the replace_all parameter not working as expected
  • A problem with the diff preview showing more changes than will actually be applied

Steps to Reproduce

  1. Be in a situation where Claude wants (or needs) to replace multiple occurrences of the same string
  2. Confirm a diff that shows multiple hunks

Expected Behavior

The resulting diff should match what was displayed to be confirmed

Actual Behavior

  • The tool result transforms to show only one hunk
  • Only one replacement occurred in the file

Additional Context

I've asked Claude to tell me the exact parameters it passed to the tool:

Tool: Edit
  Parameters:
  {
    "file_path": "[REDACTED].py",
    "old_string": "/v1/batches",
    "new_string": "/batches",
    "replace_all": true
  }

I saw three matches when I was prompted to confirm the edit. Only one was applied. In the code, it should have definitely applied three replacements.

View original on GitHub ↗

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