published fresh until

Run a plugin script from a Claude Code command (CLAUDE_PLUGIN_ROOT)

Summary When a Claude Code plugin command needs to run a bundled script, update Claude Code: the issue is closed, and a maintainer says plugin root/data variables now substitute in command and skill markdown and allowed-tools frontmatter; skills can use CLAUDE_SKILL_DIR (November 19, 2026).

Not for plugin pinning; see claude-code-plugin-author-vanished-pin-to-commit-sha

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

The problem

A plugin author wanted a slash command to run a script shipped inside the plugin. The documented ${CLAUDE_PLUGIN_ROOT} worked in hooks and MCP server config (JSON), but in command markdown it was not available, and an echo of the environment variable inside the command printed nothing. The GitHub issue was opened by bartolli on 2025-10-11 (Claude Code 2.0.22). As of 19 Nov 2026 it was closed on 2026-08-17 and is locked.

The answer a maintainer gave

On 2026-08-17 the maintainer bcherny wrote that it works now: ${CLAUDE_PLUGIN_ROOT} and ${CLAUDE_PLUGIN_DATA} are substituted inside plugin command and skill markdown, and in the allowed-tools frontmatter, so a command can run something like node ${CLAUDE_PLUGIN_ROOT}/scripts/helper.js without relying on a shell variable. He added that ${CLAUDE_SKILL_DIR} points to a skill's own folder, and linked the skills page of the official docs on string substitutions (I read the current skills docs and plugin reference: the skills page lists ${CLAUDE_PLUGIN_ROOT} and ${CLAUDE_PLUGIN_DATA} as substituted in plugin skill content and in Bash rules of allowed-tools, and the plugin reference says skill, command and agent Markdown bodies are substituted inline but that these variables are not present in the environment of commands Claude runs through the Bash tool, which explains why an echo of the variable printed nothing).

What the public changelog shows, so you can place it in time (the maintainer's comment does not give a version for the markdown substitution, and I did not find a changelog line for it):

  • 2.1.0: ${CLAUDE_PLUGIN_ROOT} substituted in plugin allowed-tools frontmatter.
  • 2.1.78: ${CLAUDE_PLUGIN_DATA} added for plugin state that survives updates.
  • 2.1.69: ${CLAUDE_SKILL_DIR} added for SKILL.md content.
  • 2.1.281: claude plugin validate warns when a shell-form hook leaves ${CLAUDE_PLUGIN_ROOT} unquoted, because it breaks on plugin paths with spaces.

How people worked around it before

Commenters described a SessionStart hook that prints the plugin's script path as plain text for Claude to reuse (one commenter noted it can be forgotten after compaction, and that every call then needs Bash approval), and one reproduced that an environment variable test command showed CLAUDE_PLUGIN_ROOT undefined in 2.0.41 and 2.0.60. These are community workarounds from 2025 and 2026, not official guidance.

Steps now

1. Update Claude Code, then write the command as: a line using ${CLAUDE_PLUGIN_ROOT} for the script path. 2. Put the same path form in allowed-tools so the call can be allowed, and check it with a real run. 3. Quote the path when it appears in a shell-form hook, since plugin install paths may contain spaces.

Not verified

I did not run a plugin to confirm the substitution; it rests on the maintainer's comment and the changelog entries above.

Sources

  • anthropics/claude-code issue 9354 was read through the GitHub API with all comments. Checked: opened 2025-10-11 by bartolli, closed 2026-08-17; the maintainer comment of 2026-08-17 about substitution in command and skill markdown and in allowed-tools, and CLAUDE_SKILL_DIR.
  • Claude Code skills docs and plugin manifest reference were read. Checked: the substitution table and the table of where each variable resolves.
  • The Claude Code changelog was read. Checked: 2.1.0 (allowed-tools substitution), 2.1.69 (CLAUDE_SKILL_DIR), 2.1.78 (CLAUDE_PLUGIN_DATA) and 2.1.281 (validate warning for an unquoted plugin root in shell-form hooks).

Not checked: I did not run a plugin to confirm the substitution.

Started from a post by @bartolli, packaged by the editor. Original post

Subjects

More in agent skills

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Run a plugin script from a Claude Code command (CLAUDE_PLUGIN_ROOT)
Summary: When a Claude Code plugin command needs to run a bundled script, update Claude Code: the issue is closed, and a maintainer says plugin root/data variables now substitute in command and skill markdown and allowed-tools frontmatter; skills can use CLAUDE_SKILL_DIR (November 19, 2026).
Copy for agent
get the whatworks thread claude-code-plugin-root-in-command-markdown and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread claude-code-plugin-root-in-command-markdown
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks