create-plugin
它能做什么
这个技能指导智能体为 OpenCode 编程工具构建插件。适合希望为 OpenCode 添加自定义工具或行为的开发者。
适用场景
- ✓你想为 OpenCode 添加一个自定义工具的时候。
- ✓你要求智能体为 OpenCode 编写或制作插件的时候。
- ✓你想用挂接其事件的新行为来扩展 OpenCode 的时候。
技能链接
https://github.com/Devin-AXIS/iPolloWork/blob/main/.opencode/skills/create-plugin/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请为 OpenCode 制作一个插件,添加一个用于检查我项目中文件大小的工具。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会使用标准的插件结构:一个返回工具和钩子的异步函数,并用 zod 编写输入规则。它会把文件放到正确的插件文件夹中。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Skill: Create an OpenCode Plugin
Scaffold a working OpenCode plugin for use in iPolloWork.
When to use
- User asks "create a plugin that does X"
- User asks "write a plugin" or "make a plugin"
- User wants to extend iPolloWork/OpenCode with custom tools
Plugin API
An OpenCode plugin is an async factory function that returns a hooks object.
File location
Plugins can live in:
- Project:
.opencode/plugins/my-plugin.ts(auto-discovered) - Global:
~/.config/opencode/plugins/my-plugin.ts - npm: published as a package, referenced in
opencode.jsonpluginarray - URL:
file:orhttps:path in thepluginarray
Minimal shape
import { z } from "zod";
export default async () => ({
tool: {
my_tool_name: {
description: "What this tool does.",
args: z.object({
input: z.string().describe("The input parameter."),
}).shape, // NOTE: .shape, not the ZodObject itself
async execute(args: { input: string }) {
// Your logic here. Can use fetch(), fs, child_process, etc.
return `Result: ${args.input}`;
},
},
},
});
Key rules
- Export default an async function that returns the hooks object.
- Tool args use
zodSchema.shape(aZodRawShape), not theZodObject. executereturns astringor{ output: string; metadata?: Record<string, unknown> }.- Tools are declared, not registered imperatively — return them in the hooks object.
fetch()works — plugins run in-process inside the OpenCode runtime.process.envis accessible — use env vars for secrets/config.
Available hooks
{
// Modify the system prompt
"experimental.chat.system.transform": async (input, output: { system: string[] }) => {
output.system.push("Extra instruction for the agent.");
},
// Define tools the agent can call
tool: {
tool_name: { description, args, execute },
},
// Run code before/after a tool executes
"tool.execute.before": async ({ tool, args }) => { /* ... */ },
"tool.execute.after": async ({ tool, args, result }) => { /* ... */ },
// React to lifecycle events
event: async ({ event }) => { /* ... */ },
}
Registering the plugin
Add to opencode.json:
{
"plugin": [
".opencode/plugins/my-plugin.ts"
]
}
Or install from npm:
{
"plugin": [
"my-published-plugin"
]
}
Anthropic / Claude plugin compatibility
OpenCode plugins are NOT the same as Anthropic's plugin format. Key differences:
| Aspect | OpenCode Plugin | Anthropic Plugin |
|---|---|---|
| Entry point | Async factory function | Manifest JSON |
| Tool args | Zod schema .shape |
JSON Schema |
| Runtime | In-process (Bun/Node) | Sandboxed container |
| Auth | process.env |
OAuth/API key in manifest |
| Distribution | npm / file path / URL | Anthropic marketplace |
To adapt an Anthropic plugin for OpenCode:
- Rewrite the tool definitions using Zod instead of JSON Schema.
- Move any auth from the manifest to env vars or
opencode.jsonprovider config. - Export the async factory function instead of the manifest.
- HTTP-based Anthropic plugins can often be wrapped as MCP servers instead.
Example: plugin with multiple tools
import { z } from "zod";
export default async () => ({
"experimental.chat.system.transform": async (_input: unknown, output: { system: string[] }) => {
output.system.push("You have access to a note-taking system. Use save_note and list_notes.");
},
tool: {
save_note: {
description: "Save a note with a title and body.",
args: z.object({
title: z.string().describe("Note title"),
body: z.string().describe("Note content"),
}).shape,
async execute(args: { title: string; body: string }) {
const fs = await import("node:fs/promises");
const path = `.opencode/notes/${args.title.replace(/[^a-zA-Z0-9-_]/g, "_")}.md`;
await fs.mkdir(".opencode/notes", { recursive: true });
await fs.writeFile(path, `# ${args.title}\n\n${args.body}\n`);
return `Saved note: ${path}`;
},
},
list_notes: {
description: "List all saved notes.",
args: {},
async execute() {
const fs = await import("node:fs/promises");
try {
const files = await fs.readdir(".opencode/notes");
return files.filter(f => f.endsWith(".md")
常见问题
插件文件应该放在哪里?
可以放在项目的插件文件夹中、全局配置文件夹中,或作为软件包分享。
我需要懂 TypeScript 吗?
示例使用 TypeScript,因此有一定了解会有帮助。智能体会为你编写大部分代码。
工具会返回什么?
工具的 execute 步骤会返回文本结果,或包含输出和可选细节的对象。
详情
作者的原始描述
Create an OpenCode plugin for iPolloWork. Scaffolds the plugin file with the correct API shape, tool definitions, and hook registration. Use when the user asks to 'create a plugin', 'write a plugin', or 'make a plugin that does X'.
repo: Devin-AXIS/iPolloWork
热度
- GitHub 星标
- 7.4k
- 排名
- #13287
- 许可证
- —
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
image-editing
7.4k帮你的智能体编辑现有图片中你选定的部分,保持画面其余部分不变,并将结果保存为新文件。
image-generation
7.4k帮你的智能体通过 iPolloWork 图像服务创建新图片,用于所需画面,或设计中的辅助视觉素材。
ipollowork-design-editorial
7.4k帮你的智能体在你的 iPolloWork 设计项目中创建或编辑文章和报告,保持你的风格令牌和版式不变。
ipollowork-design-graphics
7.4k帮你的智能体在你的 iPolloWork 设计会话中创建或编辑海报和社交卡片系列,保持卡片风格一致。