Edit/Write tool should auto-read files instead of erroring
Problem
The Edit and Write tools require that a file has been Read first, otherwise they fail with an error. When this happens, the model must:
- Attempt Edit → get error ("You must read the file before editing")
- Call Read on the file
- Re-attempt the Edit
This wastes 3 tool calls for what should be 1. It burns tokens, increases latency, and provides zero value to the user.
Expected Behavior
If the Edit/Write tool detects the file hasn't been read yet, it should automatically read it internally before applying the edit — not error out and force a round-trip.
The tool already knows which file is being edited. It already has the ability to read files. There is no reason to surface this as an error.
Prior Issues
- #4230 (closed 2025-08-19) — "Write tool should auto-read files instead of requiring explicit read first"
- #16546 (closed) — "Model attempts file edits without reading file first, wasting tokens and time"
Both were closed but the problem persists as of 2025-03 on Claude Opus 4.6. The underlying design issue (error instead of auto-read) was never addressed.
Impact
- Token waste: 3 tool calls instead of 1, every time this occurs
- Latency: Additional round-trips for no user benefit
- User frustration: The system knows exactly what to do but refuses to do it
Environment
- Claude Code version: latest (2025-03)
- Model: Claude Opus 4.6
- Platform: Windows 11
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗