[BUG] Infinitely repeated large <system-reminder> messages in Claude Code CLI in -p (headless) mode

Resolved 💬 8 comments Opened Feb 22, 2026 by designbyian Closed Mar 31, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

Summary: After user edits OR edits by claude code itself, <system-reminder> messages are attached to ALL subsequent user messages. These reminders include a block of lines from the file surrounding each edit. For significant edits this can be a large chunk of the file, injected on every turn. These messages compound with each new file edit and very quickly consume the session context window during any edit heavy session.

More details about the behavior of this bug can be found in the following report (from months ago) about the same issue in the Claude Code for VS Code extension. It appears to be an identical bug, there have been numerous reports from different users:
https://github.com/anthropics/claude-code/issues/16021

More details:

  • Having claude code re-read the file usually clears the notifications. The only other way to stop them is to start a new session
  • In some cases 2 reads are required to clear the <system-reminder> for a particular file. This is the weirdest part and seems to have been introduced more recently.

What Should Happen?

The harness should only inject file edit reminders once and it should not inject them for claude code's own edits.

Error Messages/Logs

Steps to Reproduce

The bug happens nearly every time, early on there was a session I wasn't able to reproduce it in, but generally speaking it happens consistently if you just:

  • Start a session in headless mode
  • Request some file edits in the same session
  • Observe <system-reminder> messages that are attached to your subsequent messages in the same session

Claude Model

None

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.50

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

PowerShell

Additional Information

Bear in mind that this bug also happens in the VS Code extension on Windows (as of the latest version) but it does not happen in claude code CLI in interactive mode, only in headless mode.

View original on GitHub ↗

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