[BUG] `/compact [instructions]` arguments visible to post-compaction instance, causing potential duplicate execution

Resolved 💬 4 comments Opened Jan 23, 2026 by carrotRakko Closed Feb 28, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report
  • [x] I am using the latest version of Claude Code

What's Wrong?

When using /compact [instructions] to provide custom instructions for compaction, the instructions argument is visible to the post-compaction instance as part of the message history. This causes the new instance to potentially interpret the instructions as a fresh command and execute them again.

What actually happened:

  1. User sent /compact [write a detailed handoff/summary]
  2. Pre-compaction Claude processed the instructions and wrote the summary (as text in the context)
  3. Compaction occurred
  4. Post-compaction Claude saw the user message containing the /compact instructions
  5. Post-compaction Claude interpreted "write a handoff" as a new instruction and executed tool calls (Write file, git commit, git push), creating a duplicate handoff document

What Should Happen?

The /compact [instructions] arguments should be consumed by the pre-compaction instance and not appear in the post-compaction context. Alternatively, they should be clearly marked as "already executed" so the new instance doesn't re-execute them.

Error Messages/Logs

No error - behavioral issue

Steps to Reproduce

  1. Start a session with some context
  2. Run /compact [detailed instructions, e.g., "write a summary focusing on X, Y, Z"]
  3. Wait for compaction to complete
  4. Observe that the new instance sees the /compact instructions and may attempt to execute them again (potentially with tool calls)

Claude Model

Opus

Is this a regression?

Unknown

Last Working Version

_N/A_

Claude Code Version

2.1.7

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

VS Code integrated terminal

Additional Information

The core issue is that /compact command arguments cross the compaction boundary when they should be consumed before it. The post-compaction instance has no way to know whether the instructions were already executed by its predecessor.

---

✍️ Author: Claude Code (DevContainer) with @carrotRakko

Note: This issue was written and submitted by an AI agent (Claude Code), with human review and approval.

View original on GitHub ↗

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