Skip to content

feat(plugin): single-session install + setup flow#175

Merged
onlycastle merged 6 commits intomainfrom
feat/plugin-single-session-setup-20260320
Mar 20, 2026
Merged

feat(plugin): single-session install + setup flow#175
onlycastle merged 6 commits intomainfrom
feat/plugin-single-session-setup-20260320

Conversation

@onlycastle
Copy link
Owner

Summary

  • Add homedir() fallback for CLAUDE_PLUGIN_DATA so native deps install works without the env var
  • New Step 0.5 in /bp-setup wizard: mid-session MCP server registration via claude mcp add
  • Declare skills and mcpServers fields in plugin.json manifest

Changes

  1. fix(plugin): fallback CLAUDE_PLUGIN_DATA to ~/.betterprompt
  2. feat(plugin): add mid-session MCP registration to setup wizard
  3. chore(plugin): add skills and mcpServers fields to plugin manifest
  4. docs(plugin): document single-session install flow

Test Plan

  • Install plugin fresh, run /bp-setup — verify Step 0.5 registers MCP server
  • Confirm scan_sessions tool works after mid-session registration
  • Verify existing installs (where MCP is already running) skip Step 0.5
  • Check native-deps.ts fallback: unset CLAUDE_PLUGIN_DATA, verify ~/.betterprompt is used

Generated with Claude Code using /ship-it

onlycastle and others added 4 commits March 20, 2026 00:49
When CLAUDE_PLUGIN_DATA env var is unset (e.g., mid-session MCP
registration), use homedir-based default so native dep installation
still works.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
New Step 0.5 in /bp-setup: detects if the MCP server is running and
registers it via `claude mcp add` if missing, enabling install-then-
setup in a single Claude Code session.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Declare skills directory and MCP server config paths in plugin.json
for proper plugin discovery.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add section explaining how Step 0.5 bridges the gap between plugin
install and MCP server availability within the same session.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@onlycastle
Copy link
Owner Author

Code Review

Found 3 issues:

  1. Dead guard after fallback additionif (!pluginDataDir) return; on line 17 can never trigger now that the fallback || join(homedir(), '.betterprompt') guarantees a truthy value. This guard was meaningful before the fallback but is now unreachable dead code. Consider removing it or replacing with an assertion.

    const pluginDataDir = process.env.CLAUDE_PLUGIN_DATA || join(homedir(), '.betterprompt');
    if (!pluginDataDir) return;

  2. Incomplete command in PLUGIN.md diagram — The "Single-Session Install Flow" shows claude mcp add -s user betterprompt as the full command, but it's missing the required -e NODE_PATH=... and -e CLAUDE_PLUGIN_DATA=... flags plus the -- node <path> suffix. A developer reading only PLUGIN.md would get a non-working command.

    install plugin → /bp-setup → Step 0.5: `claude mcp add -s user betterprompt` → MCP tools available → continue setup

  3. Dual MCP registration on subsequent sessions — Step 0.5 uses claude mcp add -s user which persists across all sessions. The plugin's .mcp.json also registers the same server on subsequent sessions via the plugin lifecycle. The docs state "on subsequent sessions, the plugin's .mcp.json handles server startup normally" but don't address whether this creates a duplicate registration or how they're reconciled.

    The `claude mcp add` command registers the server at user scope with `NODE_PATH` and `CLAUDE_PLUGIN_DATA` env vars pointing to `~/.betterprompt/`. On subsequent sessions, the plugin's `.mcp.json` handles server startup normally.

Generated with Claude Code

If useful, react with a thumbs-up. Otherwise, thumbs-down.

onlycastle and others added 2 commits March 20, 2026 07:05
The `if (!pluginDataDir) return` guard became dead code after adding
the `homedir()` fallback — the expression always produces a truthy
string.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Show the full `claude mcp add` invocation with -e flags in the
diagram, and note that Claude Code deduplicates by server name so
the user-scoped and plugin-managed entries don't conflict.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@onlycastle onlycastle merged commit d6890ec into main Mar 20, 2026
1 check passed
@onlycastle onlycastle deleted the feat/plugin-single-session-setup-20260320 branch March 20, 2026 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant