Skip to content
BENIBIX Learn

Edit Tool

AI⌨️ Claude CodeBuilt-in Tools

Also known as Edit, Claude Code Edit tool, old_string new_string

The tool that swaps one exact piece of text in a file.

Think of it like

It is like rubbing out one word and writing a new one.

Example

Jack asks Claude to rename one setting. Claude uses Edit to swap that one line, and the rest of the file stays as it was.

Why it matters

Small, exact changes are easy to review and hard to get wrong.

Definition

The Edit tool changes one part of a file. It takes a piece of old text and the new text to put in its place. The old text must match the file exactly, down to the spaces. It must also appear only once, unless Claude asks to replace every copy. Edit does not use patterns or guess. An Edit rule with a path also covers Write and NotebookEdit.

Example code

json
{"permissions": {"allow": ["Edit(./src/**)"]}}
Let Claude change files in src and not ask.
Edit swaps one exact piece. The rest stays put.

Common mistake

Expecting a near match to work. One space off and the edit fails, so Claude reads the file first.

Key takeaways

  1. 1
    Old text, new text. An exact swap.
  2. 2
    Must be unique. Or replace all.
  3. 3
    No guessing. No patterns.

Compare

Learn it properly