plugin-quality

A review guide for checking Zhin.js plugins before release. It covers plugin structure, feature declarations, resource cleanup, message sending, and security.

In plain words
What is it for?
Use it to audit an existing Zhin.js plugin, identify defects, or bring an older plugin into line with the current runtime.
Why use it?
It catches outdated APIs, incorrect file organisation, missing dependencies, lifecycle problems, and unsafe message handling before publication.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/zhinjs/zhin/plugin-quality
Any agent
npx skills add zhinjs/zhin --skill plugin-quality
Clone the repo
git clone --depth 1 https://github.com/zhinjs/zhin

Made for: Claude Code, Codex.

Per session 49 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 931 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00049 $0.00931
Opus 5 $0.00024 $0.00465
Sonnet 5 $0.00010 $0.00186
Haiku 4.5 $0.00005 $0.00093

Measured 2d ago against content hash 84f018dddb7a, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

plugin-quality scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

packages/toolkit/create-zhin/template/skills/plugin-quality/SKILL.md · 100 lines

What it actually says

Zhin 插件质量审查(Plugin Runtime)

对照 Plugin Runtime 审查插件:结构、约定目录、依赖方向、发送链与安全。发现仍用 usePlugin / MessageCommand 的新代码应标为缺陷并迁移。

适用场景

  • 「检查插件质量」「审查代码」「发布前看看有没有问题」
  • 重构现有插件使其符合 Runtime

审查维度

1. 结构规范性

项目 要求 严重程度
入口 plugin.ts default-export definePlugin() 🔴 严重
manifest package.json#zhin(protocol、entry、features) 🔴 严重
能力放置 约定目录 + default export;非业务堆在 plugin.ts 🔴 严重
旧 API 新代码无 usePlugin / getPlugin / MessageCommand 🔴 严重
导入路径 相对导入带 .js 🔴 严重
Feature 依赖 用到的能力已在 zhin.features 声明 🟡 中等
配置 自有字段在 schema.json,经 context.config 读取 🟡 中等

常见错误:

// ❌ 经典插件 API(Runtime 下不工作)
import { usePlugin, MessageCommand } from 'zhin.js'
const plugin = usePlugin()
plugin.addCommand(new MessageCommand('hi').action(() => 'hi'))

// ✅ Runtime
import { definePlugin } from 'zhin.js'
export default definePlugin({ name: 'my-plugin', setup() {} })
// + commands/hi.ts → defineCommand(...)

2. 生命周期与资源

  • 清理走 context.lifecycle.addsetup 返回 disposer
  • 共享连接/DB 用 context.resources.provide,禁止裸模块级单例或 createGenerationStore
  • Host token 先 hasuse(精简安装下可选)

3. 发送与安全

  • 出站不绕过 Message.$reply / Adapter.sendMessagebefore.sendMessage
  • 密钥只走环境变量 / ${VAR} 配置引用
  • AI 工具副作用边界清晰;危险操作有策略/确认

4. 测试与文档

  • 至少覆盖核心 execute 路径
  • README 写明命令触发方式与 Feature 依赖
  • agent/ 的包检查 files / prepublishOnlypnpm check:plugin-agent-publish

审查流程

  1. package.json#zhin + plugin.ts
  2. commands/ / tools/ / middlewares/ 是否 default export 正确 API
  3. ripgrep:usePlugin|MessageCommand|getPlugin|bootstrapNode
  4. pnpm --filter <pkg> test(及需要的 harness)
  5. 输出问题清单(严重度 + 建议修复)

输出格式

## 结论
- 是否可发布:是 / 否

## 问题
| 严重度 | 位置 | 问题 | 建议 |
|--------|------|------|------|
| 🔴 | ... | ... | ... |

## 已通过
- definePlugin 入口 / 约定目录 / 发送链 …

迁移

旧插件迁 Runtime:.github/skills/migrate-zhin-plugin-runtime

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 100 lines · 49 tokens per session scan A 84f018dddb7a

Subscribe to this mod's changes

plugin-quality is a skill published in the GitHub repository zhinjs/zhin (135 stars, last pushed 5d ago), licensed MIT. It adds 49 tokens to every session and 931 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.