vitest-unit

vitest-unit is a skill for Claude Code, Codex from lukasrepublic/agentic-foundry. It costs 0 tokens per session (1,443 once invoked), scanned A, original, MIT.

Guidance for writing unit tests for functions, React components, hooks, and asynchronous handlers, including coverage and mocking decisions.

In plain words
What is it for?
Use it when adding or reviewing unit tests, checking coverage requirements, handling async behavior, or deciding what boundaries to mock.
Why use it?
It helps keep tests close to the code they cover and encourages isolated tests before broader integration or browser tests.

Skill for Claude CodeCodex

Part of the foundry plugin — 81 skills, 8 agents, 8 hooks, 1 MCP server shipped together

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/lukasrepublic/agentic-foundry/vitest-unit
Any agent
npx skills add lukasrepublic/agentic-foundry --skill vitest-unit
Clone the repo
git clone --depth 1 https://github.com/lukasrepublic/agentic-foundry

Made for: Claude Code, Codex.

Or install foundry, the plugin that ships this one along with the rest of its 81 skills, 8 agents, 8 hooks, 1 MCP server.

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 vitest-unit

README.md
[![agentmods](https://agentmods.dev/badge/skills/lukasrepublic/agentic-foundry/vitest-unit.svg)](https://agentmods.dev/skills/lukasrepublic/agentic-foundry/vitest-unit)
Your own site
<a href="https://agentmods.dev/skills/lukasrepublic/agentic-foundry/vitest-unit"><img src="https://agentmods.dev/badge/skills/lukasrepublic/agentic-foundry/vitest-unit.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,443 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.1 $0.00000 $0.01443
Opus 5 $0.00000 $0.00722
Sonnet 5 $0.00000 $0.00289
Haiku 4.5 $0.00000 $0.00144

Measured 5d ago against content hash 6def233a3e20, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

vitest-unit 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 5d 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.

packs/stack-profiles/node-web/blueprints/vitest-unit/SKILL.md · 73 lines

How it starts

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

When to trigger

  • Authoring a unit test for a function, React component, hook, or async handler.
  • Coverage-gate work: ensuring the target package meets its coverage threshold.
  • Snapshot review: deciding whether to update or reject a snapshot diff.
  • Async-pattern test work: testing promises, async/await, timeouts, or event-driven code.
  • Mock-strategy decisions: which layer to mock (module boundary vs. network boundary).

Procedure

  1. Place test file colocated with implementation: <file>.test.ts (non-React) or <file>.test.tsx (React components) in the same directory as the source file. This makes it obvious when a test is missing and prevents "lost test" drift.

  2. Test pyramid discipline: write many unit tests, fewer integration tests, fewest e2e tests. A unit test covers one function or component in isolation. If a test requires multiple real modules to be wired together, consider whether it should be an integration test.

  3. Coverage threshold for the target package is {{ profile.test_recipe.coverage_gate }}. Do not invent a threshold; use the profile's gate. Verify with the project's coverage run that the PR does not lower the threshold below the defined minimum.

  4. Snapshots only for stable serialization (config objects, API response shapes, serialized schemas). Never snapshot rendered React DOM — rendered output is brittle (class names, whitespace, auto-generated IDs change between builds). Replace DOM snapshots with role/testid assertions.

  5. Async patterns: always await returned promises. Never use the done callback pattern (deprecated idiom; async/await is the supported form in Vitest). For timer-based code, use vi.useFakeTimers() + vi.runAllTimers().

  6. Mocks via vi.mock at the module boundary: vi.mock('../path/to/module') hoists the mock above imports. Scope mocks to the test file — never use globalThis or vi.doMock for cross-file state. Reset mocks between tests with vi.clearAllMocks() in afterEach.

Read the full file on GitHub · 73 lines

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. 5d ago First seen · 73 lines · 0 tokens per session scan A 6def233a3e20

Subscribe to this mod's changes

vitest-unit is a skill published in the GitHub repository lukasrepublic/agentic-foundry (1 stars, last pushed today), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,443 tokens. 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-31.