Skip to content

Instantly share code, notes, and snippets.

@lisaross
Created December 10, 2025 15:28
Show Gist options
  • Select an option

  • Save lisaross/f4d5185f88a4f0e043d55cebeb0297e7 to your computer and use it in GitHub Desktop.

Select an option

Save lisaross/f4d5185f88a4f0e043d55cebeb0297e7 to your computer and use it in GitHub Desktop.
Clean up stale plugin caches from removed marketplaces
description argument-hint
Clean up stale plugin caches from removed marketplaces
[--dry-run] [marketplace-name]

Plugin Cache Cleanup

Clean up stale plugin artifacts (commands, agents, skills) from marketplaces that have been removed.

User Request

{{arguments}}

Instructions

Analyze the plugin system state and clean up orphaned data:

Step 1: Discover State

Read these files to understand current state:

  • ~/.claude/plugins/known_marketplaces.json - Active marketplaces
  • ~/.claude/plugins/installed_plugins.json - Plugin registry v1
  • ~/.claude/plugins/installed_plugins_v2.json - Plugin registry v2

List directories in:

  • ~/.claude/plugins/cache/ - Cached plugin artifacts
  • ~/.claude/plugins/marketplaces/ - Downloaded marketplace repos

Step 2: Identify Orphans

Compare cache directories against known_marketplaces.json:

  • Any directory in cache/ NOT listed in known_marketplaces.json is orphaned
  • Any plugin in installed_plugins*.json with @marketplace suffix where marketplace is NOT in known_marketplaces.json is orphaned

Step 3: Report Findings

Present a summary:

Plugin Cache Analysis
=====================

Active Marketplaces:
- marketplace-name (last updated: date)

Orphaned Cache Directories:
- orphaned-marketplace/ (X plugins, Y MB)

Orphaned Plugin Entries:
- plugin-name@orphaned-marketplace
- another-plugin@orphaned-marketplace

Recommended Actions:
1. Remove cache directory: ~/.claude/plugins/cache/orphaned-marketplace/
2. Clean plugin entries from installed_plugins.json
3. Clean plugin entries from installed_plugins_v2.json

Step 4: Execute Cleanup (if not --dry-run)

If user did NOT specify --dry-run:

  1. Remove orphaned cache directories:

    rm -rf ~/.claude/plugins/cache/<orphaned-marketplace>/
  2. Update installed_plugins.json:

    • Read current content
    • Filter out plugins with @<orphaned-marketplace> suffix
    • Write updated content back
  3. Update installed_plugins_v2.json:

    • Read current content
    • Filter out plugins with @<orphaned-marketplace> suffix
    • Write updated content back
  4. Optionally remove orphaned marketplace repos:

    • Check ~/.claude/plugins/marketplaces/ for directories not in known_marketplaces.json
    • Remove if orphaned

Step 5: Provide Summary

After cleanup:

Cleanup Complete
================

Removed:
- Cache: ~/.claude/plugins/cache/orphaned-marketplace/ (X plugins)
- Plugin entries: Y entries removed from registries

Next Steps:
- Restart Claude Code to reload plugin registry
- Run `/plugin list` to verify cleanup

Argument Handling

  • --dry-run: Only show what WOULD be cleaned, don't actually delete
  • <marketplace-name>: Only clean specific marketplace (e.g., makably)
  • No arguments: Clean ALL orphaned marketplaces

Safety Notes

  • Always show what will be deleted before deleting
  • Preserve known_marketplaces.json (source of truth)
  • Only delete cache/registry entries, never marketplace configs
  • If in doubt, default to dry-run behavior
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment