feat(install): add --skills-dir mode (Claude Code skills-directory plugin)#2
Open
mh0pe wants to merge 5 commits into
Open
feat(install): add --skills-dir mode (Claude Code skills-directory plugin)#2mh0pe wants to merge 5 commits into
mh0pe wants to merge 5 commits into
Conversation
Prefer CLAUDE_PROJECT_DIR when set and non-blank; fall back to the existing __dirname/HOOK_DIR relative resolution unchanged. Never throws on missing env var. Affected: src/packages/base-mcp/index.js and all six auto-register hooks (active, backlog, base-pulse-check, operator, satellite-detection, psmm-injector) plus apex-insights.py. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…lugin
Adds --skills-dir [--dir <path>] flag to bin/install.js (purely additive,
no existing flags changed). Installs a Claude Code skills-directory plugin
at <cwd>/.claude/skills/base/ by default (or --dir <path>). Creates
.claude-plugin/plugin.json, commands/, skills/, base-framework/ (with
hooks/ and packages/), hooks/ + hooks.json (UserPromptSubmit + SessionStart
wiring), and mcp/ + .mcp.json. All @~/.claude/base-framework/ and
@./.claude/base-framework/ refs in copied .md files are rewritten to
${CLAUDE_PLUGIN_ROOT}/base-framework/. Hook and MCP command paths use
${CLAUDE_PLUGIN_ROOT}. Prints load instructions on completion.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…R resolution for hooks and MCP
…E_PROJECT_DIR hooks, conflict guard)
- Finding 1 (HIGH): move .mcp.json write target from mcp/.mcp.json to
path.join(targetBase, '.mcp.json') so it lands at the plugin root.
The arg path \${CLAUDE_PLUGIN_ROOT}/mcp/base-mcp/index.js is unchanged.
- Finding 2 (HIGH): merge origin/feat/workspace-project-dir into this branch
so all 7 emitted hooks carry CLAUDE_PROJECT_DIR-first workspace resolution
(falls back to HOOK_DIR.parent.parent when env is unset). base-mcp/index.js
receives the same layered resolution. Plugin requires CLAUDE_PROJECT_DIR to
be set at runtime; Claude Code sets it automatically for plugin hooks.
This branch depends on feat/workspace-project-dir — note for PR description.
- Finding 3 (MEDIUM): add conflict guard — --skills-dir combined with --global
or --local prints an error and exits non-zero before installSkillsDir() runs.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Emit hooks/install-mcp-deps.py (SessionStart hook) that installs @modelcontextprotocol/sdk deps into CLAUDE_PLUGIN_DATA and symlinks PLUGIN_ROOT/mcp/base-mcp/node_modules -> PLUGIN_DATA/node_modules so Node ESM can resolve bare specifiers from the importing file's directory. NODE_PATH added to .mcp.json env (CJS fallback; Node ESM requires the symlink bridge since ESM does not honour NODE_PATH at import time). - Idempotent: skips install if sdk marker already present; re-asserts symlink - Fail-open: warns to stderr and exits 0 on any error (npm missing, env unset) - Keeps all 5 UserPromptSubmit hooks + satellite-detection SessionStart hook - Adds install-mcp-deps.py as second SessionStart hook entry - Script emitted inline (not in src/hooks/) so it stays scoped to skills-dir Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Author
|
Related PRs — part of a coordinated cross-repo offer (
Reviewing them together is recommended; the same change pattern is mirrored per repo. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
--skills-dir [--dir <path>]to the installer. It writes a self-contained skills-directory plugin that Claude Code auto-loads in place asbase@skills-dir:.claude-plugin/plugin.jsoncommands/,skills/,base-framework/hooks/(the 5 UserPromptSubmit hooks + satellite-detection SessionStart + a SessionStart MCP-deps bootstrapper) withhooks/hooks.json({hooks:{...}}envelope)mcp/base-mcp/+ a root.mcp.json@-includes rewritten to${CLAUDE_PLUGIN_ROOT}Default target:
<cwd>/.claude/skills/base/.Why
claude plugin install, no marketplace setup..claude/skills/but cannot see local marketplace installs; a committed skills-dir plugin is the supported way to ship a plugin to cloud.MCP bootstrapping
A skills-dir (or marketplace) plugin has no install step, so the base-mcp npm deps aren't present at launch and
node mcp/base-mcp/index.jswould fail withERR_MODULE_NOT_FOUND. The emitted plugin includes a fail-open SessionStart hook that idempotently installs the MCP deps into${CLAUDE_PLUGIN_DATA}and links them onto the MCP's module-resolution path (base-mcp is ESM, and Node's ESM loader ignoresNODE_PATH, so anode_modulessymlink is the operative mechanism;.mcp.jsonalso setsNODE_PATHas a harmless CJS fallback). The hook short-circuits when deps already exist and never blocks the session if npm or${CLAUDE_PLUGIN_DATA}is unavailable.Verified: after the SessionStart install, the MCP boots cleanly (
BASE MCP Server running on stdio, 21 tools) with noERR_MODULE_NOT_FOUND.First-session caveat: Claude Code may spawn the MCP concurrently with the SessionStart hook, so on a brand-new install the base-mcp becomes available from the next session (or after a restart) once deps are linked.
Relationship to the workspace-resolution PR
This branch includes the
CLAUDE_PROJECT_DIRworkspace-resolution fix offered standalone in the companion PR (the hooks needCLAUDE_PROJECT_DIR-aware resolution to work correctly in the.claude/skills/base/hooks/layout). If the workspace PR is merged first, the overlapping commits apply cleanly; recommend merging that one first.Notes
--workspacepaths are unchanged.--skills-dircannot be combined with--global/--local(errors out).@.base/...) are left untouched; only framework@-includes are rewritten. apex-insights is an on-demand command and is intentionally not event-wired.🤖 Generated with Claude Code