Skip to content

fix: register PostHog marketplace before Claude Code plugin install#479

Draft
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-code/claude-code-marketplace-add
Draft

fix: register PostHog marketplace before Claude Code plugin install#479
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-code/claude-code-marketplace-add

Conversation

@posthog
Copy link
Copy Markdown

@posthog posthog Bot commented May 26, 2026

Problem

ClaudeCodeMCPClient.installPlugin() (src/steps/add-mcp-server-to-clients/clients/claude-code.ts:143-159) calls claude plugin install posthog directly without ever registering the PostHog marketplace, so any user without the marketplace pre-configured gets Plugin "posthog" not found in any configured marketplace. Error Tracking shows ~1,977 occurrences of Claude Code plugin install failed across 842 distinct users over the last 90 days, with that variant dominant. A rarer variant (Marketplace configuration file is corrupted: local.source.source: Invalid input, 1 user) flows through the same path and gets captured as a generic wizard exception with no recovery hint.

The sibling Codex client (codex.ts:93-132) already registers the marketplace and even retries on a stale local cache; the Claude Code client skipped that step entirely.

Changes

  • claude-code.ts: installPlugin() now runs claude plugin marketplace add PostHog/ai-plugin via spawnSync before claude plugin install posthog, mirroring the Codex pattern. Stale-cache stderr (already added from a different source) triggers a one-shot retry that clears ~/.claude/plugins/marketplaces/posthog. already added / already exists stderr is treated as a no-op (continue to install).
  • claude-code.ts: corrupted-config stderr is detected and captured with a clearer message pointing the user at their local ~/.claude/plugins/ config instead of the generic Claude Code plugin install failed.
  • claude-code.test.ts: adds coverage for the marketplace-add step, the "already added" passthrough, the stale-cache retry, the corrupt-config branch, and a generic marketplace-add failure. Existing install-step branches kept intact.

Test plan

  • pnpm build
  • pnpm test -- claude-code — 15/15 pass
  • pnpm test — full suite passes (one provision-cli timeout was flaky under parallel load, passes in isolation and on main)
  • pnpm lint — 0 errors

Created with PostHog Code

`claude plugin install posthog` fails for users who haven't pre-registered
the PostHog marketplace — the dominant variant of the `Claude Code plugin
install failed` exception (Error Tracking: ~1,977 occurrences across 842
distinct users in 90 days). The sibling Codex client already runs
`marketplace add` first; mirror that here.

Also detect the rarer `Marketplace configuration file is corrupted` stderr
and surface a clearer message pointing at the user's local config so the
captured exception is actionable instead of generic. The stale-cache retry
mirrors the Codex pattern (clear `~/.claude/plugins/marketplaces/posthog`
and try once more).

Tests cover the new marketplace-add step, the stale-cache retry, the
corrupt-config branch, the "already added" passthrough, and the existing
install-step failure modes.

Generated-By: PostHog Code
Task-Id: c34c6418-2898-44cb-9459-60ddf9221364
@github-actions
Copy link
Copy Markdown

🧙 Wizard CI

Run the Wizard CI and test your changes against wizard-workbench example apps by replying with a GitHub comment using one of the following commands:

Test all apps:

  • /wizard-ci all

Test all apps in a directory:

  • /wizard-ci basic-integration
  • /wizard-ci misc
  • /wizard-ci revenue

Test an individual app:

  • /wizard-ci basic-integration/android
  • /wizard-ci basic-integration/angular
  • /wizard-ci basic-integration/astro
Show more apps
  • /wizard-ci basic-integration/django
  • /wizard-ci basic-integration/fastapi
  • /wizard-ci basic-integration/flask
  • /wizard-ci basic-integration/javascript-node
  • /wizard-ci basic-integration/javascript-web
  • /wizard-ci basic-integration/laravel
  • /wizard-ci basic-integration/next-js
  • /wizard-ci basic-integration/nuxt
  • /wizard-ci basic-integration/python
  • /wizard-ci basic-integration/rails
  • /wizard-ci basic-integration/react-native
  • /wizard-ci basic-integration/react-router
  • /wizard-ci basic-integration/sveltekit
  • /wizard-ci basic-integration/swift
  • /wizard-ci basic-integration/tanstack-router
  • /wizard-ci basic-integration/tanstack-start
  • /wizard-ci basic-integration/vue
  • /wizard-ci misc/quack-quack
  • /wizard-ci revenue/stripe

Results will be posted here when complete.

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.

0 participants