plugin-test

plugin-test is a skill for Claude Code, Codex from zhinjs/zhin. It costs 51 tokens per session (857 once invoked), scanned A, original, MIT.

A testing guide for Zhin.js plugins using Vitest, a JavaScript and TypeScript testing framework. It focuses on checking command and tool behavior, ordinary business logic, and the plugin package’s required structure.

In plain words
What is it for?
Use it to write tests, increase coverage, verify command or agent-tool execution, test package exports and manifests, and run the project’s test or coverage commands.
Why use it?
It helps test the parts of a plugin directly without the cost of starting a complete bot. It also keeps tests aligned with the current Plugin Runtime instead of older lifecycle APIs.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Needs its repository: it reads a path above its own folder, which exists only inside the repository. The line is import hello from '../commands/hello/index.js';.

Good fit Use it to write tests, increase coverage, verify command or agent-tool execution, test package exports and manifests, and run the project’s test or coverage commands.

Compare 6 skills from other repositories ↓
Install

Getting it into your agent

It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.

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

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for plugin-test

README.md
[![agentmods](https://agentmods.dev/badge/skills/zhinjs/zhin/plugin-test/github.svg)](https://agentmods.dev/skills/zhinjs/zhin/plugin-test)
Your own site
<a href="https://agentmods.dev/skills/zhinjs/zhin/plugin-test"><img src="https://agentmods.dev/badge/skills/zhinjs/zhin/plugin-test/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for plugin-test

Your own site · 80×15
<a href="https://agentmods.dev/skills/zhinjs/zhin/plugin-test"><img src="https://agentmods.dev/badge/skills/zhinjs/zhin/plugin-test.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 51 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 857 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
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.1 $0.00051 $0.00857
Opus 5.5 $0.00020 $0.00343
Sonnet 5.5 $0.00010 $0.00171
Haiku 4.5 $0.00005 $0.00086

Measured 26d ago against content hash 28cefb879161, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

plugin-test 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 26d 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-test/SKILL.md · 107 lines

How it starts

The opening of the file, as written. The whole thing — 107 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Zhin 插件测试(Plugin Runtime)

为 Plugin Runtime 插件写 Vitest 测试。不要再测 new Plugin('/path') / usePlugin / MessageCommand 旧生命周期——CLI 路径是 zhin runtime start。

适用场景

  • 「帮我写测试」「增加覆盖率」「测试这个命令」
  • 新功能配套测试、发布前验证

环境

pnpm test
pnpm test:watch
pnpm test:coverage

全局 API 已注入(describe / it / expect / vi)。根 vitest.config.ts:globals: true,匹配 **/*.test.ts。

优先测什么

层级 测什么 怎么测
命令逻辑 defineCommand 的 execute 直接调用 definition,传入 mock params/args/input
工具逻辑 defineAgentTool 的 execute 同上,mock inputSchema 入参
纯函数 / 服务 业务模块 普通单元测,不碰 Runtime
装配契约 package zhin manifest、default export 轻量:import default 是 PluginDefinition

集成级「起完整 bot」成本高;优先单测 execute。需要端到端时用 examples/minimal-bot / Sandbox 手测,或仓库已有 Runtime 测试 helper(搜 definePlugin / PluginScope 相关测试)。

模板:命令 execute

import { describe, it, expect } from 'vitest';
import hello from '../commands/hello/index.js';

describe('commands/hello', () => {
  it('returns greeting', async () => {
    const result = await hello.execute({
      params: {},
      args: [],
      input: { $content: 'hello' },
      config: {},
    } as never);
    expect(result).toBe('Hello!');
  });
});

带参数的命令对 params.name 断言即可。

模板:工具 execute

import { describe, it, expect } from 'vitest';
import weather from '../tools/get_weather/index.js';

describe('tools/get_weather', () => {
  it('formats city weather', async () => {
    const text = await weather.execute({ city: '上海' }, {} as never);
    expect(text).toContain('上海');
  });
});

禁止

// ❌ 旧经典 Plugin 生命周期
import { Plugin } from '@zhin.js/core'
root = new Plugin('/test/root.ts')
plugin = new Plugin('/plugins/my-plugin/src/index.ts', root)

// ❌ 依赖 usePlugin / MessageCommand 的测试

验证清单

  • pnpm --filter <pkg> test 通过
  • 新命令/工具有至少一条正向用例
  • 边界(缺参、空串)按需求覆盖
  • 不引入对 zhin.js/node / bootstrapNode 的依赖

输出格式

## 测试摘要
- 覆盖:`commands/...` / `tools/...`
- 命令:`pnpm --filter <pkg> test`

Read the full file on GitHub · 107 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 26d ago Changed 28cefb879161
  2. 1mo ago First seen · 107 lines · 51 tokens per session scan A 06b03069c589

Subscribe to this mod's changes

plugin-test is a skill published in the GitHub repository zhinjs/zhin (136 stars, last pushed yesterday), licensed MIT. It adds 51 tokens to every session and 857 once invoked, about $0.0002 per session on Opus 5.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.