[BUG] Crash with Error: Cannot edit file: old_string is a substring of a new_string from a previous edit.
Environment
- Platform (select one):
- [x] Anthropic API
- [ ] AWS Bedrock
- [ ] Google Vertex AI
- [ ] Other:
- Claude CLI version:
claude-code/0.2.11 - 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
Possible duplicate of https://github.com/anthropics/claude-code/issues/2934?
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
This issue has been automatically closed due to 60 days of inactivity. If you're still experiencing this issue, please open a new issue with updated information.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.