Storybook
Skill Syo-M/codex-frontend-skills/plugins/codex-frontend-skills/skills/storybook
Codex-native frontend skills, custom agents, profiles, and an evidence-backed evaluation harness for React, Next.js, Vite, and Astro.
npx -y skills add Syo-M/codex-frontend-skills --skill storybookAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- 24 days oldThe repository was created 24 days ago. New is not bad, but a brand new repository carrying a familiar-sounding name is the shape a typosquat arrives in, and there has been no time for anyone else to find a problem with it.
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Storybook CSF3 stories, play functions, decorators, and component behavior tests. Use for stories or component-test requests. 日本語の依頼例:「Storybook」「ストーリーを書く」「コンポーネントテスト」「play関数」。
SKILL.md
4.5 KB, as published. Nobody here has run it
Storybook
Stories are the component-test layer: every story renders in the UI catalog AND runs as a Vitest browser-mode test via the Storybook Vitest addon. Write them as both documentation and test.
CSF3 shape
import type { Meta, StoryObj } from '@storybook/react'; // or framework package per installed SB version
import { expect, fn, userEvent, within } from 'storybook/test';
import { LoginForm } from './LoginForm';
const meta = {
component: LoginForm,
args: { onSubmit: fn() }, // fn() for every callback prop — assertable, visible in Actions panel
} satisfies Meta<typeof LoginForm>;
export default meta;
type Story = StoryObj<typeof meta>;
- Colocate:
LoginForm.tsx+LoginForm.stories.tsx.satisfies Meta<…>+StoryObj<typeof meta>— full inference, no casts. - Check installed Storybook major version before using version-specific imports (
storybook/testvs@storybook/test).
Which stories to write
- One story per meaningful state: default, empty, loading, error, edge content (long text, many items). Each renders without interaction → these are your visual states, and the VRT snapshot surface (see
visual-regression). - Plus interaction stories with
playfor each key behavior: submit success, validation error, keyboard operation. - Vary stories via
args, not copy-pasted render functions. Customrenderonly when composition is needed.
Play functions
export const ShowsValidationError: Story = {
play: async ({ canvas, step, args }) => {
await step('submit empty form', async () => {
await userEvent.click(canvas.getByRole('button', { name: /log in/i }));
});
await step('shows error, does not submit', async () => {
await expect(canvas.getByRole('alert')).toHaveTextContent(/required/i);
await expect(args.onSubmit).not.toHaveBeenCalled();
});
},
};
awaitevery interaction and assertion — a missing await passes locally and flakes in CI.- Same query rules as Testing Library:
getByRolefirst (seetesting-vitest). step()for multi-phase plays — failures pinpoint the phase.- Assert outcomes: error visible AND callback not called; not just "no crash".
- Portals/modals render outside the canvas — query via
within(canvasElement.parentElement!)or screen-level helpers.
Decorators & data
- Global providers (theme, i18n, MemoryRouter) once in
.storybook/preview.tsxdecorators — never per-story copies. - Network-dependent components: MSW (
msw-storybook-addon), sharing handler definitions with Vitest tests. No fetch stubbing inside stories. - A story requiring 30 lines of setup is telling you the component's dependencies are too broad.
Running as tests
- The Vitest addon turns every story into a test (render check) and runs
playfunctions in a real browser (Playwright provider) — keep the repository's package-manager-neutraltestscript covering them in CI. - Pin the React runtime (and any animation lib) in the Storybook test project's
optimizeDeps.include:react,react-dom,react-dom/client,react/jsx-runtime,react/jsx-dev-runtime, plus e.g.motion/react. Otherwise Vite discovers a dep mid-run, re-optimizes, and reloads the page — the play function then queries an unmounted tree: an intermittent "unable to find element" that often only shows in CI. The[vitest] Vite unexpectedly reloaded a testwarning is the tell. - A story that can't pass headlessly (depends on viewport quirks, real network) is broken — fix the story, don't exclude it.
- Plays that follow an animation (modal close, exit transitions) assert post-animation state with auto-retrying queries (
findBy*, retriedexpect) — do NOT disable animations or emulate reduced motion in interaction tests; that executes a different motion code path than users get. Animations-off belongs to VRT only (seevisual-regression). - Reuse stories in plain Vitest tests with
composeStorieswhen you need extra assertions beyond the play function.
A11y
- Keep
@storybook/addon-a11yenabled with serious/critical violations failing the test run (same threshold as the Playwright axe gate), not just warnings in the panel. Fix or explicitly (with reason) disable specific rules per story — never globally.
Gives 0 of the 12 instructions most test skills give
Counted across 964 of the 1,571 authors here whose files we hold, read 2026-08-06
- close the browser when donein 55 of 964, across 12 files
- wait for network idle statein 51 of 964, across 6 files
- launch chromium in headless modein 49 of 964, across 6 files
- use descriptive selectors for elementsin 49 of 964, across 6 files
- run provided scripts with help flag firstin 49 of 964, across 6 files
- add appropriate explicit waitsin 48 of 964, across 5 files
- use bundled scripts as black boxesin 46 of 964, across 3 files
- do not read script source codein 46 of 964, across 3 files
- use sync playwright for scriptsin 46 of 964, across 3 files
- inspect dom before executing actionsin 46 of 964, across 3 files
- run the full test suitein 36 of 964, across 34 files
- write the failing test firstin 25 of 964, across 18 files
Said here and by no other author read
- colocate stories with the component file
- type stories using satisfies Meta and StoryObj
- check installed Storybook version before importing
- write one story per meaningful visual state
- vary stories via args not copied render functions
- await every interaction and assertion in play functions
Grouped from the skills themselves: near-identical wordings counted once, and counted by distinct author, so one author publishing three of these counts once.