# Claude Code plugin gstack ships a Claude Code installer plugin so you can add gstack through Claude Code's `/plugin` command and install it from this repository's GitHub marketplace (`/plugin marketplace add garrytan/gstack`). ## Install On Claude Code 2.1.275 or later: ```bash /plugin install gstack --marketplace garrytan/gstack ``` On earlier Claude Code versions: ```bash /plugin marketplace add garrytan/gstack /plugin install gstack@gstack ``` Then run `/gstack:gstack-setup` inside Claude Code (or run the setup command the session-start notice prints) to clone gstack and build its compiled tools. Requirements for the plugin hook and `./setup`: Claude Code, Git (with Git Bash on `PATH` on Windows), and Bun v1.4.2+ (plus Node.js on Windows). See [docs/install.md](install.md) for platform notes and update channels. ## What the installer plugin does The repository root holds `.claude-plugin/marketplace.json`, which points at the self-contained plugin folder `plugins/gstack/`: | Path | Role | | --- | --- | | `.claude-plugin/marketplace.json` | Marketplace catalog read by `/plugin marketplace add garrytan/gstack`. Points `gstack` at `./plugins/gstack`. | | `plugins/gstack/.claude-plugin/plugin.json` | Plugin manifest (`name: "gstack"`, metadata, license). | | `plugins/gstack/hooks/hooks.json` | Registers the `SessionStart` hook command (`bash "${CLAUDE_PLUGIN_ROOT}/scripts/session-start.sh"`). | | `plugins/gstack/scripts/session-start.sh` | Fast, offline, fail-open check run on `SessionStart` events. Checks only an absolute user-scoped Claude skills directory (`${CLAUDE_CONFIG_DIR:-~/.claude}/skills/gstack`) for the compiled browser binary, `bin/gstack-skill-start`, linked Claude skills, and `bin/gstack-paths` (never scanning untrusted project repositories or relative paths); prints a shell-quoted one-step fix (with `unset CLAUDE_PLUGIN_ROOT CLAUDE_PLUGIN_DATA`) when missing and stays silent when ready. | | `plugins/gstack/commands/gstack-setup.md` | Defines `/gstack:gstack-setup`, which checks prerequisites, targets `${CLAUDE_CONFIG_DIR:-~/.claude}/skills/gstack` (never executing a repo-local `./setup` without explicit confirmation), clones `garrytan/gstack` if needed, runs `./setup`, and verifies with `gstack-paths --explain` and `gstack-doctor`. | | `plugins/gstack/README.md`, `LICENSE`, `assets/icon.png` | Plugin README, MIT license, and 512x512 square PNG icon for the plugin bundle. | ### Why state does not split under the plugin When Claude Code runs a hook for a plugin named `gstack`, it exports `CLAUDE_PLUGIN_ROOT` (containing `gstack`) and `CLAUDE_PLUGIN_DATA` (`~/.claude/plugins/data/gstack-...`). Left untouched, gstack's state-root chain would pick `CLAUDE_PLUGIN_DATA` inside plugin hooks while terminal runs and regular skills still use `~/.gstack` (or `GSTACK_HOME`). To prevent split state, both `plugins/gstack/scripts/session-start.sh` and every shell block in `plugins/gstack/commands/gstack-setup.md` run `unset CLAUDE_PLUGIN_ROOT CLAUDE_PLUGIN_DATA` before invoking gstack. That preserves your normal state-root precedence (`GSTACK_STATE_ROOT` -> `GSTACK_HOME` -> `GSTACK_STATE_DIR` -> `~/.gstack`) across plugin sessions and CLI runs. See [docs/state-root.md](state-root.md#claude-code-plugin-installs). ### Why the plugin lives in `plugins/gstack/` instead of the repository root Keeping `.claude-plugin/marketplace.json` at the repository root and the plugin bundle inside `plugins/gstack/` avoids four concrete failures of a repo-root `plugin.json`: 1. **Existing `~/.claude/skills/gstack/` installs stay untouched.** Claude Code treats any folder under `~/.claude/skills/` that contains `.claude-plugin/plugin.json` as a `@skills-dir` plugin. Putting `plugin.json` at the repository root would convert every existing git-clone install into a plugin automatically, colliding with marketplace installs and activating `CLAUDE_PLUGIN_DATA`. 2. **Strict validation passes.** `CLAUDE.md` lives at the repository root, and `claude plugin validate --strict` fails with a warning when a plugin root contains `CLAUDE.md`. 3. **Anthropic directory size and file rules pass.** Anthropic's directory stops validation if any file inside the plugin folder exceeds 5 MiB (`lib/diagram-render/dist/diagram-render.html` is 7.52 MiB), holds plugins with more than 512 files or a lockfile (`package.json` + `bun.lock` + `bunfig.toml`), and blocks claude.ai and Cowork installs for plugins with a top-level `bin/` directory. 4. **Small cache footprint.** Installing the plugin copies 7 files (about 165 KiB) instead of the entire 86 MiB repository. ## Native-plugin feasibility spike (Step 2 decision) **Verdict: Step 2 (serving all gstack skills directly from `CLAUDE_PLUGIN_ROOT` without `./setup`) stays deferred.** This spike audited `garrytan/gstack` (at commit `7f7b0f1`, referencing `TODOS.md` #526) against Claude Code v2.1.326 to test whether gstack's skills can run unchanged from `CLAUDE_PLUGIN_ROOT`. Six blockers prevent a native plugin today: 1. **Compiled binaries and runtime assets are not committed to git.** `scripts/build.sh` compiles five executables (`browse/dist/browse`, `browse/dist/find-browse`, `design/dist/design`, `make-pdf/dist/pdf`, `bin/gstack-global-discover`), vendors xterm assets into `extension/lib/`, builds the Node fallback server, and relies on Playwright Chromium. None of those outputs are tracked in git: 11 skills invoke `browse/dist/browse`, 5 invoke `design/dist/design`, 1 invokes `make-pdf/dist/pdf`, and 108 of 213 `bin/` helpers require Bun. Claude Code's automatic plugin dependency installer cannot replace `./setup`: it runs with `--ignore-scripts`, skips Bun lockfiles when `package.json` declares `patchedDependencies` (gstack patches `playwright-core@1.65.0`), and enforces a 60-second timeout. 2. **All 62 generated Claude `SKILL.md` files hardcode `~/.claude/skills/gstack`.** Because `hosts/claude.ts` sets `usesEnvVars: false`, all 62 generated Claude `SKILL.md` files (`SKILL.md` plus 61 sub-skills checked by `scripts/skill-check.ts`) contain 1,154 literal `~/.claude/skills/gstack/...` paths (plus 105 of 134 `*/sections/*.md` files), including 56 skills using `!` inline `gstack-skill-load` commands and 36 calling `gstack-paths`. Zero skills reference `CLAUDE_PLUGIN_ROOT` or `CLAUDE_SKILL_DIR`. 3. **Skill frontmatter hooks and `settings.json` hooks expect `~/.claude/skills/gstack`.** Five skills (`autoplan`, `careful`, `freeze`, `guard`, `plan-ceo-review`) define frontmatter hooks pointing at `$HOME/.claude/skills/gstack/...`, and `autoplan`'s `PreToolUse` publication hook fails closed when its script is absent. Twelve additional wrappers in `hosts/claude/hooks/` are registered by `./setup` in `~/.claude/settings.json` with per-hook opt-outs in `gstack-config`; moving them into a static plugin `hooks/hooks.json` would bypass per-hook opt-outs and double-fire alongside `./setup`. 4. **Forced plugin namespacing breaks unprefixed slash commands.** Claude Code namespaces every plugin skill under `/gstack:` (for example `/gstack:office-hours`, `/gstack:review`), while gstack's cross-skill routing, templates, and documentation invoke unprefixed `/office-hours`, `/review`, `/qa`, and `/gstack-ship`. 5. **Repo-root packaging fails strict and directory validation.** Verified empirically with `@anthropic-ai/claude-code@2.1.326`: root `CLAUDE.md` fails `claude plugin validate --strict`, `lib/diagram-render/dist/diagram-render.html` (7.52 MiB) trips the directory's 5 MiB per-file limit, top-level `bin/` blocks claude.ai/Cowork, and root `plugin.json` collides with existing `~/.claude/skills/gstack/` checkouts. 6. **Cross-environment state-root bridging is still deferred.** Running full skills natively inside `CLAUDE_PLUGIN_ROOT` without the deferred cross-environment pointer (`TODOS.md`) would split `CLAUDE_PLUGIN_DATA` from `~/.gstack`. **What would reopen Step 2:** a Claude Code post-install build hook or prebuilt platform binaries for gstack's tools; a `CLAUDE_PLUGIN_ROOT`-aware render target in `hosts/claude.ts` covering generated skill bodies and frontmatter hooks; an isolated plugin build output free of `CLAUDE.md`, top-level `bin/`, lockfiles, and files over 5 MiB; and a plan for `/gstack:` namespacing plus cross-environment state resolution. ## Validation Validate both the marketplace and the plugin bundle locally with Claude Code: ```bash claude plugin validate --strict . claude plugin validate --strict --profile directory ./plugins/gstack ``` The repository also runs deterministic schema, hook, state-root pinning, and directory pre-submission checks in CI via `test/claude-plugin.test.ts`. Whenever files under `plugins/gstack/` change after initial publication, bump `version` in `plugins/gstack/.claude-plugin/plugin.json` so Claude Code invalidates cached plugin installs. ## Why GitHub marketplace instead of Anthropic's hosted directory gstack's installer plugin ships a `SessionStart` hook (`plugins/gstack/hooks/hooks.json` and `plugins/gstack/scripts/session-start.sh`) so Claude Code can verify `~/.claude/skills/gstack` at session start and print the exact setup fix when anything is missing. Anthropic's hosted plugin directory currently blocks local hooks and shell scripts in community submissions, so gstack is distributed straight from this repository's GitHub marketplace instead. Install it from GitHub with `/plugin marketplace add garrytan/gstack` and `/plugin install gstack@gstack` (or `/plugin install gstack --marketplace garrytan/gstack` on Claude Code 2.1.275 or later).