一键导入
unit-testing
Writes unit tests following behavior-driven conventions with vitest. Use when creating tests, adding test coverage, or writing regression tests.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Writes unit tests following behavior-driven conventions with vitest. Use when creating tests, adding test coverage, or writing regression tests.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | unit-testing |
| description | Writes unit tests following behavior-driven conventions with vitest. Use when creating tests, adding test coverage, or writing regression tests. |
foo.test.ts next to foo.tsdescribe named after the unit under testtest, not itdescribe("createCart", () => {
test("calculates total for multiple items", () => { ... });
test("returns empty items for new cart", () => { ... });
});
import { describe, expect, test, vi } from "vitest";
| API | Use |
|---|---|
describe("group", fn) | Group related tests |
test("desc", fn) | Single test |
test.each([...])("desc %s", fn) | Parameterized |
expect(v).toBe(x) | Strict equality |
expect(v).toEqual(x) | Deep equality |
expect(fn).toThrow() | Assert throws |
vi.fn() | Mock function |
Mock only at system boundaries:
Date.now), randomness (Math.random), file systemNever mock things you control:
If you feel the need to mock an internal module, the code is doing too much or you're testing at the wrong level.
For mocking patterns and DI examples, see references/mocking.md.
When a project has coverage thresholds configured, every file must meet them individually (perFile: true). Write tests that cover all branches and statements — if a file has unreachable code, that's a signal to simplify the implementation rather than lower thresholds.
Plans development tasks through codebase exploration, exhaustive user interviews, and structured file-based plans. Use when tackling a feature, bug fix, refactor, or any task that benefits from upfront planning. Generates plan files in .agents/plans/ for later execution with /execute-plan.
Executes a plan generated by /create-plan. Orchestrates team members in parallel, each working in isolated worktrees. Use when ready to execute a plan from .agents/plans/, resume an interrupted execution, or run a specific plan by ID.
Plans and executes development tasks through codebase exploration, user interviews, and coordinated teammates. Use when tackling a feature, bug fix, refactor, or any task that benefits from upfront planning and parallel execution.
Builds type-safe, accessible forms with TanStack Form, Base UI Field, and the useAppForm hook. Use when creating forms, adding validation, handling form submission, or working with form fields and form state management.
Provides instructions for the Better Auth admin plugin in Convex projects. Use when adding admin capabilities, user management, role-based access control, banning users, managing sessions, impersonation, or custom permissions.
Provides instructions for the Better Auth email OTP plugin in Convex projects. Use when adding passwordless sign-in, email OTP authentication, one-time codes, email verification, or OTP-based password reset.