claude-code - 💡(How to fix) Fix Feature request: expose CLAUDE_PLUGIN_ROOT as shell env var in Bash tool context [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#48230Fetched 2026-04-15 06:29:31
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
0
Participants
Timeline (top)
labeled ×3

Fix Action

Fix / Workaround

Current Workaround

Code Example

uv run --directory "${CLAUDE_SKILL_DIR}/../.." python scripts/my_script.py args...

---

uv run --directory "$CLAUDE_PLUGIN_ROOT" python scripts/my_script.py args...

---

uv run --project "$CLAUDE_PLUGIN_ROOT" python "$CLAUDE_PLUGIN_ROOT/scripts/my_script.py" args...
RAW_BUFFERClick to expand / collapse

Problem

When plugins invoke scripts from SKILL.md via the Bash tool, the only way to locate the plugin root is to navigate relative to CLAUDE_SKILL_DIR:

uv run --directory "${CLAUDE_SKILL_DIR}/../.." python scripts/my_script.py args...

This is verbose, fragile (assumes skills are always exactly 2 levels deep), and repeated on every single command line in every skill. For a plugin like disciplined-agile-delivery with 30+ skills and 70+ script invocations, this boilerplate dominates the SKILL.md content.

CLAUDE_PLUGIN_ROOT already exists and is expanded in hooks.json and plugin.json config files, but it is not available as a shell environment variable when the Bash tool executes commands.

Proposed Solution

Inject CLAUDE_PLUGIN_ROOT as an environment variable in the Bash tool's execution context when running within a plugin skill. The variable should contain the absolute path to the plugin's installation directory (same value that's expanded in config files).

Impact

Every skill invocation becomes:

uv run --directory "$CLAUDE_PLUGIN_ROOT" python scripts/my_script.py args...

Or even simpler if combined with --project:

uv run --project "$CLAUDE_PLUGIN_ROOT" python "$CLAUDE_PLUGIN_ROOT/scripts/my_script.py" args...

Benefits:

  • No relative path gymnastics (../../)
  • No assumption about skill directory depth
  • Consistent with how CLAUDE_SKILL_DIR is already injected
  • Enables cleaner permission patterns (e.g., Bash(uv run --directory $CLAUDE_PLUGIN_ROOT *))

Current Workaround

Skills use ${CLAUDE_SKILL_DIR}/../.. which assumes the skill is at plugins/<name>/skills/<skill>/SKILL.md. This works but is ugly, repetitive, and breaks if the directory structure changes.

Environment

  • Claude Code CLI
  • uv 0.11.x for Python plugin dependency management
  • Affects any plugin with Python/Node scripts invoked from SKILL.md

extent analysis

TL;DR

Injecting CLAUDE_PLUGIN_ROOT as an environment variable in the Bash tool's execution context can simplify script invocations in SKILL.md files.

Guidance

  • Verify that CLAUDE_PLUGIN_ROOT is correctly expanded in hooks.json and plugin.json config files to ensure consistency.
  • Update the Bash tool to inject CLAUDE_PLUGIN_ROOT as an environment variable when running within a plugin skill, allowing for simpler script invocations like uv run --directory "$CLAUDE_PLUGIN_ROOT" python scripts/my_script.py args....
  • Test the updated Bash tool with various plugin structures to ensure the solution is robust and works as expected.
  • Consider combining the new environment variable with the --project option for even simpler invocations: uv run --project "$CLAUDE_PLUGIN_ROOT" python "$CLAUDE_PLUGIN_ROOT/scripts/my_script.py" args....

Example

# Before
uv run --directory "${CLAUDE_SKILL_DIR}/../.." python scripts/my_script.py args...

# After
uv run --directory "$CLAUDE_PLUGIN_ROOT" python scripts/my_script.py args...

Notes

The proposed solution assumes that the CLAUDE_PLUGIN_ROOT environment variable will be correctly set and expanded by the Bash tool. Additional testing may be necessary to ensure compatibility with different plugin directory structures and versions of the Claude Code CLI and uv.

Recommendation

Apply the workaround by injecting CLAUDE_PLUGIN_ROOT as an environment variable in the Bash tool's execution context, as it provides a more robust and flexible solution for script invocations in SKILL.md files.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING