agents/create-opencode-plugin/.opencode/skill/create-opencode-plugin/SKILL.md
Create OpenCode plugins using the @opencode-ai/plugin SDK. Use for building custom tools, event hooks, auth providers, or tool execution interception. Use proactively when developing new plugins in .opencode/plugin/ or ~/.config/opencode/plugin/. Examples: - user: "Create a plugin to block dangerous commands" → implement tool execution before hook with blocking logic - user: "Add a custom tool for jira" → design tool schema and implementation using SDK context - user: "Show toast on file edit" → react to file edit events and display status message - user: "Build a custom auth provider" → implement auth flow for new model provider - user: "Intercept git commits" → add hook to validate commit messages before execution
npx skillsauth add igorwarzocha/opencode-workflows create-opencode-pluginInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
| Step | Action | Read |
| ---- | -------------------- | ------------------------------------------------------------------------------- |
| 1 | Verify SDK reference | Run extract script |
| 2 | Validate feasibility | This file |
| 3 | Design plugin | references/hooks.md, references/hook-patterns.md, references/CODING-TS.MD |
| 4 | Implement | references/tool-helper.md (if custom tools) |
| 5 | Add UI feedback | references/toast-notifications.md, references/ui-feedback.md (if needed) |
| 6 | Test | references/testing.md |
| 7 | Publish | references/publishing.md, references/update-notifications.md (if npm) |
Before creating any plugin, MUST regenerate the API reference to ensure accuracy:
bun run .opencode/skill/create-opencode-plugin/scripts/extract-plugin-api.ts
This generates:
references/hooks.md - All available hooks and signaturesreferences/events.md - All event types and propertiesreferences/tool-helper.md - Tool creation patternsMUST determine if the user's concept is achievable with available hooks.
If not feasible, MUST inform user clearly. Suggest:
packages/opencodeREAD: references/hooks.md for available hooks, references/hook-patterns.md for implementation patterns.
READ: references/CODING-TS.MD for code architecture principles. MUST follow these design guidelines:
index.ts file| Scope | Path | Use Case |
| ------- | ------------------------------------------- | -------------------------- |
| Project | .opencode/plugin/<name>/index.ts | Team-shared, repo-specific |
| Global | ~/.config/opencode/plugin/<name>/index.ts | Personal, all projects |
import type { Plugin } from "@opencode-ai/plugin"
export const MyPlugin: Plugin = async ({ project, client, $, directory, worktree }) => {
// Setup code runs once on load
return {
// Hook implementations - see references/hook-patterns.md
}
}
| Parameter | Type | Description |
| ----------- | ---------- | ----------------------------------------- |
| project | Project | Current project info (id, worktree, name) |
| client | SDK Client | OpenCode API client |
| $ | BunShell | Bun shell for commands |
| directory | string | Current working directory |
| worktree | string | Git worktree path |
READ: references/hook-patterns.md for hook implementation examples.
READ: references/tool-helper.md if adding custom tools (Zod schemas).
READ: references/events.md if using event hook (event types/properties).
READ: references/examples.md for complete plugin examples.
ALWAYS READ: references/CODING-TS.MD and follow modular design principles.
For complex plugins, MUST use a modular directory structure:
.opencode/plugin/my-plugin/
├── index.ts # Entry point, exports Plugin
├── types.ts # TypeScript types/interfaces
├── utils.ts # Shared utilities
├── hooks/ # Hook implementations
│ ├── event.ts
│ └── tool-execute.ts
└── tools/ # Custom tool definitions
└── my-tool.ts
Example modular index.ts:
import type { Plugin } from "@opencode-ai/plugin"
import { eventHooks } from "./hooks/event"
import { toolHooks } from "./hooks/tool-execute"
import { customTools } from "./tools"
export const MyPlugin: Plugin = async ({ project, client }) => {
return {
...eventHooks({ client }),
...toolHooks({ client }),
tool: customTools,
}
}
Keep each file under 150 lines. Split as complexity grows.
| Mistake | Fix |
| ----------------------------- | --------------------------------------------------- |
| Using client.registerTool() | Use tool: { name: tool({...}) } |
| Wrong event property names | Check references/events.md |
| Sync event handler | MUST use async |
| Not throwing to block | throw new Error() in tool.execute.before |
| Forgetting TypeScript types | import type { Plugin } from "@opencode-ai/plugin" |
Only if plugin needs user-visible notifications:
READ: references/toast-notifications.md for transient alerts (brief popups)
READ: references/ui-feedback.md for persistent inline status messages
Choose based on:
| Need | Use | | ---------------------------- | -------------- | | Brief alerts, warnings | Toast | | Detailed stats, multi-line | Inline message | | Config validation errors | Toast | | Session completion notice | Toast or inline|
READ: references/testing.md for full testing procedure.
Create test folder with opencode.json:
{
"plugin": ["file:///path/to/your/plugin/index.ts"],
}
Verify plugin loads:
cd /path/to/test-folder
opencode run hi
Test interactively:
opencode
SHOULD recommend specific tests based on hook type used.
READ: references/publishing.md for npm publishing.
READ: references/update-notifications.md for version update toasts (for users with pinned versions).
<reference_summary>
| File | Purpose | When to Read |
| ------------------------- | --------------------------------- | ------------------------- |
| hooks.md | Hook signatures (auto-generated) | Step 3-4 |
| events.md | Event types (auto-generated) | Step 4 (if using events) |
| tool-helper.md | Zod tool schemas (auto-generated) | Step 4 (if custom tools) |
| hook-patterns.md | Hook implementation examples | Step 3-4 |
| CODING-TS.MD | Code architecture principles | Step 3 (Design) |
| examples.md | Complete plugin examples | Step 4 |
| toast-notifications.md | Toast popup API | Step 5 (if toasts needed) |
| ui-feedback.md | Inline message API | Step 5 (if inline needed) |
| testing.md | Testing procedure | Step 6 |
| publishing.md | npm publishing | Step 7 |
| update-notifications.md | Version toast pattern | Step 7 (for npm plugins) |
</reference_summary>
development
Handle structured co-authoring of professional documentation. Use for proposals, technical specs, and RFCs. Use proactively when a collaborative drafting process (Gathering -> Refinement -> Testing) is needed. Examples: - user: "Draft a technical RFC for the new API" -> follow Stage 1 context gathering - user: "Refine the introduction of this proposal" -> use iterative surgical edits - user: "Test if this document is clear for readers" -> run reader testing workflow
development
Handle Word document (.docx) creation, editing, and analysis with high-fidelity visual review. Use for professional reports, legal documents, and tracked changes. Use proactively when quality and precise formatting are critical. Examples: - user: "Create a professional report in Word" -> use python-docx with render loops - user: "Draft a legal contract with redlines" -> use ooxml redlining workflow - user: "Extract text from this DOCX while preserving structure" -> use pandoc markdown conversion
testing
Apply professional visual themes to documents and presentations. Use for styling artifacts with consistent color palettes and font pairings. Use proactively to quickly improve the aesthetic quality of deliverables. Examples: - user: "Apply a modern theme to this deck" -> use Modern Minimalist theme - user: "I want a tech aesthetic for this doc" -> apply Tech Innovation theme - user: "Create a custom theme for my project" -> generate new color/font specification
tools
Guide for creating effective opencode skills. Use for creating or updating skills that extend agent capabilities with specialized knowledge, workflows, or tool integrations. Examples: - user: "Create a skill for git workflows" → define SKILL.md with instructions and examples - user: "Add examples to my skill" → follow the user: "query" → action pattern - user: "Update skill description" → use literal block scalar and trigger contexts - user: "Structure a complex skill" → organize with scripts/ and references/ directories - user: "Validate my skill" → check structure, frontmatter, and discovery triggers