Paths Subjects Questions Quizzes Pricing Search
Beginner Open Free

What Makes the Edit Tool Refuse to Apply a Change

A developer asks Claude Code to change a single default value in config.py. Claude calls the Edit tool, and it comes back with an error instead of applying the change.

Which of the following is the actual reason Claude Code's Edit tool fails and reports an error, rather than applying some version of the requested change?

Solution

The correct answer is "The old_string doesn't uniquely match the file's exact contents."

Edit performs exact, literal string replacement: it looks for the precise old_string it was given and requires that string to appear in the file exactly once (unless replace_all is explicitly set). If that string isn't present verbatim, or it's present more than once with nothing distinguishing which occurrence was meant, Edit has no reliable way to know which text to change — so it refuses and reports the ambiguity back to Claude rather than guessing.

The other options describe things Edit simply doesn't check. Git commit status is irrelevant to Edit — it operates on whatever is currently on disk, tracked or not. There's no fixed line-count limit that causes Edit to fail. And Edit has no dependency on a linter having run; linting and editing are unrelated steps.

Share this question

← Back to Claude Code Fundamentals practice

We use cookies for product analytics to improve OmniAtlas. See our Privacy Policy.