claude-code - 💡(How to fix) Fix [BUG] Plan mode pins a stale plan file across topic pivots in same session (refile of stale-closed #21131) [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#53046Fetched 2026-04-25 06:13:49
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Author
Timeline (top)
labeled ×4commented ×1

Error Message

Error Messages/Logs

Fix Action

Fix / Workaround

  1. Mint a fresh three-word-slug plan file per topic by default. Existing plans become read-only references; never auto-pinned for write.
  2. Prompt "resume X or start a new plan file?" when an existing plan is detected, instead of silently pinning it.
  3. Allow the agent to touch a new file in ~/.claude/plans/ from within plan mode. (Today the read-only restriction blocks even creating a fresh sibling, which is what makes the CLAUDE.md-rule workarounds dead-end — see SeanHollen's comment on #21131.)

Option (1) is the cleanest. Option (3) is the smallest behavioral change and would make existing user-side rule workarounds actually viable.

  • Confirmed not a host/wrapper bug. Reproduces in Bearings (a claude-agent-sdk consumer). grep across the host's source shows no file-selection logic, no system-reminder emission, and no plan-path wiring through the host's session/prompt layer — every reference to ~/.claude/plans/ in the host is a comment pointing at planning docs for traceability. The reminder originates in the plan-mode harness exposed by claude-agent-sdk / the CLI.
  • Adam Goyer's comment on #21131 describes a PostToolUse hook workaround that copies plans to a git-tracked location, but the in-mode pin still destroys the original. SeanHollen's comment on #21131 shows the deadlock cleanly: even with strong CLAUDE.md rules forbidding plan-file overwrite, the agent correctly refuses to write — but has no escape hatch to create a fresh file from within plan mode.
  • Current workaround: drop out of plan mode, hand off to a fresh session, replan there. Applicable in long-lived UIs like Bearings; standalone CLI users typically /clear or restart, which trades context for correctness.
  • Sibling bug (filing separately once reproduced): plan-mode dropdown picker behavior in the claude-agent-sdk flow appears to be wired up incorrectly — needs its own repro before filing.

Code Example

$ ls -la --time-style=long-iso ~/.claude/plans/ | grep -E "ullman|otter"
-rw-r--r-- 1 user user 18853 2026-04-21 13:35 enumerated-inventing-ullman.md   ← pinned
-rw-r--r-- 1 user user 18097 2026-04-21 14:29 sparkling-triaging-otter.md      ← newer, NOT pinned

---

A plan file already exists at /home/<user>/.claude/plans/<slug>.md.
You can read it and make incremental edits using the Edit tool.

this is the only file you are allowed to edit — other than this you
are only allowed to take READ-ONLY actions.
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet (canonical thread #21131 was auto-closed stale 2026-04-08 with an explicit "open a new issue" invite; refiling per that instruction)
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code (reproduced via claude-agent-sdk (Python) 0.1.66 — see version field below)

What's Wrong?

When entering plan mode partway through a long-lived session that previously produced a plan file on a different topic, the plan-mode harness emits a system-reminder pinning that earlier file as the only file the agent is allowed to edit. Verbatim text the agent receives:

A plan file already exists at /home/<user>/.claude/plans/<earlier-slug>.md. You can read it and make incremental edits using the Edit tool. … this is the only file you are allowed to edit — other than this you are only allowed to take READ-ONLY actions.

The agent has no in-mode affordance to mint a fresh plan file. The result is a forced choice between (a) clobbering a still-valuable unrelated plan, or (b) appending a mismatched section to a file on a different topic.

This refiles the canonical bug #21131 (auto-closed stale 2026-04-08, locked 2026-04-15; the auto-close comment explicitly invites a refile) with crisper evidence isolating the selection mechanism. Related/duplicate threads: #35943, #18258, #12505, #12827, #14866, #30398, #31245.

What Should Happen?

On plan-mode entry mid-session, one of:

  1. Mint a fresh three-word-slug plan file per topic by default. Existing plans become read-only references; never auto-pinned for write.
  2. Prompt "resume X or start a new plan file?" when an existing plan is detected, instead of silently pinning it.
  3. Allow the agent to touch a new file in ~/.claude/plans/ from within plan mode. (Today the read-only restriction blocks even creating a fresh sibling, which is what makes the CLAUDE.md-rule workarounds dead-end — see SeanHollen's comment on #21131.)

Option (1) is the cleanest. Option (3) is the smallest behavioral change and would make existing user-side rule workarounds actually viable.

Steps to Reproduce

  1. Start a long-lived Claude Code session (CLI or claude-agent-sdk consumer).
  2. In that session, work on topic A long enough that the agent produces a plan file. Filename will be auto-slugged at ~/.claude/plans/<slug-A>.md.
  3. Continue the same session — pivot to an unrelated topic B (different concern, independent feature).
  4. Enter plan mode.
  5. Observe: the harness emits the system-reminder above pinning <slug-A>.md for write, even though the new task is unrelated.

Disproof of the "most-recent-mtime" theory (this matters — selection is not "pick the newest file in the directory"):

$ ls -la --time-style=long-iso ~/.claude/plans/ | grep -E "ullman|otter"
-rw-r--r-- 1 user user 18853 2026-04-21 13:35 enumerated-inventing-ullman.md   ← pinned
-rw-r--r-- 1 user user 18097 2026-04-21 14:29 sparkling-triaging-otter.md      ← newer, NOT pinned

The pinned file was not the newest in the directory. Selection appears to be per-session sticky — the harness remembers an assignment from earlier in the same session and re-pins it on every subsequent plan-mode entry, regardless of whether the new task relates.

Error Messages/Logs

A plan file already exists at /home/<user>/.claude/plans/<slug>.md.
You can read it and make incremental edits using the Edit tool.
this is the only file you are allowed to edit — other than this you
are only allowed to take READ-ONLY actions.

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

(unknown)

Claude Code Version

claude-agent-sdk (Python) 0.1.66. Not using the Claude Code CLI directly — host is a claude-agent-sdk consumer (Bearings, localhost web UI). The plan-mode harness behavior is shared between the SDK and the CLI; route to whichever team owns the harness.

Platform

Anthropic API

Operating System

Other Linux

Terminal/Shell

Non-interactive/CI environment

Additional Information

  • Confirmed not a host/wrapper bug. Reproduces in Bearings (a claude-agent-sdk consumer). grep across the host's source shows no file-selection logic, no system-reminder emission, and no plan-path wiring through the host's session/prompt layer — every reference to ~/.claude/plans/ in the host is a comment pointing at planning docs for traceability. The reminder originates in the plan-mode harness exposed by claude-agent-sdk / the CLI.
  • Adam Goyer's comment on #21131 describes a PostToolUse hook workaround that copies plans to a git-tracked location, but the in-mode pin still destroys the original. SeanHollen's comment on #21131 shows the deadlock cleanly: even with strong CLAUDE.md rules forbidding plan-file overwrite, the agent correctly refuses to write — but has no escape hatch to create a fresh file from within plan mode.
  • Current workaround: drop out of plan mode, hand off to a fresh session, replan there. Applicable in long-lived UIs like Bearings; standalone CLI users typically /clear or restart, which trades context for correctness.
  • Sibling bug (filing separately once reproduced): plan-mode dropdown picker behavior in the claude-agent-sdk flow appears to be wired up incorrectly — needs its own repro before filing.

extent analysis

TL;DR

The plan-mode harness in Claude Code should be updated to allow minting a fresh plan file or prompting the user to start a new plan file when an existing plan is detected.

Guidance

  • The issue is caused by the plan-mode harness silently pinning an existing plan file, preventing the creation of a new plan file for an unrelated topic.
  • To verify the issue, follow the steps to reproduce and observe the system-reminder pinning the existing plan file.
  • A potential workaround is to drop out of plan mode, start a fresh session, and replan, but this is not ideal as it trades context for correctness.
  • The claude-agent-sdk consumer, such as Bearings, can be used to reproduce the issue, confirming it's not a host/wrapper bug.

Example

No code snippet is provided as the issue is related to the plan-mode harness behavior, which is not explicitly shown in the issue body.

Notes

The issue is not a regression, and the last working version is unknown. The claude-agent-sdk version used is 0.1.66.

Recommendation

Apply a workaround, such as dropping out of plan mode and starting a fresh session, until a fix is available. This is because the current behavior is causing issues with plan file management, and a workaround is necessary to mitigate the problem.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [BUG] Plan mode pins a stale plan file across topic pivots in same session (refile of stale-closed #21131) [1 comments, 2 participants]