[BUG] EditTool uses insane amount of tokens for simple edits

Resolved 💬 3 comments Opened Jan 10, 2026 by szwagros Closed Feb 28, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

When editing large file (around 2k lines of code) with simple one line change it used 30k tokens of context window. I made another one (also one line change) another 30k tokens used. I asked claude why this happens and this is his answer:

The problem is internal to Claude Code's Edit tool:

  • When I make an edit, the tool returns a snippet of the file back to me (the AI) to confirm what changed
  • For small files, this is fine
  • For a 2200-line file like NCPScanner_v2.mq5, it returns hundreds/thousands of lines in the result

You can see it in the output above - after my second edit, the result showed lines 1-2213 (the entire file!).

This is a Claude Code tool design issue. The tool should return less context for large files.

What Should Happen?

When editing large files output from Edit Tool should be localized to place where changes were made - not whole file. Or maybe add confifguration option of how much output can edit tool return.

Error Messages/Logs

Steps to Reproduce

Use large code file (e.g. 2k lines) m and ask Claude to make simple edit e..g add import statemant / include - depending on language used. What 30k tokens used for this edit

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

2.1.3 (Claude Code)

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

IntelliJ IDEA terminal

Additional Information

_No response_

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗