Claude Code Edits Break When the Model Guesses Wrong. Here’s a Fix.
You’re deep into a Claude Code session. The agent edits a file — but the string it’s trying to match doesn’t quite exist. Maybe the file changed since the agent last read it. Maybe the model hallucinated a few characters. Either way, the edit fails, the agent re-reads the whole file to get back in sync, and you’ve just burned tokens for nothing.
This happens because Claude Code’s built-in Edit tool uses string matching. The model sends the text it thinks is in the file, and hopes it matches. Most of the time it works. But when it doesn’t, the agent has to re-read the file and retry — wasting context window on content it already saw. In longer sessions, these re-reads add up.
I got tired of it, so I built trueline-mcp.
Every edit is verified against reality
The idea is dead simple. When the agent reads a file through trueline, every line comes back tagged with a short hash:
1:bq|import { Server } from "@modelcontextprotocol/sdk/server/index.js";
2:ab|
3:mz|const server = new Server({ name: "trueline-mcp", version: "0.1.0" });
checksum: 1-3:a4b5
When the agent wants to edit, it echoes those hashes back. If the file changed since the read — another tool modified it, you saved in your editor, anything — the hashes won’t match and the edit is rejected before it touches disk. No guessing, no surprise failures halfway through a session.
This also means the agent can make targeted, surgical edits. Instead of hoping a string match lands in the right place, it specifies exact line ranges with proof that it’s looking at the right content. Multiple edits to the same file go through in a single call, each independently verified. The result is fewer re-reads, fewer wasted tokens, and edits that land exactly where they should.
Three tools, zero config
trueline_read— reads a file, tags each line with a hash, returns a range checksum.trueline_edit— verifies hashes, then applies the edit atomically. Supports multiple edits per call.trueline_diff— same verification, but outputs a unified diff without touching disk. Good for previewing changes before committing to them.
Once installed, a SessionStart hook nudges the agent toward the trueline tools, and a PreToolUse hook blocks the built-in Edit tool so it can’t fall back to string matching. The agent uses verified edits from the start, automatically.
Security-wise, trueline enforces the same deny patterns Claude Code uses (.env, *.key, etc.)
Try it
/plugin marketplace add rjkaes/trueline-mcp
/plugin install trueline-mcp@trueline-mcp
That’s it. Your next Claude Code session will use hash-verified edits automatically. No configuration, no changes to your workflow.
Prior art
Can Boluk described the underlying problem — AI agents working against stale state — and Seth Livingston built a hash-line edit tool for VS Code. trueline-mcp brings the same idea to Claude Code as an MCP plugin.
The code is on GitHub: rjkaes/trueline-mcp. Apache-2.0, TypeScript, built with Bun.