[BUG] Claude Code Context Bloat: Bug Report + Community Issue Tracker
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?
Workaround Script (for other affected users)
# Clean stale plugin cache versions
python3 << 'EOF'
import json, os, shutil
with open(os.path.expanduser("~/.claude/plugins/installed_plugins.json")) as f:
data = json.load(f)
cache = os.path.expanduser("~/.claude/plugins/cache/claude-plugins-official")
for full_name, installs in data["plugins"].items():
plugin = full_name.split("@")[0]
active = installs[0]["version"]
plugin_dir = os.path.join(cache, plugin)
if os.path.isdir(plugin_dir):
for ver in os.listdir(plugin_dir):
path = os.path.join(plugin_dir, ver)
if os.path.isdir(path) and ver != active:
print(f"Removing stale: {plugin}/{ver}")
shutil.rmtree(path)
EOF
# Check for stale versions (verification)
for d in ~/.claude/plugins/cache/claude-plugins-official/*/; do
name=$(basename "$d")
count=$(ls -d "$d"*/ 2>/dev/null | wc -l)
if [ "$count" -gt 1 ]; then
echo "STALE: $name has $count versions (should be 1)"
fi
done
---
Community Issue Tracker
Category 1: Skill/Plugin Duplication (THE BUG I HIT)
| # | Title | Status | Author | Date | Platform | Notes |
|---|-------|--------|--------|------|----------|-------|
| #27721 | Skills from plugins registered twice in system prompt, doubling context usage | OPEN | @trumpyla | Feb 22 | All | ROOT ISSUE — no Anthropic response, no assignee |
| #29520 | Plugin skills duplicated in /context report and system prompt | Open (dup) | @dave-tedder | Feb 28 | macOS | Assigned to @dicksontsai, confirmed single cache dir rules out multi-dir scanning |
| #29675 | Plugin skills appear twice in system prompt skill list | Open (dup) | @JeffPGray | Feb 28 | macOS | 37 unique skills → 74 entries. Verified: no config duplication |
| #25994 | Skills loaded twice after context compaction (111 instead of ~63) | Closed (dup) | @nachmanmetodi | Feb 16 | Windows/VSCode | Debug log proves: "Sending 111 skills (63 total sent)" |
| #24334 | Windows: duplicate context injection — CLAUDE.md and skills loaded twice | Closed (dup) | @Sebastilan | Feb 9 | Windows | Case-insensitive path dedup failure (C: vs c:) |
| #15835 | Skill prompt rendered twice during Skill tool definition building | Closed (not planned) | @pproenca | Dec 30 | macOS | Debug log shows 22 renders for 11 skills at identical timestamp |
| #20391 | /context command output renders twice | OPEN (stale) | @carrotRakko | Jan 23 | Linux | Multiple users confirmed. No Anthropic response. |
Pattern: This bug has been reported at least 7 times across 4 months, on 3 platforms (macOS, Windows, Linux). The root issue (#27721) has no assignee and no Anthropic response after 6 days. #29520 is the only one with an assignee (@dicksontsai).
Category 2: CLAUDE.md Re-injection
| # | Title | Status | Author | Date | Notes |
|---|-------|--------|--------|------|-------|
| #27814 | Project CLAUDE.md re-injected as system-reminder on every tool call | Closed (dup of #21214) | @dkeesey | Feb 23 | O(N) context growth: 50 tool calls × 10KB = 500KB wasted |
Impact: CLAUDE.md content accumulates with every tool call instead of being injected once. Users forced to keep CLAUDE.md artificially small (<5KB) to limit blast radius.
Category 3: MCP Tool Context Overhead
| # | Title | Status | Author | Date | Notes |
|---|-------|--------|--------|------|-------|
| #20412 | Claude.ai MCP servers auto-injected without opt-in — causes OOM crashes | OPEN | @MattStarfield | Jan 23 | 6 remote servers silently synced from claude.ai web account. Can't be removed via CLI. Causes OOM kills on RPi 5. |
| #21966 | Show deferred MCP tools overhead in /context command | OPEN (stale) | @dustinbyershax | Jan 30 | /context shows 13% used but /doctor warns about ~40K tokens of hidden MCP overhead |
| #12241 | Large MCP tools context warning — excessive context usage | Closed (not planned) | @t34wrj | Nov 24 | Docker MCP alone consumed 125K tokens. Regression — worked the previous week. |
| #28660 | Skill injection is O(n) per tool call — unusable at 100+ skills | OPEN | @grahama1970 | Feb 25 | 160 skills = ~25K tokens injected per tool call = ~1.25M wasted per session |
Pattern: MCP tools are loaded unconditionally regardless of project relevance, cannot be scoped per-project, and their context cost is hidden from users. Cloud-synced MCP servers are injected without consent and can't be removed.
Category 4: Premature Compaction
| # | Title | Status | Author | Date | Notes |
|---|-------|--------|--------|------|-------|
| #15377 | Conversations compacting prematurely at ~65% token capacity | Closed (not planned) | @rubenheymans | Dec 25 | Root cause: corrupted ~/.claude.json + excessive MCP context (~246K tokens). User had to manually reduce to ~56K. |
| #27757 | Sandbox mode generates ~607K token system prompt | OPEN | @jdoss | Feb 22 | 33 deny rules explode system prompt to 607K tokens (3x the 200K limit) |
---
The Systemic Pattern
These 15 issues aren't independent bugs — they're symptoms of missing context lifecycle management:
- No deduplication — skills, CLAUDE.md, and tool definitions are injected multiple times without checking if they're already present
- No cleanup — stale plugin versions, accumulated permissions, and orphaned cache directories persist indefinitely
- No scoping — all plugins, MCP servers, and connectors load in every project regardless of relevance
- No visibility — context overhead is hidden from users; /context underreports actual usage
- No budget management — there's no cap on how much context can be consumed by system overhead vs. user content
The result: users pay (in money, time, and session quality) for context that provides zero value.
---
Asks
For Anthropic Engineering
- Fix the stale plugin cache cleanup — when a plugin updates, delete the old version directory. This is the simplest fix with immediate impact.
- Deduplicate skill injection — only inject each skill once, regardless of how many cache directories or subagents exist.
- Scope MCP tools per-project — let users specify which MCP servers are active for which projects, rather than loading all 92 tools everywhere.
- Make /context honest — show the actual context cost of deferred MCP tools, injected skills, and CLAUDE.md re-injections.
- Add a context budget for system overhead — cap how many tokens can be consumed by non-conversation content.
For Anthropic Support
- Credit for wasted context — users affected by skill duplication and unconditional MCP loading have been paying for tokens that delivered zero value. The duplication bug alone wastes ~3,000-5,000 tokens per session, compounding across every session since the auto-update.
---
Related Issues Index
For easy cross-referencing by support:
- Root issue (skills duplication): #27721
- Duplicates of #27721: #29520, #29675, #25994, #24334, #15835
- CLAUDE.md re-injection: #27814 (dup of #21214)
- MCP auto-injection: #20412
- MCP context hidden: #21966
- MCP context explosion: #12241
- Skill injection O(n): #28660
- Premature compaction: #15377
- Sandbox prompt explosion: #27757
- /context renders twice: #20391
What Should Happen?
Workaround Script (for other affected users)
# Clean stale plugin cache versions
python3 << 'EOF'
import json, os, shutil
with open(os.path.expanduser("~/.claude/plugins/installed_plugins.json")) as f:
data = json.load(f)
cache = os.path.expanduser("~/.claude/plugins/cache/claude-plugins-official")
for full_name, installs in data["plugins"].items():
plugin = full_name.split("@")[0]
active = installs[0]["version"]
plugin_dir = os.path.join(cache, plugin)
if os.path.isdir(plugin_dir):
for ver in os.listdir(plugin_dir):
path = os.path.join(plugin_dir, ver)
if os.path.isdir(path) and ver != active:
print(f"Removing stale: {plugin}/{ver}")
shutil.rmtree(path)
EOF
# Check for stale versions (verification)
for d in ~/.claude/plugins/cache/claude-plugins-official/*/; do
name=$(basename "$d")
count=$(ls -d "$d"*/ 2>/dev/null | wc -l)
if [ "$count" -gt 1 ]; then
echo "STALE: $name has $count versions (should be 1)"
fi
done
Error Messages/Logs
NONE the end user is blind to this issue occuring.
Steps to Reproduce
Check if you're affected (30 seconds)
Check 1: Stale plugin versions
for d in ~/.claude/plugins/cache/claude-plugins-official/*/; do
name=$(basename "$d")
count=$(ls -d "$d"*/ 2>/dev/null | wc -l)
if [ "$count" -gt 1 ]; then
echo "AFFECTED: $name has $count versions (should be 1)"
ls -d "$d"*/
fi
done
Check 2: Duplicate symlinks
ls -la ~/.claude/skills/ 2>/dev/null | grep -c "plugins/"
# If this returns a number > 0, you have symlink duplicates
Check 3: From inside a session — run /context and look at the Skills table. If every skill appears twice, you're hit.
Fix it
Fix stale versions:
python3 << 'EOF'
import json, os, shutil
with open(os.path.expanduser("~/.claude/plugins/installed_plugins.json")) as f:
data = json.load(f)
cache = os.path.expanduser("~/.claude/plugins/cache/claude-plugins-official")
for full_name, installs in data["plugins"].items():
plugin = full_name.split("@")[0]
active = installs[0]["version"]
plugin_dir = os.path.join(cache, plugin)
if os.path.isdir(plugin_dir):
for ver in os.listdir(plugin_dir):
path = os.path.join(plugin_dir, ver)
if os.path.isdir(path) and ver != active:
print(f"Removing stale: {plugin}/{ver}")
shutil.rmtree(path)
EOF
Fix duplicate symlinks:
# Remove symlinks in skills/ that point to plugins/ (the plugin registry handles discovery)
find ~/.claude/skills/ -type l -lname "*/plugins/*" -delete 2>/dev/null
Restart Claude Code after running these.
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
Claude Code Version: 2.1.58
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 6 comments on GitHub. Read the full discussion on GitHub ↗