[BUG] Re-entering plan mode with Edit tool leaves old plan content concatenated
Bug Report
Description
When re-entering plan mode for a different task, the system prompt instructs the model to edit the existing plan file. If the model uses the Edit tool to replace the beginning of the file but doesn't replace ALL content, the old plan's content remains appended below the new plan. The result is a plan file containing two unrelated plans concatenated together.
Steps to Reproduce
- Enter plan mode, write Plan A to the plan file, exit plan mode
- Start a new task, re-enter plan mode (system prompt says 'A plan file already exists... modify the existing plan')
- Model uses Edit tool to replace the top portion of the file with Plan B
- The file now contains Plan B followed by the remainder of Plan A's content
Expected Behavior
When re-entering plan mode for a different task, the old plan file should be fully replaced, not partially edited. The system prompt says 'start fresh by overwriting the existing plan' for different tasks, but the Edit tool only replaces matched strings, not the whole file.
Actual Behavior
Plan file contains concatenated content from two unrelated plans. In my case, a sync script fix plan was followed by a looping architecture plan from the previous session.
Environment
- Claude Code CLI on Windows/WSL
- Opus 4.6 (1M context)
Suggested Fix
When the model determines this is a different task, it should use Write (full file overwrite) instead of Edit (partial replacement) for the plan file. Or the plan mode system prompt should explicitly instruct using Write for different tasks.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗