Skip to content

Migrate config + caches to $CLAUDE_PLUGIN_DATA (~/.claude/plugins/data/) per official plugin spec #519

@qhuang20

Description

@qhuang20

Hi! Love the plugin — using it daily.

Noticed claude-hud currently writes its runtime data directly under ~/.claude/plugins/claude-hud/:

  • config.json
  • config-cache/
  • transcript-cache/

The official Claude Code Plugins reference introduces a standardized location:

Persistent data directory
The ${CLAUDE_PLUGIN_DATA} directory resolves to ~/.claude/plugins/data/{id}/, where {id} is the plugin identifier with characters outside a-z, A-Z, 0-9, _, - replaced by -. For a plugin installed as formatter@my-marketplace, the directory is ~/.claude/plugins/data/formatter-my-marketplace/.

For claude-hud that would be ~/.claude/plugins/data/claude-hud-claude-hud/, and the env var $CLAUDE_PLUGIN_DATA is auto-injected so the plugin doesn't need to hardcode it.

Benefits of migrating:

  • Auto-cleanup on uninstall (with --keep-data opt-out)
  • Counted in /plugin UI's data-size display
  • Future-proof against any auto-cleanup of unknown top-level dirs in ~/.claude/plugins/
  • Plays nicely with multi-account setups via CLAUDE_CONFIG_DIR (related: Support CLAUDE_CONFIG_DIR for multi-account setups #274)

Suggested migration path (one-time, in startup code):

const dataDir = process.env.CLAUDE_PLUGIN_DATA
  ?? path.join(os.homedir(), '.claude/plugins/claude-hud');  // fallback

// On first run after upgrade, if old path exists and new one doesn't, move it:
const oldPath = path.join(os.homedir(), '.claude/plugins/claude-hud');
if (fs.existsSync(oldPath) && !fs.existsSync(dataDir) && oldPath !== dataDir) {
  fs.renameSync(oldPath, dataDir);
}

Happy to send a PR if you'd like.

Thanks!

@qhuang20

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions