test

A test-planning command for creating test cases with Vitest and React Testing Library. Vitest runs unit tests, while React Testing Library checks how React components behave for users.

In plain words
What is it for?
Use it to plan tests for functions and React components, including their expected behavior, file locations, and required import style.
Why use it?
It provides a consistent testing approach and prevents test files from being misplaced or importing application code incorrectly.

Command for Claude Code

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 commands/caspian-sun/claude-code-workflow/test
Clone the repo
git clone --depth 1 https://github.com/Caspian-Sun/claude-code-workflow

Made for: Claude Code.

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 3,203 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 $0.00000 $0.03203
Opus 5 $0.00000 $0.01602
Sonnet 5 $0.00000 $0.00641
Haiku 4.5 $0.00000 $0.00320

Measured 2d ago against content hash a6486c966d25, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

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 2d 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/test.md · 246 lines

How it starts

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

You are now acting as a Test Engineer. Generate comprehensive test cases for the specified components/functions.

Testing Frameworks

  • Unit tests: Vitest + @testing-library/react
  • E2E tests: Playwright (only when explicitly requested)

Test File Placement Rules (mandatory)

All test files must be placed under workspace/tests/, mirroring the workspace/src/ directory structure with a one-to-one correspondence to source files. Prohibited: placing *.test.ts(x) files in the same directory as source files or in __tests__/ subdirectories.

Mapping examples:

Source File Test File
workspace/src/features/list/api/listApi.ts workspace/tests/features/list/api/listApi.test.ts
workspace/src/features/list/components/SearchForm.tsx workspace/tests/features/list/components/SearchForm.test.tsx
workspace/src/pages/list/index.tsx workspace/tests/pages/list/index.test.tsx

Test files must reference business code exclusively via the @/ alias (do not write ../../../src/...):

import SearchForm from '@/features/list/components/SearchForm';
vi.mock('@/features/list/api/listApi', () => ({ ... }));

Execution Flow

Step 0: Read Business Anchors and Extract Business Rules (mandatory)

Test expectations must come from business rules, not from AI inferences about source code behavior. Otherwise you get "tests and source code are both AI-written, mutually validating" false passes.

For each target source file:

  1. Extract business anchors from the JSDoc header (see .claude/rules/file-docs.md):

    • @prd docs/prds/xxx.md#<anchor> → PRD location
    • @task docs/tasks/xxx.json#<taskId> → task entry
    • @rules → multi-line business rule list
  2. Read the linked documents:

    • Open the PRD fragment at @prd for full context
    • Open the task entry at @task to read acceptance criteria
    • Use @rules directly as the rule list
  3. Output the business rule list (show to user for alignment):

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

Subscribe to this mod's changes

test is a command published in the GitHub repository Caspian-Sun/claude-code-workflow (10 stars, last pushed 5d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 3,203 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.