Plugin cache lost after CLI auto-update (local/third-party plugins not restored)
Bug Description
After Claude Code auto-updates (e.g., 2.1.90 → 2.1.110), the ~/.claude/plugins/cache/ directory is wiped. Plugins installed from local directory sources and third-party marketplaces are not automatically restored, causing all non-official plugins to silently disappear.
settings.json still contains the enabledPlugins and statusLine entries pointing to the now-deleted cache paths, so the user sees no error — features just stop working.
Steps to Reproduce
- Install plugins from a local directory marketplace source:
``json``
"extraKnownMarketplaces": {
"my-plugins": {
"source": { "source": "directory", "path": "/path/to/local/plugins" }
}
}
- Also install a third-party plugin not from an official marketplace (e.g.,
claude-statusline-hud) - Close Claude Code
- Reopen — CLI auto-updates to a new version
- All locally-sourced and third-party plugins are gone from
~/.claude/plugins/cache/
Expected Behavior
- Plugin cache should survive CLI upgrades
- If cache must be rebuilt, plugins should be automatically reinstalled from their registered sources in
installed_plugins.jsonandextraKnownMarketplaces - At minimum, the user should be notified that plugins were removed
Actual Behavior
~/.claude/plugins/cache/is cleared during upgradeinstalled_plugins.jsonentries become orphaned (point to non-existent paths)enabledPluginsinsettings.jsonstill references the missing plugins- No error or warning is shown — plugins silently stop working
statusLinecommand path breaks silently
Impact
In my case, 18+ plugins were lost, including:
- All local marketplace plugins (ai-review-reporter, browser-automator, slack-mcp, kusto-query, etc.)
claude-statusline-hud(third-party)memex(local directory source)claude-mem(GitHub source)
Root Cause Analysis
From reading the minified cli.js, the plugin autoupdate flow appears to delete the old cache entry before attempting reinstallation. If reinstallation fails (e.g., local directory source not accessible, network issues for GitHub sources), the cache is already gone with no rollback.
Suggested Fix
- Don't delete cache during CLI upgrade —
~/.claude/plugins/cache/is user data, not a disposable cache. CLI binary updates should not touch it.
- Backup-before-delete pattern in the plugin update function:
``javascript``
async function updatePlugin(name, scope) {
const oldPath = getCachePath(name, oldVersion);
const backupPath = oldPath + '.bak';
renameSync(oldPath, backupPath); // backup first
try {
const result = await installFromSource(name);
if (result.success) {
rmSync(backupPath, { recursive: true }); // success -> delete backup
} else {
renameSync(backupPath, oldPath); // fail -> restore
}
} catch (e) {
renameSync(backupPath, oldPath); // error -> restore
}
}
- Add a
claude plugins restorecommand that rebuilds cache frominstalled_plugins.json+ registered sources.
- Startup integrity check: on launch, compare
installed_plugins.jsonentries against actual cache contents. If mismatched, attempt re-install from source before giving up.
Environment
- OS: Windows 11 Enterprise
- Claude Code: upgraded from 2.1.90 → 2.1.110 (auto-update via winget)
- Install method: winget (
Anthropic.ClaudeCode) - Plugin sources: local directory, GitHub, third-party marketplace
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗