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.
git clone --depth 1 https://github.com/zhinjs/zhinnpx agentmods add skills/zhinjs/zhin/plugin-testWrote 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.
[](https://agentmods.dev/skills/zhinjs/zhin/plugin-test)<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.
<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>- NVIDIA SkillSpector pass
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.
| Model | Per session | Once 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 |
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.
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`
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.
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.
- 26d ago Changed 28cefb879161
- 1mo ago First seen · 107 lines · 51 tokens per session scan A 06b03069c589
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.
Other skills, from other repositories
test-generator
A skill for creating unit tests, generating mock data or objects, and analysing test coverage. Unit tests check small parts of a program in isolation.
Code Coverage Analysis
Measure and enforce test coverage with Istanbul/nyc, c8, Jest, and Vitest. Covers branch versus line coverage, per-directory thresholds, CI gates, and correctly excluding generated code from reports.
coding
Use when five specialized coding agents (linter, perf, refactor, security, test) that enforce quality gates across the development lifecycle. From lint enforcement through performance profiling, refactoring, security auditing, and test coverage. Use when working with coding agents.
csharp-xunit
Your goal is to help me write effective unit tests with XUnit, covering both standard and data-driven testing approaches.
java-junit
JUnit 5 testing patterns and parameterized-test guidance. Use when writing or reviewing Java unit tests.
test-data-generator
Creates test fixtures, mock data, and test scenarios for unit and integration tests. Use when setting up test data, creating mocks, or generating test fixtures.