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.
npx skills add s977043/river-review --skill vitest-mock-isolationgit clone --depth 1 https://github.com/s977043/river-reviewWrote 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/s977043/river-review/vitest-mock-isolation)<a href="https://agentmods.dev/skills/s977043/river-review/vitest-mock-isolation"><img src="https://agentmods.dev/badge/skills/s977043/river-review/vitest-mock-isolation/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/s977043/river-review/vitest-mock-isolation"><img src="https://agentmods.dev/badge/skills/s977043/river-review/vitest-mock-isolation.svg" alt="Reviewed on agentmods" width="80" height="20"></a>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.00048 | $0.01141 |
| Opus 5 | $0.00024 | $0.00571 |
| Sonnet 5 | $0.00010 | $0.00228 |
| Haiku 4.5 | $0.00005 | $0.00114 |
Grade A, and why
Vitest Mock Isolation Review 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 7d 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 — 76 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Pattern declaration
Primary pattern: Reviewer Secondary patterns: Inversion Why: Vitest 固有の mock lifecycle と async expect 契約をチェックリスト型で検査し、設定不明時はゲートで止める。
Goal / 目的
vi.spyOn/vi.mockの未復元によりテスト間でモック状態が漏れ、実行順序依存の flaky を生むのを防ぐ。expect(...).resolves/.rejectsの await/return 漏れによる「常に pass する空 assertion」を検出する。- モジュールスコープの可変状態がテスト間でリークするのを検出する。
Non-goals / 扱わないこと
- テストの存在有無・カバレッジ・命名は downstream test スキルの領域であり、本スキルでは扱わない。
- どのアサーションライブラリを使うべきかの選定。
- テスト対象の実装ロジックの正しさ(本スキルは mock lifecycle と async expect 契約に限定)。
Pre-execution Gate / 実行前ゲート
このスキルは以下の条件がすべて満たされない限りNO_REVIEWを返す。
- 差分に
vi.mock/vi.spyOn/expect(...)の追加・変更が含まれている - diff コンテキストが利用可能である
ゲート不成立時の出力: NO_REVIEW: vitest-mock-isolation — mock / spy / expect の変更なし
False-positive guards / 抑制条件
- vitest config(
vitest.config.ts/vite.config.ts)でtest.restoreMocks: true/clearMocks: true/mockReset: trueが設定されている場合、afterEachの明示呼び出しが無くても指摘しない。diff だけで設定が見えない場合は断定せず質問に留める。 vi.fn()をローカル変数で都度生成し再利用していないケースはリーク源でないため指摘しない。setupFilesで指定された setup ファイルが意図的にグローバルモックを共有する場合は、別スコープとして扱い指摘しない。
抑制時の出力: 該当する指摘を出力しない(黙る)。
Rule / ルール
vi.spyOn/vi.mockを使う場合、afterEach(() => vi.restoreAllMocks())(spy 復元)またはvi.clearAllMocks()の呼び出し、もしくは config のrestoreMocks: true等のいずれかを満たすことを確認する。いずれも無ければモック状態がテスト間で漏れる。expect(promise).resolves/.rejectsはawaitまたはreturnする。asyncテスト内で await されない expect は検出する。- モジュールスコープの可変変数を複数テストが書き換える場合、
beforeEach等でのリセットを確認する。
Evidence / 根拠の取り方
- 指摘は
<file>:<line>で差分に紐づけ、Vitest 公式の該当規約(mock restore / async assertion)を 1 行で添える。 - config が diff 外にあり確認できない場合は断定せず「可能性」として質問に留める。
Output / 出力(短文版の推奨)
コメントは日本語で返す。
- Finding: どの分離契約に反しているか(1文)
- Impact: テスト間状態リーク / 実行順序依存 flaky / 常に pass する空 assertion 等
- Fix:
afterEach(vi.restoreAllMocks)/restoreMocks: true/await expect(...).rejectsの最小修正案
Sources / 出典
- Vitest — vi API(mock restore): https://vitest.dev/api/vi.html
- Vitest — config restoreMocks: https://vitest.dev/config/#restoremocks
What ships with it
3 files 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.
- 7d ago First seen · 76 lines · 48 tokens per session scan A 69808f75f5de
Vitest Mock Isolation Review is a skill published in the GitHub repository s977043/river-review (3 stars, last pushed today), licensed MIT. It adds 48 tokens to every session and 1,141 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-09-03.
Other skills, from other repositories
testing-react
Writes React/TypeScript tests using Vitest and React Testing Library. Use when "write react tests", "vitest", "component test", "hook test", "RTL", "testing library", "snapshot test", or testing React components, hooks, and utilities.
brooks-test
Test quality review drawing on twelve classic engineering books — with primary focus on xUnit Test Patterns, The Art of Unit Testing, How Google Tests Software, and Working Effectively with Legacy Code — that diagnoses structural problems in an existing test suite: brittleness, mock abuse, coverage illusions, slow…
test-implement
Implements React/TypeScript unit, integration, and browser E2E tests with the repository's configured runner, mocks, setup, and browser harness. Use when creating or completing frontend tests and generated test skeletons.
coverage
Compute code coverage for active track or module. Targets 95%+ coverage with report and justification for uncovered lines. Complements TDD workflow.
testing-laravel
Writes Laravel tests using PHPUnit. Use when "write tests", "add tests", "phpunit", "laravel test", "feature test", "unit test", "mock", "factory", or testing controllers, models, services, actions, jobs, artisan commands, or API endpoints.
review-all
Multi-agent code review for diffs (project-agnostic). Covers standards, bugs, security, DRY, smells, perf, tests, API contracts, a11y/i18n. Verifies each finding to eliminate false positives. Use for /review-all, pre-PR/pre-commit review, or auditing uncommitted/staged changes.