diff --git a/AGENTS.md b/AGENTS.md index d87217453..b7df6098c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -15,6 +15,7 @@ Skills live in `.agents/skills/`. Invoke them by name (e.g., `/office-hours`). | `/plan-eng-review` | Lock architecture, data flow, edge cases, and tests. | | `/plan-design-review` | Rate each design dimension 0-10, explain what a 10 looks like. | | `/design-consultation` | Build a complete design system from scratch. | +| `/find-skills` | Query the external Agent Skills / skills.sh marketplace for vendor/framework-specific skills. | | `/review` | Pre-landing PR review. Finds bugs that pass CI but break in prod. | | `/debug` | Systematic root-cause debugging. No fixes without investigation. | | `/design-review` | Design audit + fix loop with atomic commits. | diff --git a/CLAUDE.md b/CLAUDE.md index 5c0389c1f..65a90c49f 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -75,6 +75,7 @@ gstack/ ├── benchmark/ # /benchmark skill (performance regression detection) ├── canary/ # /canary skill (post-deploy monitoring loop) ├── codex/ # /codex skill (multi-AI second opinion via OpenAI Codex CLI) +├── find-skills/ # /find-skills skill (external marketplace search for Agent Skills / skills.sh) ├── land-and-deploy/ # /land-and-deploy skill (merge → deploy → canary verify) ├── office-hours/ # /office-hours skill (YC Office Hours — startup diagnostic + builder brainstorm) ├── investigate/ # /investigate skill (systematic root-cause debugging) diff --git a/README.md b/README.md index 253d54252..25cfbacaa 100644 --- a/README.md +++ b/README.md @@ -46,11 +46,11 @@ Fork it. Improve it. Make it yours. And if you want to hate on free open source Open Claude Code and paste this. Claude does the rest. -> Install gstack: run **`git clone https://github.com/garrytan/gstack.git ~/.claude/skills/gstack && cd ~/.claude/skills/gstack && ./setup`** then add a "gstack" section to CLAUDE.md that says to use the /browse skill from gstack for all web browsing, never use mcp\_\_claude-in-chrome\_\_\* tools, and lists the available skills: /office-hours, /plan-ceo-review, /plan-eng-review, /plan-design-review, /design-consultation, /review, /ship, /land-and-deploy, /canary, /benchmark, /browse, /qa, /qa-only, /design-review, /setup-browser-cookies, /setup-deploy, /retro, /investigate, /document-release, /codex, /cso, /autoplan, /careful, /freeze, /guard, /unfreeze, /gstack-upgrade. Then ask the user if they also want to add gstack to the current project so teammates get it. +> Install gstack: run **`git clone https://github.com/garrytan/gstack.git ~/.claude/skills/gstack && cd ~/.claude/skills/gstack && ./setup`** then add a "gstack" section to CLAUDE.md that says to use the /browse skill from gstack for all web browsing, never use mcp\_\_claude-in-chrome\_\_\* tools, and lists the available skills: /office-hours, /plan-ceo-review, /plan-eng-review, /plan-design-review, /design-consultation, /find-skills, /review, /ship, /land-and-deploy, /canary, /benchmark, /browse, /qa, /qa-only, /design-review, /setup-browser-cookies, /setup-deploy, /retro, /investigate, /document-release, /codex, /cso, /autoplan, /careful, /freeze, /guard, /unfreeze, /gstack-upgrade. Then ask the user if they also want to add gstack to the current project so teammates get it. ### Step 2: Add to your repo so teammates get it (optional) -> Add gstack to this project: run **`cp -Rf ~/.claude/skills/gstack .claude/skills/gstack && rm -rf .claude/skills/gstack/.git && cd .claude/skills/gstack && ./setup`** then add a "gstack" section to this project's CLAUDE.md that says to use the /browse skill from gstack for all web browsing, never use mcp\_\_claude-in-chrome\_\_\* tools, lists the available skills: /office-hours, /plan-ceo-review, /plan-eng-review, /plan-design-review, /design-consultation, /review, /ship, /land-and-deploy, /canary, /benchmark, /browse, /qa, /qa-only, /design-review, /setup-browser-cookies, /setup-deploy, /retro, /investigate, /document-release, /codex, /cso, /careful, /freeze, /guard, /unfreeze, /gstack-upgrade, and tells Claude that if gstack skills aren't working, run `cd .claude/skills/gstack && ./setup` to build the binary and register skills. +> Add gstack to this project: run **`cp -Rf ~/.claude/skills/gstack .claude/skills/gstack && rm -rf .claude/skills/gstack/.git && cd .claude/skills/gstack && ./setup`** then add a "gstack" section to this project's CLAUDE.md that says to use the /browse skill from gstack for all web browsing, never use mcp\_\_claude-in-chrome\_\_\* tools, lists the available skills: /office-hours, /plan-ceo-review, /plan-eng-review, /plan-design-review, /design-consultation, /find-skills, /review, /ship, /land-and-deploy, /canary, /benchmark, /browse, /qa, /qa-only, /design-review, /setup-browser-cookies, /setup-deploy, /retro, /investigate, /document-release, /codex, /cso, /careful, /freeze, /guard, /unfreeze, /gstack-upgrade, and tells Claude that if gstack skills aren't working, run `cd .claude/skills/gstack && ./setup` to build the binary and register skills. Real files get committed to your repo (not a submodule), so `git clone` just works. Everything lives inside `.claude/`. Nothing touches your PATH or runs in the background. @@ -145,6 +145,7 @@ Each skill feeds into the next. `/office-hours` writes a design doc that `/plan- | `/plan-eng-review` | **Eng Manager** | Lock in architecture, data flow, diagrams, edge cases, and tests. Forces hidden assumptions into the open. | | `/plan-design-review` | **Senior Designer** | Rates each design dimension 0-10, explains what a 10 looks like, then edits the plan to get there. AI Slop detection. Interactive — one AskUserQuestion per design choice. | | `/design-consultation` | **Design Partner** | Build a complete design system from scratch. Researches the landscape, proposes creative risks, generates realistic product mockups. | +| `/find-skills` | **Marketplace Search** | Find the best external Agent Skills / skills.sh skills for a technology or workflow query. | | `/review` | **Staff Engineer** | Find the bugs that pass CI but blow up in production. Auto-fixes the obvious ones. Flags completeness gaps. | | `/investigate` | **Debugger** | Systematic root-cause debugging. Iron Law: no fixes without investigation. Traces data flow, tests hypotheses, stops after 3 failed fixes. | | `/design-review` | **Designer Who Codes** | Same audit as /plan-design-review, then fixes what it finds. Atomic commits, before/after screenshots. | @@ -165,6 +166,7 @@ Each skill feeds into the next. `/office-hours` writes a design doc that `/plan- | Skill | What it does | |-------|-------------| +| `/find-skills` | **Marketplace Search** — query Agent Skills / skills.sh for external vendor/framework-specific skills and get copy-paste install commands. | | `/codex` | **Second Opinion** — independent code review from OpenAI Codex CLI. Three modes: review (pass/fail gate), adversarial challenge, and open consultation. Cross-model analysis when both `/review` and `/codex` have run. | | `/careful` | **Safety Guardrails** — warns before destructive commands (rm -rf, DROP TABLE, force-push). Say "be careful" to activate. Override any warning. | | `/freeze` | **Edit Lock** — restrict file edits to one directory. Prevents accidental changes outside scope while debugging. | @@ -234,7 +236,7 @@ Data is stored in [Supabase](https://supabase.com) (open source Firebase alterna ## gstack Use /browse from gstack for all web browsing. Never use mcp__claude-in-chrome__* tools. Available skills: /office-hours, /plan-ceo-review, /plan-eng-review, /plan-design-review, -/design-consultation, /review, /ship, /land-and-deploy, /canary, /benchmark, /browse, +/design-consultation, /find-skills, /review, /ship, /land-and-deploy, /canary, /benchmark, /browse, /qa, /qa-only, /design-review, /setup-browser-cookies, /setup-deploy, /retro, /investigate, /document-release, /codex, /cso, /autoplan, /careful, /freeze, /guard, /unfreeze, /gstack-upgrade. diff --git a/SKILL.md b/SKILL.md index af9ef7b06..f45ed9e01 100644 --- a/SKILL.md +++ b/SKILL.md @@ -8,7 +8,7 @@ description: | test a site, verify a deployment, dogfood a user flow, or file a bug with screenshots. Also suggest adjacent gstack skills by stage: brainstorm /office-hours; strategy /plan-ceo-review; architecture /plan-eng-review; design /plan-design-review or - /design-consultation; auto-review /autoplan; debugging /investigate; QA /qa; code review + /design-consultation; external marketplace /find-skills; auto-review /autoplan; debugging /investigate; QA /qa; code review /review; visual audit /design-review; shipping /ship; docs /document-release; retro /retro; second opinion /codex; prod safety /careful or /guard; scoped edits /freeze or /unfreeze; gstack upgrades /gstack-upgrade. If the user opts out of suggestions, stop diff --git a/SKILL.md.tmpl b/SKILL.md.tmpl index 436e80040..bddb0b739 100644 --- a/SKILL.md.tmpl +++ b/SKILL.md.tmpl @@ -8,7 +8,7 @@ description: | test a site, verify a deployment, dogfood a user flow, or file a bug with screenshots. Also suggest adjacent gstack skills by stage: brainstorm /office-hours; strategy /plan-ceo-review; architecture /plan-eng-review; design /plan-design-review or - /design-consultation; auto-review /autoplan; debugging /investigate; QA /qa; code review + /design-consultation; external marketplace /find-skills; auto-review /autoplan; debugging /investigate; QA /qa; code review /review; visual audit /design-review; shipping /ship; docs /document-release; retro /retro; second opinion /codex; prod safety /careful or /guard; scoped edits /freeze or /unfreeze; gstack upgrades /gstack-upgrade. If the user opts out of suggestions, stop diff --git a/autoplan/SKILL.md b/autoplan/SKILL.md index ec75c5507..ad86cde6d 100644 --- a/autoplan/SKILL.md +++ b/autoplan/SKILL.md @@ -479,6 +479,36 @@ Then prepend a one-line HTML comment to the plan file: button, modal, layout, dashboard, sidebar, nav, dialog). Require 2+ matches. Exclude false positives ("page" alone, "UI" in acronyms). +## External Skill Marketplace Check + +If `PROACTIVE` is `"false"`, skip this step entirely. + +Use this step when the user's request or current plan/design context clearly names a +platform, vendor, framework, or tool that may already have a strong external skill in +the Agent Skills / skills.sh marketplace. + +1. Extract 2-6 concrete technology keywords from the user's request or current plan/design context. +2. Write the original request (or a short summary of the current plan/design) to a temp file: + +```bash +TMP_QUERY=$(mktemp /tmp/gstack-marketplace-query-XXXX.txt) +cat > "$TMP_QUERY" <<'EOF' +[original user request or current plan/design summary] +EOF +~/.claude/skills/gstack/bin/gstack-marketplace-search --query-file "$TMP_QUERY" --keyword "keyword-1" --keyword "keyword-2" --limit 3 --json +rm -f "$TMP_QUERY" +``` + +3. If the helper returns `"status": "ok"` with non-empty `results`, surface an + **External Skills Worth Considering** section with up to 3 results: + - scoped name + - one-line why it matches + - install command +4. Never auto-install or auto-run marketplace skills. This step is recommendation-only. +5. If the helper returns `unavailable` or no results, continue silently. +6. If a gstack built-in skill already covers the need well, prefer the gstack skill and + present the external result only as optional context. + ### Step 3: Load skill files from disk Read each file using the Read tool: diff --git a/autoplan/SKILL.md.tmpl b/autoplan/SKILL.md.tmpl index 2213c8b9d..36bcf0a9a 100644 --- a/autoplan/SKILL.md.tmpl +++ b/autoplan/SKILL.md.tmpl @@ -137,6 +137,8 @@ Then prepend a one-line HTML comment to the plan file: button, modal, layout, dashboard, sidebar, nav, dialog). Require 2+ matches. Exclude false positives ("page" alone, "UI" in acronyms). +{{MARKETPLACE_SKILL_DISCOVERY}} + ### Step 3: Load skill files from disk Read each file using the Read tool: diff --git a/bin/gstack-marketplace-search.ts b/bin/gstack-marketplace-search.ts new file mode 100755 index 000000000..0ea5cc4c0 --- /dev/null +++ b/bin/gstack-marketplace-search.ts @@ -0,0 +1,322 @@ +#!/usr/bin/env bun + +import * as fs from 'fs'; +import * as path from 'path'; +import { createHash } from 'crypto'; +import { spawnSync } from 'child_process'; + +interface RawSkill { + name?: string; + description?: string; + author?: string; + stars?: number; + forks?: number; + githubUrl?: string; + scopedName?: string; +} + +interface SearchQuery { + text: string; + source: 'full' | 'keyword'; +} + +interface RankedSkill { + name: string; + description: string; + author: string; + scopedName: string; + githubUrl: string; + stars: number; + forks: number; + installCommand: string; + matchedKeywords: string[]; + sourceQueries: string[]; + score: number; +} + +interface SearchResponse { + status: 'ok' | 'unavailable'; + query: string; + keywords: string[]; + queries: string[]; + results: RankedSkill[]; + reason?: string; +} + +const KNOWN_KEYWORDS: Array<{ canonical: string; patterns: RegExp[] }> = [ + { canonical: 'supabase', patterns: [/\bsupabase\b/i] }, + { canonical: 'vercel', patterns: [/\bvercel\b/i] }, + { canonical: 'azure cli', patterns: [/\bazure cli\b/i, /\baz\s+cli\b/i, /\baz\b/i] }, + { canonical: 'github cli', patterns: [/\bgithub cli\b/i, /\bgh cli\b/i, /\bgh\b/i] }, + { canonical: 'nextjs', patterns: [/\bnext\.?js\b/i, /\bnextjs\b/i] }, + { canonical: 'postgres', patterns: [/\bpostgres(?:ql)?\b/i] }, + { canonical: 'prisma', patterns: [/\bprisma\b/i] }, + { canonical: 'drizzle', patterns: [/\bdrizzle\b/i] }, + { canonical: 'tailwind', patterns: [/\btailwind\b/i] }, + { canonical: 'docker', patterns: [/\bdocker\b/i] }, + { canonical: 'kubernetes', patterns: [/\bkubernetes\b/i, /\bk8s\b/i] }, + { canonical: 'terraform', patterns: [/\bterraform\b/i] }, + { canonical: 'openai', patterns: [/\bopenai\b/i] }, + { canonical: 'anthropic', patterns: [/\banthropic\b/i, /\bclaude\b/i] }, + { canonical: 'stripe', patterns: [/\bstripe\b/i] }, + { canonical: 'react', patterns: [/\breact\b/i] }, + { canonical: 'vue', patterns: [/\bvue\b/i] }, + { canonical: 'svelte', patterns: [/\bsvelte\b/i] }, +]; + +const STOPWORDS = new Set([ + 'build', 'using', 'with', 'need', 'help', 'make', 'this', 'that', 'from', + 'into', 'have', 'about', 'should', 'would', 'there', 'their', 'when', 'what', + 'where', 'which', 'while', 'before', 'after', 'without', 'through', 'query', + 'skill', 'skills', 'mode', 'plan', 'design', 'review', 'flow', +]); + +function parseArgs(argv: string[]) { + let query = ''; + let queryFile = ''; + let limit = 3; + let outputJson = false; + const explicitKeywords: string[] = []; + + for (let i = 0; i < argv.length; i++) { + const arg = argv[i]; + if (arg === '--query') query = argv[++i] ?? ''; + else if (arg === '--query-file') queryFile = argv[++i] ?? ''; + else if (arg === '--keyword') explicitKeywords.push((argv[++i] ?? '').trim()); + else if (arg === '--limit') limit = Math.max(1, Number(argv[++i] ?? 3) || 3); + else if (arg === '--json') outputJson = true; + } + + if (!query && queryFile) query = fs.readFileSync(queryFile, 'utf-8'); + + if (!query.trim()) { + throw new Error('Usage: gstack-marketplace-search --query [--keyword ] [--limit ] [--json]'); + } + + return { query: query.trim(), explicitKeywords, limit, outputJson }; +} + +export function extractKeywords(text: string): string[] { + const matches = new Set(); + + for (const entry of KNOWN_KEYWORDS) { + if (entry.patterns.some(pattern => pattern.test(text))) { + matches.add(entry.canonical); + } + } + + if (matches.size === 0) { + const generic = text + .toLowerCase() + .split(/[^a-z0-9.+#-]+/) + .filter(token => token.length >= 4 && !STOPWORDS.has(token)) + .slice(0, 4); + for (const token of generic) matches.add(token); + } + + return Array.from(matches).slice(0, 6); +} + +export function parseMarketplaceOutput(raw: string): RawSkill[] { + const start = raw.indexOf('{'); + const end = raw.lastIndexOf('}'); + if (start === -1 || end === -1 || end < start) return []; + const parsed = JSON.parse(raw.slice(start, end + 1)); + return Array.isArray(parsed.skills) ? parsed.skills : []; +} + +function buildQueries(query: string, explicitKeywords: string[]): SearchQuery[] { + const keywords = Array.from(new Set([ + ...explicitKeywords.map(k => k.trim().toLowerCase()).filter(Boolean), + ...extractKeywords(query), + ])).slice(0, 6); + + const trimmedQuery = query.split(/\s+/).slice(0, 12).join(' ').trim(); + const queries: SearchQuery[] = []; + if (trimmedQuery) queries.push({ text: trimmedQuery, source: 'full' }); + for (const keyword of keywords.slice(0, 3)) queries.push({ text: keyword, source: 'keyword' }); + return queries; +} + +function commandExists(bin: string): boolean { + const result = spawnSync('which', [bin], { encoding: 'utf-8' }); + return result.status === 0; +} + +function getStateDir(): string { + return process.env.GSTACK_STATE_DIR || path.join(process.env.HOME || '', '.gstack'); +} + +function readCache(key: string): SearchResponse | null { + const cacheFile = path.join(getStateDir(), 'cache', 'marketplace-search', `${key}.json`); + if (!fs.existsSync(cacheFile)) return null; + const stat = fs.statSync(cacheFile); + if (Date.now() - stat.mtimeMs > 24 * 60 * 60 * 1000) return null; + return JSON.parse(fs.readFileSync(cacheFile, 'utf-8')) as SearchResponse; +} + +function writeCache(key: string, data: SearchResponse) { + const cacheDir = path.join(getStateDir(), 'cache', 'marketplace-search'); + fs.mkdirSync(cacheDir, { recursive: true }); + fs.writeFileSync(path.join(cacheDir, `${key}.json`), JSON.stringify(data, null, 2)); +} + +function runSearchQuery(query: SearchQuery, limit: number): RawSkill[] | null { + if (process.env.GSTACK_MARKETPLACE_FIXTURE) { + const raw = fs.readFileSync(process.env.GSTACK_MARKETPLACE_FIXTURE, 'utf-8'); + return parseMarketplaceOutput(raw); + } + + const queryArgs = query.text.split(/\s+/).filter(Boolean).slice(0, 12); + const commonArgs = ['search', ...queryArgs, '--json', '--limit', String(limit), '--sort', 'stars']; + + if (commandExists('skills')) { + const result = spawnSync('skills', commonArgs, { encoding: 'utf-8', timeout: 30000 }); + if (result.status === 0) return parseMarketplaceOutput(result.stdout || result.stderr || ''); + } + + if (commandExists('npx')) { + const result = spawnSync('npx', ['-y', 'agent-skills-cli', ...commonArgs], { + encoding: 'utf-8', + timeout: 30000, + }); + if (result.status === 0) return parseMarketplaceOutput((result.stdout || '') + (result.stderr || '')); + } + + return null; +} + +export function rankSkills(rawSkills: Array, keywords: string[], limit: number): RankedSkill[] { + const ranked = new Map(); + + for (let index = 0; index < rawSkills.length; index++) { + const raw = rawSkills[index]; + const key = raw.scopedName || raw.githubUrl || `${raw.author}:${raw.name}`; + if (!key) continue; + + const name = raw.name || 'unknown'; + const description = raw.description || ''; + const author = raw.author || 'unknown'; + const scopedName = raw.scopedName || `@${author}/${name}`; + const githubUrl = raw.githubUrl || ''; + const stars = raw.stars || 0; + const forks = raw.forks || 0; + const haystack = `${name} ${scopedName} ${description}`.toLowerCase(); + const matchedKeywords = keywords.filter(keyword => haystack.includes(keyword.toLowerCase())); + const exactNameMatch = matchedKeywords.some(keyword => + name.toLowerCase().includes(keyword) || scopedName.toLowerCase().includes(keyword) + ); + + const score = + Math.max(0, 100 - index * 3) + + matchedKeywords.length * 18 + + (exactNameMatch ? 20 : 0) + + (raw.query.source === 'keyword' ? 8 : 4) + + Math.min(18, Math.floor(Math.log10(stars + 1) * 6)); + + const next: RankedSkill = { + name, + description, + author, + scopedName, + githubUrl, + stars, + forks, + installCommand: `npx skills add ${scopedName}`, + matchedKeywords, + sourceQueries: [raw.query.text], + score, + }; + + const existing = ranked.get(key); + if (!existing || next.score > existing.score) { + ranked.set(key, existing + ? { + ...next, + sourceQueries: Array.from(new Set([...existing.sourceQueries, ...next.sourceQueries])), + matchedKeywords: Array.from(new Set([...existing.matchedKeywords, ...next.matchedKeywords])), + } + : next); + } else { + existing.sourceQueries = Array.from(new Set([...existing.sourceQueries, raw.query.text])); + existing.matchedKeywords = Array.from(new Set([...existing.matchedKeywords, ...next.matchedKeywords])); + } + } + + return Array.from(ranked.values()) + .sort((a, b) => b.score - a.score || b.stars - a.stars) + .slice(0, limit); +} + +function formatText(response: SearchResponse): string { + if (response.status !== 'ok') { + return `Marketplace unavailable: ${response.reason ?? 'unknown reason'}`; + } + if (response.results.length === 0) { + return `No marketplace matches found for: ${response.query}`; + } + const lines = [`Marketplace matches for: ${response.query}`, '']; + response.results.forEach((result, index) => { + lines.push(`${index + 1}. ${result.scopedName} — ${result.description}`); + lines.push(` Why: matched ${result.matchedKeywords.join(', ') || 'query context'}`); + lines.push(` Install: ${result.installCommand}`); + if (result.githubUrl) lines.push(` Source: ${result.githubUrl}`); + }); + return lines.join('\n'); +} + +async function main() { + try { + const { query, explicitKeywords, limit, outputJson } = parseArgs(process.argv.slice(2)); + const keywords = Array.from(new Set([ + ...explicitKeywords.map(k => k.trim().toLowerCase()).filter(Boolean), + ...extractKeywords(query), + ])).slice(0, 6); + const queries = buildQueries(query, explicitKeywords); + const cacheKey = createHash('sha1') + .update(JSON.stringify({ query, keywords, limit })) + .digest('hex'); + + if (!process.env.GSTACK_MARKETPLACE_FIXTURE) { + const cached = readCache(cacheKey); + if (cached) { + console.log(outputJson ? JSON.stringify(cached, null, 2) : formatText(cached)); + return; + } + } + + const rawHits: Array = []; + for (const searchQuery of queries) { + const hits = runSearchQuery(searchQuery, Math.max(limit, 5)); + if (!hits) continue; + for (const hit of hits) rawHits.push({ ...hit, query: searchQuery }); + } + + const response: SearchResponse = rawHits.length > 0 + ? { + status: 'ok', + query, + keywords, + queries: queries.map(item => item.text), + results: rankSkills(rawHits, keywords, limit), + } + : { + status: 'unavailable', + query, + keywords, + queries: queries.map(item => item.text), + results: [], + reason: 'skills CLI unavailable or search failed', + }; + + if (!process.env.GSTACK_MARKETPLACE_FIXTURE) writeCache(cacheKey, response); + console.log(outputJson ? JSON.stringify(response, null, 2) : formatText(response)); + } catch (error) { + console.error(error instanceof Error ? error.message : String(error)); + process.exit(1); + } +} + +if (import.meta.main) { + await main(); +} diff --git a/design-consultation/SKILL.md b/design-consultation/SKILL.md index fc265f9e7..cbd82ff39 100644 --- a/design-consultation/SKILL.md +++ b/design-consultation/SKILL.md @@ -362,6 +362,36 @@ If browse is not available, that's fine — visual research is optional. The ski --- +## External Skill Marketplace Check + +If `PROACTIVE` is `"false"`, skip this step entirely. + +Use this step when the user's request or current plan/design context clearly names a +platform, vendor, framework, or tool that may already have a strong external skill in +the Agent Skills / skills.sh marketplace. + +1. Extract 2-6 concrete technology keywords from the user's request or current plan/design context. +2. Write the original request (or a short summary of the current plan/design) to a temp file: + +```bash +TMP_QUERY=$(mktemp /tmp/gstack-marketplace-query-XXXX.txt) +cat > "$TMP_QUERY" <<'EOF' +[original user request or current plan/design summary] +EOF +~/.claude/skills/gstack/bin/gstack-marketplace-search --query-file "$TMP_QUERY" --keyword "keyword-1" --keyword "keyword-2" --limit 3 --json +rm -f "$TMP_QUERY" +``` + +3. If the helper returns `"status": "ok"` with non-empty `results`, surface an + **External Skills Worth Considering** section with up to 3 results: + - scoped name + - one-line why it matches + - install command +4. Never auto-install or auto-run marketplace skills. This step is recommendation-only. +5. If the helper returns `unavailable` or no results, continue silently. +6. If a gstack built-in skill already covers the need well, prefer the gstack skill and + present the external result only as optional context. + ## Phase 1: Product Context Ask the user a single question that covers everything you need to know. Pre-fill what you can infer from the codebase. diff --git a/design-consultation/SKILL.md.tmpl b/design-consultation/SKILL.md.tmpl index d8604cebf..72727643e 100644 --- a/design-consultation/SKILL.md.tmpl +++ b/design-consultation/SKILL.md.tmpl @@ -69,6 +69,8 @@ If browse is not available, that's fine — visual research is optional. The ski --- +{{MARKETPLACE_SKILL_DISCOVERY}} + ## Phase 1: Product Context Ask the user a single question that covers everything you need to know. Pre-fill what you can infer from the codebase. diff --git a/docs/skills.md b/docs/skills.md index afbac0d2d..adadd1be0 100644 --- a/docs/skills.md +++ b/docs/skills.md @@ -9,6 +9,7 @@ Detailed guides for every gstack skill — philosophy, workflow, and examples. | [`/plan-eng-review`](#plan-eng-review) | **Eng Manager** | Lock in architecture, data flow, diagrams, edge cases, and tests. Forces hidden assumptions into the open. | | [`/plan-design-review`](#plan-design-review) | **Senior Designer** | Interactive plan-mode design review. Rates each dimension 0-10, explains what a 10 looks like, fixes the plan. Works in plan mode. | | [`/design-consultation`](#design-consultation) | **Design Partner** | Build a complete design system from scratch. Knows the landscape, proposes creative risks, generates realistic product mockups. Design at the heart of all other phases. | +| [`/find-skills`](#find-skills) | **Marketplace Search** | Query Agent Skills / skills.sh for the best external vendor/framework-specific skills and copyable install commands. | | [`/review`](#review) | **Staff Engineer** | Find the bugs that pass CI but blow up in production. Auto-fixes the obvious ones. Flags completeness gaps. | | [`/investigate`](#investigate) | **Debugger** | Systematic root-cause debugging. Iron Law: no fixes without investigation. Traces data flow, tests hypotheses, stops after 3 failed fixes. | | [`/design-review`](#design-review) | **Designer Who Codes** | Live-site visual audit + fix loop. 80-item audit, then fixes what it finds. Atomic commits, before/after screenshots. | @@ -90,6 +91,30 @@ After the design doc is approved, `/office-hours` reflects on what it noticed ab --- +## `/find-skills` + +This is the manual parity path for the external marketplace. + +Sometimes the right next step is not another built-in gstack workflow skill, but a +specialized external skill published by the vendor or ecosystem you are working in. +That is what `/find-skills` is for. + +Give it a query like: + +- `supabase auth nextjs` +- `vercel deployment` +- `azure cli` +- `github cli workflow automation` + +It runs the marketplace search, dedupes the results, ranks the best matches, and gives +you copy-paste install commands. It never auto-installs anything — recommendation only. + +This is also the manual fallback for the new planning/design marketplace recommendation +layer. If an automatic planning flow mentions an external skill and you want to dig +deeper, `/find-skills` is the direct command to use. + +--- + ## `/plan-ceo-review` This is my **founder mode**. diff --git a/find-skills/SKILL.md b/find-skills/SKILL.md new file mode 100644 index 000000000..14f95bc14 --- /dev/null +++ b/find-skills/SKILL.md @@ -0,0 +1,338 @@ +--- +name: find-skills +version: 1.0.0 +description: | + Find external agent skills from the Agent Skills / skills.sh marketplace for a given + technology or workflow query. Use when asked to "find a skill for X", "search skills + for supabase/vercel/azure/github cli", or "what external skill should I install". + Proactively suggest when the user asks for vendor-specific help that gstack does not + directly provide as a built-in workflow skill. +allowed-tools: + - Bash + - AskUserQuestion +--- + + + +## Preamble (run first) + +```bash +_UPD=$(~/.claude/skills/gstack/bin/gstack-update-check 2>/dev/null || .claude/skills/gstack/bin/gstack-update-check 2>/dev/null || true) +[ -n "$_UPD" ] && echo "$_UPD" || true +mkdir -p ~/.gstack/sessions +touch ~/.gstack/sessions/"$PPID" +_SESSIONS=$(find ~/.gstack/sessions -mmin -120 -type f 2>/dev/null | wc -l | tr -d ' ') +find ~/.gstack/sessions -mmin +120 -type f -delete 2>/dev/null || true +_CONTRIB=$(~/.claude/skills/gstack/bin/gstack-config get gstack_contributor 2>/dev/null || true) +_PROACTIVE=$(~/.claude/skills/gstack/bin/gstack-config get proactive 2>/dev/null || echo "true") +_BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown") +echo "BRANCH: $_BRANCH" +echo "PROACTIVE: $_PROACTIVE" +source <(~/.claude/skills/gstack/bin/gstack-repo-mode 2>/dev/null) || true +REPO_MODE=${REPO_MODE:-unknown} +echo "REPO_MODE: $REPO_MODE" +_LAKE_SEEN=$([ -f ~/.gstack/.completeness-intro-seen ] && echo "yes" || echo "no") +echo "LAKE_INTRO: $_LAKE_SEEN" +_TEL=$(~/.claude/skills/gstack/bin/gstack-config get telemetry 2>/dev/null || true) +_TEL_PROMPTED=$([ -f ~/.gstack/.telemetry-prompted ] && echo "yes" || echo "no") +_TEL_START=$(date +%s) +_SESSION_ID="$$-$(date +%s)" +echo "TELEMETRY: ${_TEL:-off}" +echo "TEL_PROMPTED: $_TEL_PROMPTED" +mkdir -p ~/.gstack/analytics +echo '{"skill":"find-skills","ts":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","repo":"'$(basename "$(git rev-parse --show-toplevel 2>/dev/null)" 2>/dev/null || echo "unknown")'"}' >> ~/.gstack/analytics/skill-usage.jsonl 2>/dev/null || true +# zsh-compatible: use find instead of glob to avoid NOMATCH error +for _PF in $(find ~/.gstack/analytics -maxdepth 1 -name '.pending-*' 2>/dev/null); do [ -f "$_PF" ] && ~/.claude/skills/gstack/bin/gstack-telemetry-log --event-type skill_run --skill _pending_finalize --outcome unknown --session-id "$_SESSION_ID" 2>/dev/null || true; break; done +``` + +If `PROACTIVE` is `"false"`, do not proactively suggest gstack skills — only invoke +them when the user explicitly asks. The user opted out of proactive suggestions. + +If output shows `UPGRADE_AVAILABLE `: read `~/.claude/skills/gstack/gstack-upgrade/SKILL.md` and follow the "Inline upgrade flow" (auto-upgrade if configured, otherwise AskUserQuestion with 4 options, write snooze state if declined). If `JUST_UPGRADED `: tell user "Running gstack v{to} (just updated!)" and continue. + +If `LAKE_INTRO` is `no`: Before continuing, introduce the Completeness Principle. +Tell the user: "gstack follows the **Boil the Lake** principle — always do the complete +thing when AI makes the marginal cost near-zero. Read more: https://garryslist.org/posts/boil-the-ocean" +Then offer to open the essay in their default browser: + +```bash +open https://garryslist.org/posts/boil-the-ocean +touch ~/.gstack/.completeness-intro-seen +``` + +Only run `open` if the user says yes. Always run `touch` to mark as seen. This only happens once. + +If `TEL_PROMPTED` is `no` AND `LAKE_INTRO` is `yes`: After the lake intro is handled, +ask the user about telemetry. Use AskUserQuestion: + +> Help gstack get better! Community mode shares usage data (which skills you use, how long +> they take, crash info) with a stable device ID so we can track trends and fix bugs faster. +> No code, file paths, or repo names are ever sent. +> Change anytime with `gstack-config set telemetry off`. + +Options: +- A) Help gstack get better! (recommended) +- B) No thanks + +If A: run `~/.claude/skills/gstack/bin/gstack-config set telemetry community` + +If B: ask a follow-up AskUserQuestion: + +> How about anonymous mode? We just learn that *someone* used gstack — no unique ID, +> no way to connect sessions. Just a counter that helps us know if anyone's out there. + +Options: +- A) Sure, anonymous is fine +- B) No thanks, fully off + +If B→A: run `~/.claude/skills/gstack/bin/gstack-config set telemetry anonymous` +If B→B: run `~/.claude/skills/gstack/bin/gstack-config set telemetry off` + +Always run: +```bash +touch ~/.gstack/.telemetry-prompted +``` + +This only happens once. If `TEL_PROMPTED` is `yes`, skip this entirely. + +## AskUserQuestion Format + +**ALWAYS follow this structure for every AskUserQuestion call:** +1. **Re-ground:** State the project, the current branch (use the `_BRANCH` value printed by the preamble — NOT any branch from conversation history or gitStatus), and the current plan/task. (1-2 sentences) +2. **Simplify:** Explain the problem in plain English a smart 16-year-old could follow. No raw function names, no internal jargon, no implementation details. Use concrete examples and analogies. Say what it DOES, not what it's called. +3. **Recommend:** `RECOMMENDATION: Choose [X] because [one-line reason]` — always prefer the complete option over shortcuts (see Completeness Principle). Include `Completeness: X/10` for each option. Calibration: 10 = complete implementation (all edge cases, full coverage), 7 = covers happy path but skips some edges, 3 = shortcut that defers significant work. If both options are 8+, pick the higher; if one is ≤5, flag it. +4. **Options:** Lettered options: `A) ... B) ... C) ...` — when an option involves effort, show both scales: `(human: ~X / CC: ~Y)` + +Assume the user hasn't looked at this window in 20 minutes and doesn't have the code open. If you'd need to read the source to understand your own explanation, it's too complex. + +Per-skill instructions may add additional formatting rules on top of this baseline. + +## Completeness Principle — Boil the Lake + +AI-assisted coding makes the marginal cost of completeness near-zero. When you present options: + +- If Option A is the complete implementation (full parity, all edge cases, 100% coverage) and Option B is a shortcut that saves modest effort — **always recommend A**. The delta between 80 lines and 150 lines is meaningless with CC+gstack. "Good enough" is the wrong instinct when "complete" costs minutes more. +- **Lake vs. ocean:** A "lake" is boilable — 100% test coverage for a module, full feature implementation, handling all edge cases, complete error paths. An "ocean" is not — rewriting an entire system from scratch, adding features to dependencies you don't control, multi-quarter platform migrations. Recommend boiling lakes. Flag oceans as out of scope. +- **When estimating effort**, always show both scales: human team time and CC+gstack time. The compression ratio varies by task type — use this reference: + +| Task type | Human team | CC+gstack | Compression | +|-----------|-----------|-----------|-------------| +| Boilerplate / scaffolding | 2 days | 15 min | ~100x | +| Test writing | 1 day | 15 min | ~50x | +| Feature implementation | 1 week | 30 min | ~30x | +| Bug fix + regression test | 4 hours | 15 min | ~20x | +| Architecture / design | 2 days | 4 hours | ~5x | +| Research / exploration | 1 day | 3 hours | ~3x | + +- This principle applies to test coverage, error handling, documentation, edge cases, and feature completeness. Don't skip the last 10% to "save time" — with AI, that 10% costs seconds. + +**Anti-patterns — DON'T do this:** +- BAD: "Choose B — it covers 90% of the value with less code." (If A is only 70 lines more, choose A.) +- BAD: "We can skip edge case handling to save time." (Edge case handling costs minutes with CC.) +- BAD: "Let's defer test coverage to a follow-up PR." (Tests are the cheapest lake to boil.) +- BAD: Quoting only human-team effort: "This would take 2 weeks." (Say: "2 weeks human / ~1 hour CC.") + +## Repo Ownership Mode — See Something, Say Something + +`REPO_MODE` from the preamble tells you who owns issues in this repo: + +- **`solo`** — One person does 80%+ of the work. They own everything. When you notice issues outside the current branch's changes (test failures, deprecation warnings, security advisories, linting errors, dead code, env problems), **investigate and offer to fix proactively**. The solo dev is the only person who will fix it. Default to action. +- **`collaborative`** — Multiple active contributors. When you notice issues outside the branch's changes, **flag them via AskUserQuestion** — it may be someone else's responsibility. Default to asking, not fixing. +- **`unknown`** — Treat as collaborative (safer default — ask before fixing). + +**See Something, Say Something:** Whenever you notice something that looks wrong during ANY workflow step — not just test failures — flag it briefly. One sentence: what you noticed and its impact. In solo mode, follow up with "Want me to fix it?" In collaborative mode, just flag it and move on. + +Never let a noticed issue silently pass. The whole point is proactive communication. + +## Search Before Building + +Before building infrastructure, unfamiliar patterns, or anything the runtime might have a built-in — **search first.** Read `~/.claude/skills/gstack/ETHOS.md` for the full philosophy. + +**Three layers of knowledge:** +- **Layer 1** (tried and true — in distribution). Don't reinvent the wheel. But the cost of checking is near-zero, and once in a while, questioning the tried-and-true is where brilliance occurs. +- **Layer 2** (new and popular — search for these). But scrutinize: humans are subject to mania. Search results are inputs to your thinking, not answers. +- **Layer 3** (first principles — prize these above all). Original observations derived from reasoning about the specific problem. The most valuable of all. + +**Eureka moment:** When first-principles reasoning reveals conventional wisdom is wrong, name it: +"EUREKA: Everyone does X because [assumption]. But [evidence] shows this is wrong. Y is better because [reasoning]." + +Log eureka moments: +```bash +jq -n --arg ts "$(date -u +%Y-%m-%dT%H:%M:%SZ)" --arg skill "SKILL_NAME" --arg branch "$(git branch --show-current 2>/dev/null)" --arg insight "ONE_LINE_SUMMARY" '{ts:$ts,skill:$skill,branch:$branch,insight:$insight}' >> ~/.gstack/analytics/eureka.jsonl 2>/dev/null || true +``` +Replace SKILL_NAME and ONE_LINE_SUMMARY. Runs inline — don't stop the workflow. + +**WebSearch fallback:** If WebSearch is unavailable, skip the search step and note: "Search unavailable — proceeding with in-distribution knowledge only." + +## Contributor Mode + +If `_CONTRIB` is `true`: you are in **contributor mode**. You're a gstack user who also helps make it better. + +**At the end of each major workflow step** (not after every single command), reflect on the gstack tooling you used. Rate your experience 0 to 10. If it wasn't a 10, think about why. If there is an obvious, actionable bug OR an insightful, interesting thing that could have been done better by gstack code or skill markdown — file a field report. Maybe our contributor will help make us better! + +**Calibration — this is the bar:** For example, `$B js "await fetch(...)"` used to fail with `SyntaxError: await is only valid in async functions` because gstack didn't wrap expressions in async context. Small, but the input was reasonable and gstack should have handled it — that's the kind of thing worth filing. Things less consequential than this, ignore. + +**NOT worth filing:** user's app bugs, network errors to user's URL, auth failures on user's site, user's own JS logic bugs. + +**To file:** write `~/.gstack/contributor-logs/{slug}.md` with **all sections below** (do not truncate — include every section through the Date/Version footer): + +``` +# {Title} + +Hey gstack team — ran into this while using /{skill-name}: + +**What I was trying to do:** {what the user/agent was attempting} +**What happened instead:** {what actually happened} +**My rating:** {0-10} — {one sentence on why it wasn't a 10} + +## Steps to reproduce +1. {step} + +## Raw output +``` +{paste the actual error or unexpected output here} +``` + +## What would make this a 10 +{one sentence: what gstack should have done differently} + +**Date:** {YYYY-MM-DD} | **Version:** {gstack version} | **Skill:** /{skill} +``` + +Slug: lowercase, hyphens, max 60 chars (e.g. `browse-js-no-await`). Skip if file already exists. Max 3 reports per session. File inline and continue — don't stop the workflow. Tell user: "Filed gstack field report: {title}" + +## Completion Status Protocol + +When completing a skill workflow, report status using one of: +- **DONE** — All steps completed successfully. Evidence provided for each claim. +- **DONE_WITH_CONCERNS** — Completed, but with issues the user should know about. List each concern. +- **BLOCKED** — Cannot proceed. State what is blocking and what was tried. +- **NEEDS_CONTEXT** — Missing information required to continue. State exactly what you need. + +### Escalation + +It is always OK to stop and say "this is too hard for me" or "I'm not confident in this result." + +Bad work is worse than no work. You will not be penalized for escalating. +- If you have attempted a task 3 times without success, STOP and escalate. +- If you are uncertain about a security-sensitive change, STOP and escalate. +- If the scope of work exceeds what you can verify, STOP and escalate. + +Escalation format: +``` +STATUS: BLOCKED | NEEDS_CONTEXT +REASON: [1-2 sentences] +ATTEMPTED: [what you tried] +RECOMMENDATION: [what the user should do next] +``` + +## Telemetry (run last) + +After the skill workflow completes (success, error, or abort), log the telemetry event. +Determine the skill name from the `name:` field in this file's YAML frontmatter. +Determine the outcome from the workflow result (success if completed normally, error +if it failed, abort if the user interrupted). + +**PLAN MODE EXCEPTION — ALWAYS RUN:** This command writes telemetry to +`~/.gstack/analytics/` (user config directory, not project files). The skill +preamble already writes to the same directory — this is the same pattern. +Skipping this command loses session duration and outcome data. + +Run this bash: + +```bash +_TEL_END=$(date +%s) +_TEL_DUR=$(( _TEL_END - _TEL_START )) +rm -f ~/.gstack/analytics/.pending-"$_SESSION_ID" 2>/dev/null || true +~/.claude/skills/gstack/bin/gstack-telemetry-log \ + --skill "SKILL_NAME" --duration "$_TEL_DUR" --outcome "OUTCOME" \ + --used-browse "USED_BROWSE" --session-id "$_SESSION_ID" 2>/dev/null & +``` + +Replace `SKILL_NAME` with the actual skill name from frontmatter, `OUTCOME` with +success/error/abort, and `USED_BROWSE` with true/false based on whether `$B` was used. +If you cannot determine the outcome, use "unknown". This runs in the background and +never blocks the user. + +## Plan Status Footer + +When you are in plan mode and about to call ExitPlanMode: + +1. Check if the plan file already has a `## GSTACK REVIEW REPORT` section. +2. If it DOES — skip (a review skill already wrote a richer report). +3. If it does NOT — run this command: + +\`\`\`bash +~/.claude/skills/gstack/bin/gstack-review-read +\`\`\` + +Then write a `## GSTACK REVIEW REPORT` section to the end of the plan file: + +- If the output contains review entries (JSONL lines before `---CONFIG---`): format the + standard report table with runs/status/findings per skill, same format as the review + skills use. +- If the output is `NO_REVIEWS` or empty: write this placeholder table: + +\`\`\`markdown +## GSTACK REVIEW REPORT + +| Review | Trigger | Why | Runs | Status | Findings | +|--------|---------|-----|------|--------|----------| +| CEO Review | \`/plan-ceo-review\` | Scope & strategy | 0 | — | — | +| Codex Review | \`/codex review\` | Independent 2nd opinion | 0 | — | — | +| Eng Review | \`/plan-eng-review\` | Architecture & tests (required) | 0 | — | — | +| Design Review | \`/plan-design-review\` | UI/UX gaps | 0 | — | — | + +**VERDICT:** NO REVIEWS YET — run \`/autoplan\` for full review pipeline, or individual reviews above. +\`\`\` + +**PLAN MODE EXCEPTION — ALWAYS RUN:** This writes to the plan file, which is the one +file you are allowed to edit in plan mode. The plan file review report is part of the +plan's living status. + +# /find-skills + +Find the best external marketplace skills for the user's current need. + +**HARD GATE:** Recommendation-only. Do NOT auto-install or auto-run third-party skills. + +## Workflow + +1. If the user already gave a clear query, use it. +2. If the query is vague, ask one AskUserQuestion to sharpen the technology/workflow target. +3. Extract 2-6 concrete technology keywords from the request. +4. Write the request to a temp file and run: + +```bash +TMP_QUERY=$(mktemp /tmp/gstack-marketplace-query-XXXX.txt) +cat > "$TMP_QUERY" <<'EOF' +[user query] +EOF +~/.claude/skills/gstack/bin/gstack-marketplace-search --query-file "$TMP_QUERY" --keyword "keyword-1" --keyword "keyword-2" --limit 5 --json +rm -f "$TMP_QUERY" +``` + +5. Present the top matches as: + - scoped name + - one-line why it matches + - install command + - source repo URL + +6. If no results exist, say so plainly and suggest refining the query. +7. If the marketplace CLI is unavailable, say so plainly and continue without error. + +## Output format + +Use this structure: + +```markdown +## External Skills Worth Considering + +1. `@scope/name` + Why: {1 sentence} + Install: `npx skills add @scope/name` + Source: {github url} +``` + +If gstack already has a strong built-in skill for the same need, say that first, then +present external skills as optional complements. diff --git a/find-skills/SKILL.md.tmpl b/find-skills/SKILL.md.tmpl new file mode 100644 index 000000000..3aff69ae7 --- /dev/null +++ b/find-skills/SKILL.md.tmpl @@ -0,0 +1,62 @@ +--- +name: find-skills +version: 1.0.0 +description: | + Find external agent skills from the Agent Skills / skills.sh marketplace for a given + technology or workflow query. Use when asked to "find a skill for X", "search skills + for supabase/vercel/azure/github cli", or "what external skill should I install". + Proactively suggest when the user asks for vendor-specific help that gstack does not + directly provide as a built-in workflow skill. +allowed-tools: + - Bash + - AskUserQuestion +--- + +{{PREAMBLE}} + +# /find-skills + +Find the best external marketplace skills for the user's current need. + +**HARD GATE:** Recommendation-only. Do NOT auto-install or auto-run third-party skills. + +## Workflow + +1. If the user already gave a clear query, use it. +2. If the query is vague, ask one AskUserQuestion to sharpen the technology/workflow target. +3. Extract 2-6 concrete technology keywords from the request. +4. Write the request to a temp file and run: + +```bash +TMP_QUERY=$(mktemp /tmp/gstack-marketplace-query-XXXX.txt) +cat > "$TMP_QUERY" <<'EOF' +[user query] +EOF +~/.claude/skills/gstack/bin/gstack-marketplace-search --query-file "$TMP_QUERY" --keyword "keyword-1" --keyword "keyword-2" --limit 5 --json +rm -f "$TMP_QUERY" +``` + +5. Present the top matches as: + - scoped name + - one-line why it matches + - install command + - source repo URL + +6. If no results exist, say so plainly and suggest refining the query. +7. If the marketplace CLI is unavailable, say so plainly and continue without error. + +## Output format + +Use this structure: + +```markdown +## External Skills Worth Considering + +1. `@scope/name` + Why: {1 sentence} + Install: `npx skills add @scope/name` + Source: {github url} +``` + +If gstack already has a strong built-in skill for the same need, say that first, then +present external skills as optional complements. diff --git a/office-hours/SKILL.md b/office-hours/SKILL.md index 998fd3f2a..51e35ea21 100644 --- a/office-hours/SKILL.md +++ b/office-hours/SKILL.md @@ -368,6 +368,36 @@ eval "$(~/.claude/skills/gstack/bin/gstack-slug 2>/dev/null)" Output: "Here's what I understand about this project and the area you want to change: ..." +## External Skill Marketplace Check + +If `PROACTIVE` is `"false"`, skip this step entirely. + +Use this step when the user's request or current plan/design context clearly names a +platform, vendor, framework, or tool that may already have a strong external skill in +the Agent Skills / skills.sh marketplace. + +1. Extract 2-6 concrete technology keywords from the user's request or current plan/design context. +2. Write the original request (or a short summary of the current plan/design) to a temp file: + +```bash +TMP_QUERY=$(mktemp /tmp/gstack-marketplace-query-XXXX.txt) +cat > "$TMP_QUERY" <<'EOF' +[original user request or current plan/design summary] +EOF +~/.claude/skills/gstack/bin/gstack-marketplace-search --query-file "$TMP_QUERY" --keyword "keyword-1" --keyword "keyword-2" --limit 3 --json +rm -f "$TMP_QUERY" +``` + +3. If the helper returns `"status": "ok"` with non-empty `results`, surface an + **External Skills Worth Considering** section with up to 3 results: + - scoped name + - one-line why it matches + - install command +4. Never auto-install or auto-run marketplace skills. This step is recommendation-only. +5. If the helper returns `unavailable` or no results, continue silently. +6. If a gstack built-in skill already covers the need well, prefer the gstack skill and + present the external result only as optional context. + --- ## Phase 2A: Startup Mode — YC Product Diagnostic diff --git a/office-hours/SKILL.md.tmpl b/office-hours/SKILL.md.tmpl index 55e916c9e..f5273467b 100644 --- a/office-hours/SKILL.md.tmpl +++ b/office-hours/SKILL.md.tmpl @@ -75,6 +75,8 @@ Understand the project and the area the user wants to change. Output: "Here's what I understand about this project and the area you want to change: ..." +{{MARKETPLACE_SKILL_DISCOVERY}} + --- ## Phase 2A: Startup Mode — YC Product Diagnostic diff --git a/plan-ceo-review/SKILL.md b/plan-ceo-review/SKILL.md index a6365fca5..5ccab633b 100644 --- a/plan-ceo-review/SKILL.md +++ b/plan-ceo-review/SKILL.md @@ -420,6 +420,36 @@ the handoff note to inform your analysis and avoid redundant questions. Tell the user: "Found a handoff note from your prior CEO review session. I'll use that context to pick up where we left off." +## External Skill Marketplace Check + +If `PROACTIVE` is `"false"`, skip this step entirely. + +Use this step when the user's request or current plan/design context clearly names a +platform, vendor, framework, or tool that may already have a strong external skill in +the Agent Skills / skills.sh marketplace. + +1. Extract 2-6 concrete technology keywords from the user's request or current plan/design context. +2. Write the original request (or a short summary of the current plan/design) to a temp file: + +```bash +TMP_QUERY=$(mktemp /tmp/gstack-marketplace-query-XXXX.txt) +cat > "$TMP_QUERY" <<'EOF' +[original user request or current plan/design summary] +EOF +~/.claude/skills/gstack/bin/gstack-marketplace-search --query-file "$TMP_QUERY" --keyword "keyword-1" --keyword "keyword-2" --limit 3 --json +rm -f "$TMP_QUERY" +``` + +3. If the helper returns `"status": "ok"` with non-empty `results`, surface an + **External Skills Worth Considering** section with up to 3 results: + - scoped name + - one-line why it matches + - install command +4. Never auto-install or auto-run marketplace skills. This step is recommendation-only. +5. If the helper returns `unavailable` or no results, continue silently. +6. If a gstack built-in skill already covers the need well, prefer the gstack skill and + present the external result only as optional context. + ## Prerequisite Skill Offer When the design doc check above prints "No design doc found," offer the prerequisite diff --git a/plan-ceo-review/SKILL.md.tmpl b/plan-ceo-review/SKILL.md.tmpl index 945fcaa6a..b200ab523 100644 --- a/plan-ceo-review/SKILL.md.tmpl +++ b/plan-ceo-review/SKILL.md.tmpl @@ -127,6 +127,8 @@ the handoff note to inform your analysis and avoid redundant questions. Tell the user: "Found a handoff note from your prior CEO review session. I'll use that context to pick up where we left off." +{{MARKETPLACE_SKILL_DISCOVERY}} + {{BENEFITS_FROM}} **Mid-session detection:** During Step 0A (Premise Challenge), if the user can't diff --git a/plan-design-review/SKILL.md b/plan-design-review/SKILL.md index e8d9fbbee..94089317d 100644 --- a/plan-design-review/SKILL.md +++ b/plan-design-review/SKILL.md @@ -400,6 +400,36 @@ Analyze the plan. If it involves NONE of: new UI screens/pages, changes to exist Report findings before proceeding to Step 0. +## External Skill Marketplace Check + +If `PROACTIVE` is `"false"`, skip this step entirely. + +Use this step when the user's request or current plan/design context clearly names a +platform, vendor, framework, or tool that may already have a strong external skill in +the Agent Skills / skills.sh marketplace. + +1. Extract 2-6 concrete technology keywords from the user's request or current plan/design context. +2. Write the original request (or a short summary of the current plan/design) to a temp file: + +```bash +TMP_QUERY=$(mktemp /tmp/gstack-marketplace-query-XXXX.txt) +cat > "$TMP_QUERY" <<'EOF' +[original user request or current plan/design summary] +EOF +~/.claude/skills/gstack/bin/gstack-marketplace-search --query-file "$TMP_QUERY" --keyword "keyword-1" --keyword "keyword-2" --limit 3 --json +rm -f "$TMP_QUERY" +``` + +3. If the helper returns `"status": "ok"` with non-empty `results`, surface an + **External Skills Worth Considering** section with up to 3 results: + - scoped name + - one-line why it matches + - install command +4. Never auto-install or auto-run marketplace skills. This step is recommendation-only. +5. If the helper returns `unavailable` or no results, continue silently. +6. If a gstack built-in skill already covers the need well, prefer the gstack skill and + present the external result only as optional context. + ## Step 0: Design Scope Assessment ### 0A. Initial Design Rating diff --git a/plan-design-review/SKILL.md.tmpl b/plan-design-review/SKILL.md.tmpl index 30e5b4141..3431730d6 100644 --- a/plan-design-review/SKILL.md.tmpl +++ b/plan-design-review/SKILL.md.tmpl @@ -107,6 +107,8 @@ Analyze the plan. If it involves NONE of: new UI screens/pages, changes to exist Report findings before proceeding to Step 0. +{{MARKETPLACE_SKILL_DISCOVERY}} + ## Step 0: Design Scope Assessment ### 0A. Initial Design Rating diff --git a/plan-eng-review/SKILL.md b/plan-eng-review/SKILL.md index 54d68fcc5..412956af2 100644 --- a/plan-eng-review/SKILL.md +++ b/plan-eng-review/SKILL.md @@ -351,6 +351,36 @@ DESIGN=$(ls -t ~/.gstack/projects/$SLUG/*-$BRANCH-design-*.md 2>/dev/null | head ``` If a design doc exists, read it. Use it as the source of truth for the problem statement, constraints, and chosen approach. If it has a `Supersedes:` field, note that this is a revised design — check the prior version for context on what changed and why. +## External Skill Marketplace Check + +If `PROACTIVE` is `"false"`, skip this step entirely. + +Use this step when the user's request or current plan/design context clearly names a +platform, vendor, framework, or tool that may already have a strong external skill in +the Agent Skills / skills.sh marketplace. + +1. Extract 2-6 concrete technology keywords from the user's request or current plan/design context. +2. Write the original request (or a short summary of the current plan/design) to a temp file: + +```bash +TMP_QUERY=$(mktemp /tmp/gstack-marketplace-query-XXXX.txt) +cat > "$TMP_QUERY" <<'EOF' +[original user request or current plan/design summary] +EOF +~/.claude/skills/gstack/bin/gstack-marketplace-search --query-file "$TMP_QUERY" --keyword "keyword-1" --keyword "keyword-2" --limit 3 --json +rm -f "$TMP_QUERY" +``` + +3. If the helper returns `"status": "ok"` with non-empty `results`, surface an + **External Skills Worth Considering** section with up to 3 results: + - scoped name + - one-line why it matches + - install command +4. Never auto-install or auto-run marketplace skills. This step is recommendation-only. +5. If the helper returns `unavailable` or no results, continue silently. +6. If a gstack built-in skill already covers the need well, prefer the gstack skill and + present the external result only as optional context. + ## Prerequisite Skill Offer When the design doc check above prints "No design doc found," offer the prerequisite diff --git a/plan-eng-review/SKILL.md.tmpl b/plan-eng-review/SKILL.md.tmpl index 44d64a0e8..895deb022 100644 --- a/plan-eng-review/SKILL.md.tmpl +++ b/plan-eng-review/SKILL.md.tmpl @@ -75,6 +75,8 @@ DESIGN=$(ls -t ~/.gstack/projects/$SLUG/*-$BRANCH-design-*.md 2>/dev/null | head ``` If a design doc exists, read it. Use it as the source of truth for the problem statement, constraints, and chosen approach. If it has a `Supersedes:` field, note that this is a revised design — check the prior version for context on what changed and why. +{{MARKETPLACE_SKILL_DISCOVERY}} + {{BENEFITS_FROM}} ### Step 0: Scope Challenge diff --git a/scripts/gen-skill-docs.ts b/scripts/gen-skill-docs.ts index 340dbb3ca..99cdee742 100644 --- a/scripts/gen-skill-docs.ts +++ b/scripts/gen-skill-docs.ts @@ -2797,9 +2797,42 @@ function generateSlugSetup(ctx: TemplateContext): string { return `eval "$(${ctx.paths.binDir}/gstack-slug 2>/dev/null)" && mkdir -p ~/.gstack/projects/$SLUG`; } +function generateMarketplaceSkillDiscovery(ctx: TemplateContext): string { + return `## External Skill Marketplace Check + +If \`PROACTIVE\` is \`"false"\`, skip this step entirely. + +Use this step when the user's request or current plan/design context clearly names a +platform, vendor, framework, or tool that may already have a strong external skill in +the Agent Skills / skills.sh marketplace. + +1. Extract 2-6 concrete technology keywords from the user's request or current plan/design context. +2. Write the original request (or a short summary of the current plan/design) to a temp file: + +\`\`\`bash +TMP_QUERY=$(mktemp /tmp/gstack-marketplace-query-XXXX.txt) +cat > "$TMP_QUERY" <<'EOF' +[original user request or current plan/design summary] +EOF +${ctx.paths.binDir}/gstack-marketplace-search --query-file "$TMP_QUERY" --keyword "keyword-1" --keyword "keyword-2" --limit 3 --json +rm -f "$TMP_QUERY" +\`\`\` + +3. If the helper returns \`"status": "ok"\` with non-empty \`results\`, surface an + **External Skills Worth Considering** section with up to 3 results: + - scoped name + - one-line why it matches + - install command +4. Never auto-install or auto-run marketplace skills. This step is recommendation-only. +5. If the helper returns \`unavailable\` or no results, continue silently. +6. If a gstack built-in skill already covers the need well, prefer the gstack skill and + present the external result only as optional context.`; +} + const RESOLVERS: Record string> = { SLUG_EVAL: generateSlugEval, SLUG_SETUP: generateSlugSetup, + MARKETPLACE_SKILL_DISCOVERY: generateMarketplaceSkillDiscovery, COMMAND_REFERENCE: generateCommandReference, SNAPSHOT_FLAGS: generateSnapshotFlags, PREAMBLE: generatePreamble, diff --git a/scripts/skill-check.ts b/scripts/skill-check.ts index 59f306c2c..62a13453d 100644 --- a/scripts/skill-check.ts +++ b/scripts/skill-check.ts @@ -27,6 +27,7 @@ const SKILL_FILES = [ 'plan-ceo-review/SKILL.md', 'plan-eng-review/SKILL.md', 'setup-browser-cookies/SKILL.md', + 'find-skills/SKILL.md', 'plan-design-review/SKILL.md', 'design-review/SKILL.md', 'gstack-upgrade/SKILL.md', diff --git a/test/marketplace-search.test.ts b/test/marketplace-search.test.ts new file mode 100644 index 000000000..742f6a7cc --- /dev/null +++ b/test/marketplace-search.test.ts @@ -0,0 +1,117 @@ +import { describe, test, expect } from "bun:test"; +import { mkdtempSync, writeFileSync, rmSync } from "fs"; +import { join } from "path"; +import { tmpdir } from "os"; +import { spawnSync } from "child_process"; +import { extractKeywords, parseMarketplaceOutput, rankSkills } from "../bin/gstack-marketplace-search.ts"; + +const scriptPath = join(import.meta.dir, "..", "bin", "gstack-marketplace-search.ts"); + +describe("gstack-marketplace-search", () => { + test("extractKeywords finds common platform terms", () => { + const keywords = extractKeywords("Build a Next.js app on Vercel with Supabase auth and GitHub CLI deploy scripts"); + expect(keywords).toContain("nextjs"); + expect(keywords).toContain("vercel"); + expect(keywords).toContain("supabase"); + expect(keywords).toContain("github cli"); + }); + + test("parseMarketplaceOutput strips prelude noise before JSON", () => { + const raw = `- Searching marketplace...\n{\"skills\":[{\"name\":\"supabase\",\"author\":\"supabase\",\"description\":\"Use Supabase\",\"stars\":100,\"forks\":10,\"githubUrl\":\"https://github.com/supabase/agent-skills/tree/main/skills/supabase\",\"scopedName\":\"@supabase/supabase\"}]}`; + const skills = parseMarketplaceOutput(raw); + expect(skills).toHaveLength(1); + expect(skills[0].scopedName).toBe("@supabase/supabase"); + }); + + test("rankSkills dedupes duplicate scoped names and prefers exact matches", () => { + const ranked = rankSkills([ + { + name: "supabase", + description: "Supabase auth and database", + author: "supabase", + stars: 100, + forks: 10, + githubUrl: "https://github.com/supabase/agent-skills/tree/main/skills/supabase", + scopedName: "@supabase/supabase", + query: { text: "supabase", source: "keyword" as const }, + }, + { + name: "postgres-patterns", + description: "Postgres optimization", + author: "someone", + stars: 1000, + forks: 10, + githubUrl: "https://github.com/someone/postgres-patterns", + scopedName: "@someone/postgres-patterns", + query: { text: "supabase", source: "full" as const }, + }, + { + name: "supabase", + description: "Duplicate entry", + author: "supabase", + stars: 90, + forks: 9, + githubUrl: "https://github.com/supabase/agent-skills/tree/main/skills/supabase", + scopedName: "@supabase/supabase", + query: { text: "vercel", source: "keyword" as const }, + }, + ], ["supabase", "vercel"], 5); + + expect(ranked).toHaveLength(2); + expect(ranked[0].scopedName).toBe("@supabase/supabase"); + expect(ranked[0].sourceQueries).toContain("supabase"); + expect(ranked[0].matchedKeywords).toContain("supabase"); + }); + + test("CLI mode returns normalized JSON from fixture input", () => { + const tempDir = mkdtempSync(join(tmpdir(), "gstack-marketplace-")); + const fixture = join(tempDir, "fixture.json"); + writeFileSync(fixture, `- Searching marketplace...\n${JSON.stringify({ + skills: [ + { + name: "nextjs-supabase-auth", + description: "Expert integration of Supabase Auth with Next.js", + author: "sickn33", + stars: 200, + forks: 50, + githubUrl: "https://github.com/sickn33/antigravity-awesome-skills/tree/main/skills/nextjs-supabase-auth", + scopedName: "@sickn33/nextjs-supabase-auth", + }, + { + name: "vercel-deploy", + description: "Deploy apps to Vercel", + author: "vercel", + stars: 150, + forks: 20, + githubUrl: "https://github.com/vercel/skills/tree/main/skills/vercel-deploy", + scopedName: "@vercel/vercel-deploy", + }, + ], + })}`); + + const result = spawnSync("bun", [ + "run", + scriptPath, + "--query", + "Build a Next.js app on Vercel with Supabase auth", + "--keyword", + "nextjs", + "--keyword", + "vercel", + "--keyword", + "supabase", + "--json", + ], { + env: { ...process.env, GSTACK_MARKETPLACE_FIXTURE: fixture }, + encoding: "utf-8", + timeout: 10000, + }); + + rmSync(tempDir, { recursive: true, force: true }); + expect(result.status).toBe(0); + const json = JSON.parse(result.stdout); + expect(json.status).toBe("ok"); + expect(json.results.length).toBeGreaterThan(0); + expect(json.results[0]).toHaveProperty("installCommand"); + }); +}); diff --git a/test/skill-validation.test.ts b/test/skill-validation.test.ts index c4bc99afe..89e09a0bf 100644 --- a/test/skill-validation.test.ts +++ b/test/skill-validation.test.ts @@ -546,6 +546,7 @@ describe('v0.4.1 preamble features', () => { 'SKILL.md', 'browse/SKILL.md', 'qa/SKILL.md', 'qa-only/SKILL.md', 'setup-browser-cookies/SKILL.md', + 'find-skills/SKILL.md', 'ship/SKILL.md', 'review/SKILL.md', 'plan-ceo-review/SKILL.md', 'plan-eng-review/SKILL.md', 'retro/SKILL.md', @@ -731,6 +732,43 @@ describe('investigate skill structure', () => { } }); +describe('find-skills skill structure', () => { + const content = fs.readFileSync(path.join(ROOT, 'find-skills', 'SKILL.md'), 'utf-8'); + + test('contains hard gate against auto-install', () => { + expect(content).toContain('HARD GATE'); + expect(content).toContain('Do NOT auto-install'); + }); + + test('uses marketplace search helper', () => { + expect(content).toContain('gstack-marketplace-search'); + }); + + test('contains external skills output section', () => { + expect(content).toContain('External Skills Worth Considering'); + expect(content).toContain('npx skills add'); + }); +}); + +describe('marketplace skill discovery integration', () => { + const marketplaceSkills = [ + 'office-hours/SKILL.md', + 'plan-ceo-review/SKILL.md', + 'plan-eng-review/SKILL.md', + 'plan-design-review/SKILL.md', + 'design-consultation/SKILL.md', + 'autoplan/SKILL.md', + ]; + + for (const skill of marketplaceSkills) { + test(`${skill} contains marketplace discovery block`, () => { + const content = fs.readFileSync(path.join(ROOT, skill), 'utf-8'); + expect(content).toContain('External Skill Marketplace Check'); + expect(content).toContain('gstack-marketplace-search'); + }); + } +}); + // --- Contributor mode preamble structure validation --- describe('Contributor mode preamble structure', () => { @@ -1398,6 +1436,7 @@ describe('Skill trigger phrases', () => { 'qa', 'qa-only', 'ship', 'review', 'investigate', 'office-hours', 'plan-ceo-review', 'plan-eng-review', 'plan-design-review', 'design-review', 'design-consultation', 'retro', 'document-release', + 'find-skills', 'codex', 'browse', 'setup-browser-cookies', ]; @@ -1418,6 +1457,7 @@ describe('Skill trigger phrases', () => { 'qa', 'qa-only', 'ship', 'review', 'investigate', 'office-hours', 'plan-ceo-review', 'plan-eng-review', 'plan-design-review', 'design-review', 'design-consultation', 'retro', 'document-release', + 'find-skills', ]; for (const skill of SKILLS_REQUIRING_PROACTIVE) {