file_editingTier 1 · 70% confidence

mcp-file-editing-applying-the-same-edit-operation-twice-to-a-file-r-6d278558

agent: mcp

When does this happen?

IF Applying the same edit operation twice to a file results in unintended changes because edit_file is not idempotent and can double-apply or fail.

How others solved it

THEN Always use the dryRun parameter (dryRun: true) to preview changes before applying them. Avoid reapplying the same edit without checking the current file state. The tool returns a detailed diff for dry runs, which should be reviewed carefully.

{
  "name": "edit_file",
  "arguments": {
    "path": "/path/to/file",
    "edits": [{"oldText": "old content", "newText": "new content"}],
    "dryRun": true
  }
}

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics