Token导航 LogoToken导航TokenDH.com
研究检索执行命令github未标认证来源可访问clear审计未展示

writing-plugins编写插件

Agent Skill

用于辅助文档、README、Markdown、说明文和内容稿件的整理与改写。它适合让 Agent 提炼结构、补齐章节、统一术语、检查链接或把零散材料整理成可读文档。使用时应保留项目已有事实、命令和路径,不要把未确认的信息写成确定结论;涉及对外文案时,还需要控制语气,避免过度营销或夸大能力。

总安装

250

周安装

10

GitHub Stars

公开资料未说明

下载量

81
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:writing-plugins(编写插件)
来源仓库:https://github.com/ian-pascoe/dotfiles
仓库路径:skills/writing-plugins
安装命令:
npx skills add ian-pascoe/dotfiles --skill "writing-plugins"
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

AgentSkills.tonpx skills
npx skills add ian-pascoe/dotfiles --skill "writing-plugins"

简介

辅助文档、README 和内容稿件的整理与改写,提升可读性。

  • 帮助 Agent 提炼结构、统一术语并检查链接有效性。
  • 通过 github 安装,建议核对原始文档了解具体用法。
  • 使用时应保留项目既有事实,避免将推测写成确定结论。
  • writing-plugins 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

name
writing-plugins
description
Use when creating, editing, or reviewing OpenCode plugins. Covers plugin structure, event hooks, TypeScript typing, custom tools, dependency management, and common patterns like notifications and compaction hooks.

Writing Plugins

Overview

Plugins extend OpenCode by hooking into events and customizing behavior. They're JavaScript/TypeScript modules that export functions receiving a context object and returning hooks.

When to Use

  • Creating event-driven automation (notifications, logging, protection)
  • Adding custom tools to OpenCode
  • Modifying tool behavior before/after execution
  • Customizing session compaction behavior
  • Integrating with external services

Don't use for: simple prompts (use commands), static configuration (use config), or agent behavior (use agents).

File Locations

.opencode/plugin/<name>.js|ts       # Project-local
~/.config/opencode/plugin/<name>.js|ts  # Global/personal

Or via npm in opencode.json:

{
  "plugin": ["opencode-helicone-session", "@my-org/custom-plugin"]
}

Load Order

  1. Global config (~/.config/opencode/opencode.json)
  2. Project config (opencode.json)
  3. Global plugin directory (~/.config/opencode/plugin/)
  4. Project plugin directory (.opencode/plugin/)

Basic Structure

import type { Plugin } from "@opencode-ai/plugin";

export const MyPlugin: Plugin = async ({
  project,
  client,
  $,
  directory,
  worktree,
}) => {
  // Initialization code here

  return {
    // Hook implementations
  };
};

Context Object

PropertyDescription
projectCurrent project information
directoryCurrent working directory
worktreeGit worktree path
clientOpenCode SDK client for AI interaction
$Bun's shell API for executing commands

Event Hooks

Event Categories

CategoryEvents
Sessionsession.created, session.idle, session.compacted, session.deleted, session.error, session.status, session.updated, session.diff
Tooltool.execute.before, tool.execute.after
Messagemessage.updated, message.removed, message.part.updated, message.part.removed
Filefile.edited, file.watcher.updated
Permissionpermission.updated, permission.replied
TUItui.prompt.append, tui.command.execute, tui.toast.show
LSPlsp.client.diagnostics, lsp.updated
Othercommand.executed, installation.updated, server.connected, todo.updated

Hook Patterns

// Event subscription
return {
  event: async ({ event }) => {
    if (event.type === "session.idle") {
      // Handle event
    }
  },
};

// Tool interception
return {
  "tool.execute.before": async (input, output) => {
    // Modify or block tool execution
  },
  "tool.execute.after": async (input, output) => {
    // React to tool completion
  },
};

Custom Tools

import { type Plugin, tool } from "@opencode-ai/plugin";

export const CustomToolsPlugin: Plugin = async (ctx) => {
  return {
    tool: {
      mytool: tool({
        description: "This is a custom tool",
        args: {
          foo: tool.schema.string(),
        },
        async execute(args, ctx) {
          return `Hello ${args.foo}!`;
        },
      }),
    },
  };
};

Dependencies

Add external packages via .opencode/package.json:

{
  "dependencies": {
    "shescape": "^2.1.0"
  }
}

OpenCode runs bun install at startup. npm plugins are cached in ~/.cache/opencode/node_modules/.

Quick Reference

PatternExample Use Case
event handlerNotifications on session.idle
tool.execute.beforeBlock .env reads, sanitize commands
tool.execute.afterLog tool usage, track metrics
tool definitionAdd domain-specific tools
experimental.session.compactingCustom compaction context

Common Patterns

Notification on Completion

return {
  event: async ({ event }) => {
    if (event.type === "session.idle") {
      await $`osascript -e 'display notification "Done!" with title "opencode"'`;
    }
  },
};

Tool Protection

return {
  "tool.execute.before": async (input, output) => {
    if (input.tool === "read" && output.args.filePath.includes(".env")) {
      throw new Error("Do not read .env files");
    }
  },
};

Structured Logging

await client.app.log({
  service: "my-plugin",
  level: "info", // debug, info, warn, error
  message: "Plugin initialized",
  extra: { foo: "bar" },
});

Compaction Context

return {
  "experimental.session.compacting": async (input, output) => {
    // Add context (appended to default prompt)
    output.context.push(`## Custom Context\n...`);

    // OR replace entire prompt
    output.prompt = `Your custom compaction prompt...`;
  },
};

Common Mistakes

MistakeFix
Using console.logUse client.app.log() for structured logging
Missing TypeScript typesImport Plugin from @opencode-ai/plugin
Throwing in hooks without intentThrow to block, return to allow
Forgetting async on handlersAll hooks should be async functions
Local deps without package.jsonAdd .opencode/package.json for npm packages

Validation Checklist

  • [ ] Plugin exports named function (not default)
  • [ ] Function is async and returns hooks object
  • [ ] TypeScript uses Plugin type import
  • [ ] Event types checked before handling
  • [ ] External deps listed in package.json
  • [ ] Uses client.app.log() not console.log
  • [ ] Tool definitions have description and args schema

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

OpenCode

30.21%
按下载量换算24

Claude Code

23.3%
按下载量换算19

windsurf

17.28%
按下载量换算14

Codex

11.58%
按下载量换算9

Antigravity

8.67%
按下载量换算7

Gemini CLI

3.36%
按下载量换算3

安全审计

暂无安全审计结果可展示。

权限和风险

执行命令

安装流程涉及命令执行,可能通过 npx skills add ian-pascoe/dotfiles --skill "writing-plugins" 联网下载 Skill 或依赖。用户安装前应确认命令来源、仓库内容和执行环境。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills