Plugin cache: old versions never garbage collected on autoUpdate
Summary
When a plugin has autoUpdate: true in known_marketplaces.json, Claude Code downloads each new version into a fresh hash-named directory under ~/.claude/plugins/cache/<marketplace>/<plugin>/<hash>/, and updates installed_plugins.json to point to the new directory. However, the old version directories are never deleted, causing unbounded cache growth over time.
Reproduction
- Install a plugin from a marketplace with
autoUpdate: true - Let the plugin receive several updates over days/weeks
- Check the cache directory:
````
ls ~/.claude/plugins/cache/<marketplace>/<plugin>/
- Observe multiple hash directories, each a full copy of the repo
Impact observed
On a real user setup with the agent-deck plugin (~135 MB per version):
- 9 cached versions accumulated over ~3 months
- 1.2 GB of dead cache (only the latest version is referenced by
installed_plugins.json) - 301 stale
temp_git_*directories (~420 MB) also accumulated in the plugin cache root, which are temporary git clones from the download step that are never cleaned up
Total wasted disk: ~1.5 GB
This likely contributes to slower session startup as Claude Code scans the plugin cache directory to discover skills, hooks, and agents.
Expected behavior
After a successful plugin update:
- The old version directory should be removed from the cache once the new version is confirmed working
temp_git_*temporary directories should be cleaned up after successful installation
Additional context
- Affects all plugins with
autoUpdate: true, but most visible with larger repos - Manually deleting old cache directories during a live session causes breakage (Claude Code appears to hold in-memory references). Cleanup is only safe between sessions.
- A
claude plugins gccommand or automatic post-update cleanup would solve this
Environment
- Claude Code CLI (latest as of 2026-03-19)
- macOS (Apple Silicon)
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗