react-vite2: Command for Claude Code

.claude/commands/create_unit_tests.md

create_unit_tests is a command for Claude Code from erezcohen/react-vite2. It costs 0 tokens per session (2,565 once invoked), scanned A, original, MIT.

A command for creating unit tests for React components, pages, hooks, and utility functions using Vitest and React Testing Library. Unit tests check small parts of a program in isolation.

In plain words
What is it for?
Use it to test components such as buttons and dashboards, hooks such as authentication or themes, and utilities such as date or currency formatting.
Why use it?
It encourages tests based on what users see and do rather than on internal implementation details, making them less fragile during refactoring.

Command for Claude Code

Written for Claude Code: installed under .claude/.

This is erezcohen/react-vite2's own configuration. It tells Claude Code how to work on react-vite2 itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything react-vite2 configures →

Needs its repository: it reads a path above its own folder, which exists only inside the repository. The line is import { ComponentName } from '../ComponentName';.

Reuse

Borrowing it

Nothing to install: this file belongs to erezcohen/react-vite2. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/erezcohen/react-vite2/master/.claude/commands/create_unit_tests.md
Clone the repo
git clone --depth 1 https://github.com/erezcohen/react-vite2

Made for: Claude Code.

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 create_unit_tests

README.md
[![agentmods](https://agentmods.dev/badge/commands/erezcohen/react-vite2/create_unit_tests/github.svg)](https://agentmods.dev/commands/erezcohen/react-vite2/create_unit_tests)
Your own site
<a href="https://agentmods.dev/commands/erezcohen/react-vite2/create_unit_tests"><img src="https://agentmods.dev/badge/commands/erezcohen/react-vite2/create_unit_tests/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 create_unit_tests

Your own site · 80×15
<a href="https://agentmods.dev/commands/erezcohen/react-vite2/create_unit_tests"><img src="https://agentmods.dev/badge/commands/erezcohen/react-vite2/create_unit_tests.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,565 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.
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.02565
Opus 5.5 $0.00000 $0.01026
Sonnet 5.5 $0.00000 $0.00513
Haiku 4.5 $0.00000 $0.00257

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

Security

Grade A, and why

create_unit_tests 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 25d 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.

.claude/commands/create_unit_tests.md · 393 lines

How it starts

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

Writing Unit Tests with Vitest and React Testing Library

You are an expert frontend developer with extensive experience in unit testing React components using Vitest and React Testing Library. Your expertise includes writing maintainable, reliable tests that follow industry best practices and focus on user behavior rather than implementation details.

Command Usage

This command helps you create comprehensive unit tests for React components. You can optionally specify:

  • --component or -c: The specific component to test (e.g., "Button", "Header", "UserProfile")
  • --page or -p: The page component to test (e.g., "Dashboard", "Login", "Settings")
  • --hook or -h: Custom React hook to test (e.g., "useAuth", "useTheme", "useLocalStorage")
  • --util or -u: Utility function to test (e.g., "formatDate", "validateEmail", "calculateTotal")

Examples:

  • create_unit_tests --component Button
  • create_unit_tests --page Dashboard
  • create_unit_tests --hook useAuth
  • create_unit_tests --util formatCurrency

Best Practices

Follow these best practices when creating unit tests with Vitest and React Testing Library:

1. Test Organization

  • Place test files in __tests__/ directories next to the source files
  • Use .test.ts or .test.tsx extension for test files
  • Group related tests using describe() blocks
  • Use descriptive test names that explain user behavior

2. Import Structure

import { render, screen, fireEvent, waitFor } from '@/test/test-utils';
import userEvent from '@testing-library/user-event';
import { vi } from 'vitest';
import { ComponentName } from '../ComponentName';

3. Test Utilities

Always use the custom test utilities from @/test/test-utils which includes:

  • Router provider for components that use navigation
  • Theme provider for components that use theme context
  • Other global providers your app requires

4. Query Priority

Use React Testing Library queries in this order of preference:

Read the full file on GitHub · 393 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. 25d ago First seen · 393 lines · 0 tokens per session scan A e43a317dd523

Subscribe to this mod's changes

create_unit_tests is a command published in the GitHub repository erezcohen/react-vite2 (0 stars, last pushed 3mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 2,565 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-10-02.