Skip to content

Slash commands fail: CLAUDE_PLUGIN_ROOT not available, fallback path incorrect #1357

@ApexLGF

Description

@ApexLGF

Bug Description

Slash commands like /sessions fail with MODULE_NOT_FOUND because the script require path falls back to ~/.claude/scripts/lib/ which doesn't exist.

Root Cause

The require pattern in slash command .md files:

require((process.env.CLAUDE_PLUGIN_ROOT || require('path').join(require('os').homedir(), '.claude')) + '/scripts/lib/session-manager')
  • CLAUDE_PLUGIN_ROOT is only injected by Claude Code's harness when executing hooks, not slash commands
  • The fallback path ~/.claude/scripts/lib/ doesn't exist — the actual scripts are at ~/.claude/plugins/marketplaces/everything-claude-code/scripts/lib/

Affected Commands

All slash commands using this pattern: /sessions (10 occurrences in sessions.md)

Contrast with Hooks

Hooks have proper multi-path fallback logic (added in v1.8.0 "SessionStart root fallback"):

for root in "${CLAUDE_PLUGIN_ROOT:-}" "$HOME/.claude/plugins/everything-claude-code" "$HOME/.claude/plugins/everything-claude-code@everything-claude-code" "$HOME/.claude/plugins/marketplace/everything-claude-code"; do ...

Slash commands don't have equivalent fallback.

Error

Error: Cannot find module '/Users/xxx/.claude/scripts/lib/session-manager'

Suggested Fix

Apply the same multi-path fallback logic to slash commands, or use a helper function that resolves the plugin root dynamically. For example:

function resolvePluginRoot() {
  const path = require('path');
  const fs = require('fs');
  const home = require('os').homedir();
  const candidates = [
    process.env.CLAUDE_PLUGIN_ROOT,
    path.join(home, '.claude/plugins/marketplaces/everything-claude-code'),
    path.join(home, '.claude/plugins/everything-claude-code'),
    path.join(home, '.claude/plugins/cache/everything-claude-code/everything-claude-code/1.8.0'),
  ].filter(Boolean);
  for (const root of candidates) {
    if (fs.existsSync(path.join(root, 'scripts/lib/session-manager.js'))) return root;
  }
  throw new Error('ECC plugin root not found');
}

Environment

  • Claude Code CLI
  • Plugin: everything-claude-code v1.8.0 (installed via marketplace)
  • OS: macOS

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