Agent Skillsgsd-build/gsd-2 › create-gsd-extension

create-gsd-extension

GitHub

用于创建、调试和迭代 GSD 扩展(TypeScript 模块),支持添加工具、命令、事件钩子及自定义 UI。适用于构建插件或修改 GSD 行为。

src/resources/skills/create-gsd-extension/SKILL.md gsd-build/gsd-2

Trigger Scenarios

create extension build extension add a tool register command hook into gsd custom tool gsd plugin gsd extension

Install

npx skills add gsd-build/gsd-2 --skill create-gsd-extension -g -y
More Options

Non-standard path

npx skills add https://github.com/gsd-build/gsd-2/tree/main/src/resources/skills/create-gsd-extension -g -y

Use without installing

npx skills use gsd-build/gsd-2@create-gsd-extension

指定 Agent (Claude Code)

npx skills add gsd-build/gsd-2 --skill create-gsd-extension -a claude-code -g -y

安装 repo 全部 skill

npx skills add gsd-build/gsd-2 --all -g -y

预览 repo 内 skill

npx skills add gsd-build/gsd-2 --list

SKILL.md

Frontmatter
{
    "name": "create-gsd-extension",
    "description": "Create, debug, and iterate on GSD extensions (TypeScript modules that add tools, commands, event hooks, custom UI, and providers to GSD). Use when asked to build an extension, add a tool the LLM can call, register a slash command, hook into GSD events, create custom TUI components, or modify GSD behavior. Triggers on \"create extension\", \"build extension\", \"add a tool\", \"register command\", \"hook into gsd\", \"custom tool\", \"gsd plugin\", \"gsd extension\"."
}

<essential_principles>

Extensions are TypeScript modules that hook into GSD's runtime (built on pi). They export a default function receiving ExtensionAPI and use it to subscribe to events, register tools/commands/shortcuts, and interact with the session.

GSD extension paths (community/user-installed extensions):

  • Global: ~/.pi/agent/extensions/*.ts or ~/.pi/agent/extensions/*/index.ts
  • Project-local: .gsd/extensions/*.ts or .gsd/extensions/*/index.ts

Note: ~/.gsd/agent/extensions/ is reserved for bundled extensions synced from the gsd-pi package. Community extensions placed there are silently ignored by the loader.

The three primitives:

  1. Events — Listen and react (pi.on("event", handler)). Can block tool calls, modify messages, inject context.
  2. Tools — Give the LLM new abilities (pi.registerTool()). LLM calls them autonomously.
  3. Commands — Give users slash commands (pi.registerCommand()). Users type /mycommand.

Non-negotiable rules:

  • Use StringEnum from @gsd/pi-ai for string enum params (NOT Type.Union/Type.Literal — breaks Google's API)
  • Truncate tool output to 50KB / 2000 lines max (use truncateHead/truncateTail from @gsd/pi-coding-agent)
  • Store stateful tool state in details for branching support
  • Check signal?.aborted in long-running tool executions
  • Use pi.exec() not child_process for shell commands
  • Check ctx.hasUI before dialog methods (non-interactive modes exist)
  • Session control methods (waitForIdle, newSession, fork, navigateTree, reload) are ONLY available in command handlers — they deadlock in event handlers
  • Lines from render() must not exceed width — use truncateToWidth()
  • Use theme from callback params, never import directly
  • Strip leading @ from path params in custom tools (some models add it)

Available imports:

Package Purpose
@gsd/pi-coding-agent ExtensionAPI, ExtensionContext, Theme, event types, tool utilities, DynamicBorder, BorderedLoader, CustomEditor, highlightCode
@sinclair/typebox Type.Object, Type.String, Type.Number, Type.Optional, Type.Boolean, Type.Array
@gsd/pi-ai StringEnum (required for string enums), Type re-export
@gsd/pi-tui Text, Box, Container, Spacer, Markdown, SelectList, Input, matchesKey, Key, truncateToWidth, visibleWidth
Node.js built-ins node:fs, node:path, node:child_process, etc.

</essential_principles>

Based on user intent, route to the appropriate workflow:

Building a new extension:

  • "Create an extension", "build a tool", "I want to add a command" → workflows/create-extension.md

Adding capabilities to an existing extension:

  • "Add a tool to my extension", "add event hook", "add custom rendering" → workflows/add-capability.md

Debugging an extension:

  • "My extension doesn't work", "tool not showing up", "event not firing" → workflows/debug-extension.md

If user intent is clear from context, skip the question and go directly to the workflow.

<reference_index> All domain knowledge in references/:

Core architecture: extension-lifecycle.md, events-reference.md API surface: extensionapi-reference.md, extensioncontext-reference.md Capabilities: custom-tools.md, custom-commands.md, custom-ui.md, custom-rendering.md Patterns: state-management.md, system-prompt-modification.md, compaction-session-control.md Infrastructure: model-provider-management.md, remote-execution-overrides.md, packaging-distribution.md, mode-behavior.md Spec: docs/extension-sdk/manifest-spec.md — manifest format, tiers, validation Testing: docs/extension-sdk/testing.md — mock patterns, test conventions SDK: docs/extension-sdk/ — the authoritative GSD-2 extension guide Gotchas: key-rules-gotchas.md </reference_index>

<workflows_index>

Workflow Purpose
create-extension.md Build a new extension from scratch
add-capability.md Add tools, commands, hooks, UI to an existing extension
debug-extension.md Diagnose and fix extension issues
</workflows_index>

<success_criteria> Extension is complete when:

  • extension-manifest.json exists with accurate provides listing all registered tools/commands/hooks/shortcuts
  • TypeScript compiles without errors (jiti handles this at runtime)
  • Extension loads on GSD startup or /reload without errors
  • Tools appear in the LLM's system prompt and are callable
  • Commands respond to /command input
  • Event hooks fire at the expected lifecycle points
  • Custom UI renders correctly within terminal width
  • State persists correctly across session restarts (if stateful)
  • Output is truncated to safe limits (if tools produce variable output) </success_criteria>

Version History

  • 33c00aa Current 2026-07-25 10:22

Same Skill Collection

gsd-orchestrator/SKILL.md
src/resources/skills/accessibility/SKILL.md
src/resources/skills/agent-browser/SKILL.md
src/resources/skills/api-design/SKILL.md
src/resources/skills/best-practices/SKILL.md
src/resources/skills/btw/SKILL.md
src/resources/skills/core-web-vitals/SKILL.md
src/resources/skills/create-mcp-server/SKILL.md
src/resources/skills/create-skill/SKILL.md
src/resources/skills/create-workflow/SKILL.md
src/resources/skills/debug-like-expert/SKILL.md
src/resources/skills/decompose-into-slices/SKILL.md
src/resources/skills/dependency-upgrade/SKILL.md
src/resources/skills/design-an-interface/SKILL.md
src/resources/skills/frontend-design/SKILL.md
src/resources/skills/github-workflows/SKILL.md
src/resources/skills/grill-me/SKILL.md
src/resources/skills/handoff/SKILL.md
src/resources/skills/lint/SKILL.md
src/resources/skills/make-interfaces-feel-better/SKILL.md
src/resources/skills/react-best-practices/SKILL.md
src/resources/skills/review/SKILL.md
src/resources/skills/tdd/SKILL.md
src/resources/skills/test/SKILL.md
src/resources/skills/userinterface-wiki/SKILL.md
src/resources/skills/verify-before-complete/SKILL.md
src/resources/skills/web-design-guidelines/SKILL.md
src/resources/skills/web-quality-audit/SKILL.md
src/resources/skills/write-docs/SKILL.md
src/resources/skills/write-milestone-brief/SKILL.md
src/resources/skills/code-optimizer/SKILL.md
src/resources/skills/forensics/SKILL.md
src/resources/skills/observability/SKILL.md
src/resources/skills/security-review/SKILL.md
src/resources/skills/spike-wrap-up/SKILL.md

Metadata

Files
0
Version
33c00aa
Hash
71102db8
Indexed
2026-07-25 10:22

- 위키
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-21 06:36
浙ICP备14020137号-1 $방문자$