Skip to content

[BUG] Fix ${CLAUDE_PLUGIN_ROOT} in command markdown OR support local project plugin installation #9354

@bartolli

Description

@bartolli

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

Currently, the ${CLAUDE_PLUGIN_ROOT} environment variable, which is documented as the way for plugins to reference their own files, only works in JSON configurations (hooks, MCP servers) but not in command markdown files. This makes it impossible for /plugin commands to execute bundled scripts.

What Should Happen?

Support local plugin installation
/plugin install my-plugin@marketplace --local

  • Install to .claude/plugins/ in the project directory
  • Commands can use project-relative paths: node .claude/plugins/codanna-plugin/scripts/helper.js
  • Consistent with existing .claude/commands/ and .claude/agents/ patterns

Error Messages/Logs

 ▐▛███▜▌   Claude Code v2.0.22
▝▜█████▛▘  Sonnet 4.5 · Claude Max
  ▘▘ ▝▝    /Users/bartolli/Projects/codanna

> /test is running… 
  ⎿  Allowed 1 tools for this command

⏺ I'll execute the command to check the CLAUDE_PLUGIN_ROOT environment variable and run the requested command.

⏺ Bash(echo "CLAUDE_PLUGIN_ROOT=$CLAUDE_PLUGIN_ROOT")
  ⎿  CLAUDE_PLUGIN_ROOT=

⏺ The CLAUDE_PLUGIN_ROOT environment variable is not set (empty/undefined).

  Since the variable is undefined, I cannot execute the command:
  node ${CLAUDE_PLUGIN_ROOT}/scripts/context-provider.js find "Exit codes" --limit=1

  This would expand to:
  node /scripts/context-provider.js find "Exit codes" --limit=1

  Which would fail because there's no valid path.

  The value of CLAUDE_PLUGIN_ROOT is: undefined/empty

  node:internal/modules/cjs/loader:1386
    throw err;
    ^

  Error: Cannot find module '/scripts/context-provider.js'
      at Function._resolveFilename (node:internal/modules/cjs/loader:1383:15)
      at defaultResolveImpl (node:internal/modules/cjs/loader:1025:19)
      at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1030:22)
      at Function._load (node:internal/modules/cjs/loader:1192:37)
      at TracingChannel.traceSync (node:diagnostics_channel:322:14)
      at wrapModuleLoad (node:internal/modules/cjs/loader:237:24)
      at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:171:5)
      at node:internal/main/run_main_module:36:49 {
    code: 'MODULE_NOT_FOUND',
    requireStack: []
  }

  Node.js v22.20.0

Steps to Reproduce

Custom command installed via /plugin

description: Analyze code

Execute: node ${CLAUDE_PLUGIN_ROOT}/scripts/analyzer.js

Results in:
Error: Cannot find module '/scripts/analyzer.js'

Because ${CLAUDE_PLUGIN_ROOT} expands to nothing, making it impossible for plugin commands to run bundled scripts that analyze project files, parse JSON, call APIs, or any other programmatic task.

Claude Model

None

Is this a regression?

No, this never worked

Last Working Version

No response

Claude Code Version

2.0.14

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

Many plugins need helper scripts for:

  • Complex data processing (JSON parsing, formatting)
  • API integrations
  • Code analysis tools
  • Build system integrations

Without this fix, plugin commands are limited to simple prompt engineering without any computational capabilities.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:corebugSomething isn't workingenhancementNew feature or requesthas reproHas detailed reproduction stepsplatform:macosIssue specifically occurs on macOS

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions