[BUG] Re-entering plan mode with Edit tool leaves old plan content concatenated

Resolved 💬 3 comments Opened Mar 31, 2026 by mellowmarshall Closed Apr 4, 2026

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

  1. Enter plan mode, write Plan A to the plan file, exit plan mode
  2. Start a new task, re-enter plan mode (system prompt says 'A plan file already exists... modify the existing plan')
  3. Model uses Edit tool to replace the top portion of the file with Plan B
  4. 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.

View original on GitHub ↗

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