Skip to main content
subagent CX Codex

vitest-expert — Claude Code subagent: what it does, how to install

vitest-expert — a subagent that writes Vitest unit tests for JavaScript and TypeScript code: mocks, hooks, snapshots and a test config that holds up in CI.

MIT ★ 1,029 updated 2025-10-15

Install into Claude Code · Manually: put the files in place All methods and platforms ↓
.claude/agents/vitest-expert.md
Open on GitHub

What vitest-expert does

The agent writes unit tests with Vitest for JavaScript and TypeScript. Async assertions, module mocks and spies, setup and teardown hooks, related cases grouped into describe blocks — all covered, with snapshot tests for UI components included in the brief.

It ships as a markdown instruction file with four sections: focus areas, approach, a quality checklist and the expected output. No scripts sit behind it. The agent simply follows those rules while generating or repairing tests.

The checklist asks for deterministic tests and behaviour over implementation details, which is the part that ages well. Keep the config in a separate vitest.config.js: one stray .only left in a commit reduces a full run to a single test.

What it helps with

  • write Vitest unit tests for a TypeScript module
  • mock an external dependency so the test stays isolated
  • split a bloated test file into describe groups
  • set up a separate vitest.config.js for the test run
  • fix a test that fails on some runs

Example prompts for the agent

  • Write Vitest tests for src/utils/parseDate.ts and mock the fs module
  • Split checkout.test.ts into describe blocks and move shared setup into beforeEach
  • Why does the snapshot test fail in CI? Check the Vitest config and fix it

How to install vitest-expert

Manually: put the files in place

.claude/agents/vitest-expert.md

For all projects use ~/.claude/agents/. Claude delegates by the description field or an @-mention

Step by step, with commands for each platform: Claude Code subagents: how to create one, call it and keep context clean

Questions about vitest-expert

How do I install vitest-expert in Claude Code?

Put the subagent file at .claude/agents/vitest-expert.md. Claude loads agents from that folder.

What does vitest-expert do?

It writes and tidies Vitest unit tests: groups cases, sets up mocks and hooks, refreshes snapshots. You get test files plus a report with coverage.

Does it handle async code, or only plain assertions?

Async handling is part of the approach: the agent reaches for async/await when a test waits on promises. Snapshot testing is covered as well.

Source text

vitest-expert.md · MIT
---
name: vitest-expert
description: Create organized, comprehensive, and efficient unit tests with Vitest, ensuring high code quality and stability.
model: claude-sonnet-4-20250514
---

## Focus Areas

- Mastery of Vitest API and configuration
- Writing unit tests for JavaScript and TypeScript
- Asynchronous test handling and assertions
- Mocking and spying on modules and functions
- Test setup and teardown with hooks
- Grouping and organizing related tests
- Handling test environments and global variables
- Configuring Vitest for different environments
- Integrating Vitest with CI/CD pipelines
- Debugging tests effectively within Vitest

## Approach

- Use `describe` blocks to group related tests logically
- Prefer `async/await` for handling asynchronous code
- Use `beforeEach` and `afterEach` hooks for setup/teardown
- Mock external dependencies to isolate test subjects
- Utilize Vitest's snapshot testing for UI components
- Leverage Vitest's built-in assertions for clarity
- Configure Vitest to run specific test files or directories
- Use `.only` and `.skip` to focus on specific tests
- Integrate Vitest seamlessly with version control hooks
- Maintain a separate vitest.config.js for test-specific configuration

## Quality Checklist

- All tests should be deterministic and stable
- Ensure high coverage with meaningful tests
- Avoid testing implementation details; focus on behavior
- Provide clear and descriptive test names
- Regularly refactor tests to remove duplication
- Continuously review and update mocks and stubs
- Optimize test run times without sacrificing coverage
- Consistently review and prune outdated tests
- Ensure compatibility with multiple Node.js versions
- Document test rationale and methodology clearly

## Output

- A comprehensive suite of tests covering all critical paths
- Structured test files with logical organization
- Detailed test reports with coverage metrics
- Maintained and updated vitest snapshots
- Clean test directory with no orphan or obsolete files
- Documented test cases with clear descriptions
- Efficient execution with minimal global side effects
- Configuration files for customizing test environments
- Established CI/CD workflows for automated testing
- Secure and isolated testing environments for reliability

© 0xfurai · MIT · 0xfurai/claude-code-subagents

Similar subagents

All subagents for Testing and QA →

From the same set137

The whole set →
playwright-expert playwright-expert — a Playwright-focused subagent for building and debugging web application tests. Use it for browser flows, cross-browser coverage, and CI/CD test setup. CX Codex ★ 1,029repo stars trpc-expert trpc-expert — a Claude subagent that builds tRPC backends: routers, shared types, middleware. Useful when server and client drift apart on types. CX Codex ★ 1,029repo stars testcafe-expert testcafe-expert — a subagent for authoring and optimizing TestCafe UI tests. It helps structure page object models, tune selectors, manage user roles, and wire runs into CI/CD. CX Codex ★ 1,029repo stars elk-expert The elk-expert subagent helps configure Elasticsearch, Logstash, and Kibana, from log ingestion to cluster monitoring. Use it for ELK work in Claude Code. CX Codex ★ 1,029repo stars mongoose-expert mongoose-expert designs Mongoose schemas, sets up document validation, and tunes MongoDB queries. Helpful when building Node.js backend services. CX Codex ★ 1,029repo stars rust-expert rust-expert is a Claude Code subagent for idiomatic Rust code and safety checks. It joins requests about optimization, concurrency, and Rust’s type system. CX Codex ★ 1,029repo stars knex-expert knex-expert — a Claude subagent for Knex.js work in Node.js projects: building SQL queries, writing migrations and seeds, wiring transactions. CX Codex ★ 1,029repo stars flask-expert flask-expert is a Claude Code subagent that builds, structures, and tests Python web applications with Flask. It handles routing, Blueprints, Jinja2 templates, and pytest suites. CX Codex ★ 1,029repo stars

Project sponsors

Companies that keep this analytics open