/dev-flow:write-testsfrom dev-flow
Generates Vitest unit/integration tests or Playwright e2e tests for a single source file. Reads project test config and existing mocking patterns. One file per invocation.
Ships in dev-flow. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
This skill writes the test file that should sit next to a piece of source code. One invocation = one source file → one test file. It does not install test infrastructure (that's module-add test), does not debug failing tests (that's superpowers:systematic-debugging), and does not run an HTTP-based QA pass (that's qa).
The unit of work is deliberately small because tests rot when they're auto-generated in bulk. A single file at a time forces the user to read what was written and accept it before moving to the next.
lib/server/clienti.ts", "test per app/checkout/page.tsx", "e2e per /scadenze".module_added (test infrastructure exists) when the user wants per-feature coverage.meta.json#stack.test is set, OR vitest.config.ts + playwright.config.ts exist at the root.This skill follows the dev-flow contract — see references/contracts.md. Key facts:
<root>/.workflow/meta.json#stack.test to confirm the test framework is wired.vitest.setup.ts, vitest.config.ts, playwright.config.ts, and any sibling test files to learn the mocking style — does not re-prescribe patterns from scratch.__tests__/<name>.test.ts for unit, e2e/<name>.spec.ts for e2e).phase — tests are continuous work, not a phase transition.meta.json#history with the source file path, the test path, and the test type.Read <project-root>/.workflow/meta.json:
stack.framework must be next, or monorepo with the test aimed at apps/web/. On expo-rn (or a file under apps/mobile/), stop and hand off to rn-write-tests: stack.test alone does not tell the two apart — jest-expo+rntl is a valid value too — and this skill's Vitest/Playwright patterns are wrong for React Native.stack.test must be set (e.g., "vitest+playwright"). If null, stop and tell the user: "Test infrastructure not wired. Run module-add test first, then come back."phase should be module_added or later. If earlier, the project might not have anything testable yet — warn and ask whether to proceed.If stack.test is unset but vitest.config.ts exists at the project root, the user installed Vitest manually outside the contract. Proceed, but log this in the user-facing summary so they can re-run module-add test to formalize.
The user names a file. Classify it by path + content:
| Pattern | Classification | Reference |
|---|---|---|
lib/server/<domain>.ts (contains "use server" or exported async functions returning ActionResult) | Server action | references/test-server-action.md |
lib/queries/<domain>.ts (async functions reading from @/lib/db) | Query | references/test-query.md |
app/<route>/page.tsx or app/<route>/[...slug]/page.tsx | Page (e2e) | references/test-page-e2e.md |
the same, on a project whose stack.test carries the e2e layer | Page (agentic e2e) | references/e2e-agentic.md |
components/**/*.tsx containing "use client" and interactive logic | Component (RTL) | references/test-component.md |
components/ui/*.tsx (shadcn primitives) | Skip — primitives are tested upstream | — |
| Anything else | Ask the user what kind of test they want | — |
If the file matches multiple patterns (e.g., a server action that internally uses a query), test as server action — the action is the public surface, the query is implementation detail.
Before writing anything, read at least one existing test file of the same type in the project. The mocking style, the import order (mocks before imports), the naming convention, and the assertion library are already pinned by what's there. Copy the style. Don't introduce a new pattern.
If no test of that type exists yet:
references/test-server-action.md for the canonical pattern.references/test-page-e2e.md — unless stack.test carries e2e, the
agentic runner, which is references/e2e-agentic.md. That file is also where rn-write-tests
reads the mobile half from: one technique, one copy.references/test-component.md.references/test-query.md.Also read vitest.setup.ts to see what's globally mocked (typically next/navigation, next/cache). Don't re-mock those in individual tests.
Read the source file end-to-end. Identify:
{ ok: false } for?), every system-error branch (what does it throw?), and the auth dependencies (getCurrentTenantId, getCurrentUserId).getX() queries fire), the URL params if dynamic.useState, event handlers), the conditional rendering branches.Make a list of test cases before writing the test. The list is the spec — the test file is just the encoding.
Look for:
lib/server/__tests__/<name>.test.tslib/queries/__tests__/<name>.test.tscomponents/<group>/__tests__/<name>.test.tsx (or co-located: components/<group>/<name>.test.tsx)e2e/<route-slug>.spec.tsIf exists:
it("...") blocks, and append the gaps.Apply the relevant reference template (from references/), filling in the project-specific values:
meta.json or by reading the project tree).The reference templates show the canonical shape for each test type. Adapt — don't paste verbatim.
After writing:
pnpm vitest run <test-file> # for unit tests
pnpm playwright test <test-file> # for e2e
If it fails, read the error:
it() block.If the failure is in the source code (e.g., the action throws unexpectedly), stop. Tests revealing real bugs is the point — surface the bug to the user, don't paper over it.
Update .workflow/meta.json:
{
"skill": "write-tests",
"ran_at": "<now>",
"inputs": {"source": "lib/server/clienti.ts", "type": "server-action"},
"outputs": ["lib/server/__tests__/clienti.test.ts"],
"phase_before": "<unchanged>",
"phase_after": "<unchanged>"
}
Tell the user:
it("...")).module-add auth to have run; one test marked it.todo") so they know the gap.pnpm vitest run <path> or pnpm playwright test <path>.lib/server/__tests__/practices.test.ts already exists with a specific mocking style, the new clienti.test.ts matches that style. Consistency over canonical-template-from-this-skill.jest, mocha, cypress, vitest-mock-extended, etc.expect(result.ok).toBe(false), expect(page.locator("h1")).toContainText("...")). Snapshots only when the user explicitly asks.references/worst-case-data.md is that operation — the catalog of
plausible values, the failure-signature table (symptom → cause → fix), and the dev-only
Demo/Worst-case toggle. Reach for it when the user says "stress test this", "find the edge cases",
or when a component renders anything a person typed. The fixture it produces stays in the repo as
a regression test.worst-case-data.md covers the data; this list covers the session. The two fail differently and
a suite that only has the first is still blind to the second. For every flow with more than one step,
walk this list and write the cases that apply: two tabs open at once; double click on submit;
back button mid-flow; refresh mid-flow; a slow network, then offline; an expired session at
the last step; a second user's data must be invisible (the only one on this list that is a security
test, so it is never the one to skip); a timezone away from the server's, across a DST boundary; mobile
width; keyboard only. Name the cases so a failure says which: F01-E3, not test 7.test.skip with a comment explaining why instead of writing a brittle test. Honesty over coverage theater.module-add test to have run (the test infrastructure has to exist).module-add db, module-add auth — the smoke tests in module-add test mock these; this skill follows the same pattern..claude/skills/verify-<app>/features/, from app-verification) already names the entry point, the accessible names and the end state — the Playwright or e2e test is that recipe made repeatable.module-add ci: tests written by this skill run in CI once module-add ci runs (the GHA workflow added there picks up pnpm test:run and pnpm test:e2e).module-add test. If vitest isn't in package.json, this skill stops and routes there.vitest --coverage themselves once they have enough tests.references/contracts.md (opens in a new tab)references/e2e-agentic.md (opens in a new tab)references/test-component.md (opens in a new tab)references/test-page-e2e.md (opens in a new tab)references/test-query.md (opens in a new tab)references/test-server-action.md (opens in a new tab)references/worst-case-data.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub lukedj78/dev-flow --plugin dev-flow57 skills in this plugin
/animated-iconsAdd a Motion-animated icon to a Next.js app from a shadcn registry instead of hand-animating an SVG. Two registries, picked from the project's icon set: **heroicons-animated** (316 icons, `shadcn add @heroicons-animated/<name>`) and **hugeicons-animated** (165 icons, `shadcn add @hugeicons-animated/<name>`, which also installs a shared `lib/use-icon-animation.ts`). Both MIT, both on the `motion` runtime, both copied into your repo as source. This skill owns the install plus the two things the raw components lack: a `prefers-reduced-motion` guard and timing aligned to the project motion tokens (`lib/motion/`). Use when the user says "animated icon", "animate this icon", "make the bell/heart/menu icon animate on hover", "aggiungi un'icona animata", or wants an icon micro-interaction. Refuses outside Next.js web — for React Native use `rn-animations-gestures`. Not for: static icons, a whole motion system (`transitions`), or installing the runtime itself (`module-add motion`)./app-securityCheck whether an app's own code can be attacked before it ships — vulnerable dependencies, secrets in the code and in git history, Next.js authorization gaps (Server Actions and route handlers without a session check, queries by id with no owner filter — IDOR), data over-exposure, secrets in public env vars, raw SQL — then read the flagged code against an OWASP checklist, with an opt-in dynamic level (Strix) that proves exploits against the app running locally. The fifth pre-deploy gate, beside compliance-audit, vercel-doctor, shadscan and launch-audit; reports and routes, never blocks. Triggers: "security review", "è sicura l'app?", "controllo di sicurezza prima del deploy", "IDOR", "secrets in the repo", "pentest". Not for: GDPR and legal (compliance-audit), UI quality (shadscan), cost (vercel-doctor), launch readiness (launch-audit), a review of one branch diff (Claude Code's /security-review), third-party registry code (registry-intake).