claude-code - 💡(How to fix) Fix Slash commands (/exit, /clear, /status) should not appear in model context window on session resume

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…
RAW_BUFFERClick to expand / collapse

Problem

When resuming a session with --resume, all slash commands from previous sessions appear in the context window. These commands carry no semantic value for the model but consume tokens and clutter the conversation history.

Screenshot from a real session after resume:

<img width="1282" height="623" alt="Image" src="https://github.com/user-attachments/assets/056a1622-1801-4ef3-88c0-02e1627525e8" />

/clear → (no content)
/exit → See ya!

This becomes especially noticeable in multi-session workflows — for example, when exploring different directions on a project by forking sessions (opening multiple sessions from the same base). Switching between sessions means accumulating many /exit, /clear, and similar commands in the resumed context, none of which are useful to the model.

Proposed solution

Two complementary changes:

  1. At write time — don't record pure slash commands (/exit, /clear, /status, /help, etc.) to JSONL session history at all
  2. At load time — filter them out during --resume for backward compatibility with already-saved sessions

Together these keep the context clean without requiring any flags from the user.

Alternative

A --resume --clean flag that filters slash commands on demand, preserving current behavior as the default.

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 Slash commands (/exit, /clear, /status) should not appear in model context window on session resume