Learning CenterClaude Code MasteryEditing Files with the Edit Tool
Beginner6 min read

Editing Files with the Edit Tool

Master how Claude Code edits files — understanding the diff-based approach, reviewing changes, and handling conflicts.

How Claude Code Edits Files

Claude Code never edits files silently. Every file modification goes through the Edit tool, which shows you a diff-style preview before writing the change. You can approve, reject, or modify proposed edits.

The Edit Approval Flow

When Claude proposes an edit, you'll see:

  1. File path — exactly which file will change
  2. Diff — old content (red) vs new content (green)
  3. Approval prompt — press Enter to accept, 'n' to reject

Never feel pressured to approve edits you don't understand. Ask Claude to explain the change first.

Asking for Targeted Edits

Be specific about scope:

In src/lib/auth.ts, change the JWT expiry from 24 hours to 7 days. Only touch that specific constant.

Specificity prevents Claude from making unrelated "improvements" you didn't ask for.

Multi-File Edits

For changes that span files, Claude will present each file's diff separately:

Rename the UserProfile interface to UserAccount across all TypeScript files. Update all imports.

Claude will read all affected files, propose each change in sequence, and let you approve each one.

When Claude Gets It Wrong

If an edit is wrong, reject it and give feedback:

That edit introduced a bug — the function signature changed but the callers weren't updated. Fix the callers too.

Claude maintains context across the rejection and will retry with the corrected approach.

Reading Files After Edits

Always re-read a file after editing it, especially in long sessions. Claude Code's memory of file state can drift if many edits have happened:

Re-read src/lib/auth.ts and confirm the changes look correct.

Dry Run Mode

Ask Claude to describe what it would do before doing it:

Don't make any changes yet. Just describe exactly what edits you'd make to implement this feature.

This is useful for reviewing a plan before committing to execution.

Loading…