[BUG] Crash with Error: Cannot edit file: old_string is a substring of a new_string from a previous edit.
Resolved 💬 4 comments Opened Jul 17, 2025 by Yassine-64 Closed Jan 7, 2026
Environment
- Platform (select one):
- [x] Anthropic API
- [ ] AWS Bedrock
- [ ] Google Vertex AI
- [ ] Other:
- Claude CLI version:
claude-code/0.2.11<!-- replace with your actual version if different --> - Operating System: macOS 14.x (MacBook Pro 2021)
- Terminal: Terminal App (default macOS)
Bug Description
Claude Code CLI crashes immediately after completing the first TODO. The crash happens when it attempts a second edit, and throws the following error:
node:internal/process/promises:288
triggerUncaughtException(err, true /* fromPromise */);
^
Error: Cannot edit file: old_string is a substring of a new_string from a previous edit.
at oP (file:///Users/MAC/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:1652:530)
at cZ4 (file:///Users/MAC/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:2617:10945)
at J (file:///Users/MAC/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:2617:9923)
at file:///Users/MAC/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:2617:10189
at WD (file:///Users/MAC/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:21377)
at MY (file:///Users/MAC/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:40875)
at file:///Users/MAC/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:67:39071
at Lj1 (file:///Users/MAC/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:61:78877)
at Immediate.Hj1 [as _onImmediate] (file:///Users/MAC/.claude/local/node_modules/@anthropic-ai/claude-code/cli.js:61:79295)
at process.processImmediate (node:internal/timers:476:21)
Steps to Reproduce
- Run
claude devin a project with multiple TODOs - Let Claude complete the first TODO
- After attempting the second edit, the CLI crashes with the above error
Expected Behavior
Claude should handle multiple TODO edits sequentially without crashing, even if new strings overlap with previous ones.
Actual Behavior
Claude crashes with a Node.js error due to old_string being a substring of new_string from a previous edit. This breaks the editing flow and stops further progress.
Additional Context
- Node.js version:
v18.20.8 - Claude CLI installed locally via
npm - Error possibly caused by improper handling of overlapping diffs or string replacements across edits
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗