claude-code - 💡(How to fix) Fix [BUG] "Clear Context" No longer removes old context fully [2 comments, 3 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#57862Fetched 2026-05-11 03:23:25
View on GitHub
Comments
2
Participants
3
Timeline
7
Reactions
0
Author
Timeline (top)
labeled ×4commented ×2cross-referenced ×1

Error Message

Error Messages/Logs

RAW_BUFFERClick to expand / collapse

Preflight Checklist

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

What's Wrong?

I executed a /clear command immediately preceding a query regarding an issue (as I've done numerous times before), and despite the clear, was at nearly 80% context usage nearly immediately. When I asked Claude about why I would be suddenly at such a high level, the response is below - of which I would have expected points 2 & 3 to have not been included (ie the insight report and the associated plan): A few things stacked up even after the clear:

System prompt is never cleared — CLAUDE.md plus the three @-referenced docs (collaboration.md, architecture.md, dev-standards.md) are injected on every turn. They're substantial.

The /insights skill output was carried forward — the system-reminder marked it as "skill invoked earlier in this session" and re-injected a large JSON payload into this conversation even though you had cleared. That alone was probably several thousand tokens.

The previous plan file content — plan mode injected the old plan (the long one covering items #1 and #38) via system-reminder at the start of the turn.

The Explore agent response was verbose — it returned full file contents for five files in one block.

Multiple file reads — dependencies.py, invoices.py, auth.py, test_pdf_endpoint.py all read into context in addition to the agent output.

The /clear clears your conversation history but the runtime continues re-injecting system-level context (CLAUDE.md, memory, skill state, active plan) on every turn. The practical fix for future sessions: after finishing a large workflow like the BACKLOG run, start a genuinely fresh session rather than clearing mid-session, which avoids the carried-over skill/plan reminders.

What Should Happen?

Clear should reset the context instead of maintaining old context (that's what compact is for).

Error Messages/Logs

Steps to Reproduce

  1. run /insights
  2. run following to generate BACKLOG.md: Spawn 6 parallel audit subagents over my repo, each with a single focus: (1) tenant_id isolation correctness, (2) circuit breaker and decorator ordering across the codebase, (3) test coverage gaps in service layer, (4) DB migration safety, (5) frontend/backend contract drift, (6) dead code and unused exports. Each agent writes findings to audits/<name>.md with severity, file:line refs, and a suggested fix. Then a synthesis agent merges them into BACKLOG.md ranked by risk × effort, with auto-drafted implementation prompts I can paste back to you.
  3. have Claude Code address the issues one at a time from the BACKLOG.md (mine was ~46 items)
  4. manually compact along the way
  5. once finished run clear
  6. ask Claude to investigate an issue, see the context is not actually reset

Claude Model

Sonnet (default)

Is this a regression?

Yes, this worked in a previous version

Last Working Version

No response

Claude Code Version

2.1.78

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

VS Code integrated terminal

Additional Information

No response

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] "Clear Context" No longer removes old context fully [2 comments, 3 participants]