storybook

Authors, configures, and audits Storybook CSF3 stories, addons, and play-function interaction tests.

Updated Nov 20, 2025
One-click install
npx skills add https://github.com/apuya/react-basics-ui --skill storybook-apuya
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: storybook
Source: https://github.com/apuya/react-basics-ui/tree/main/.claude/skills/storybook
Command: npx skills add https://github.com/apuya/react-basics-ui --skill storybook-apuya

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing and maintaining Storybook stories involves many moving parts — CSF3 typing, addon configuration, play functions, MSW mocking, and visual regression setup — and gaps in any of them lead to untested states, flaky tests, or broken builds. This Skill provides a structured workflow for authoring complete story coverage, configuring the workspace correctly, and auditing existing story files for common defects. ## Core Features & Use Cases - Story Authoring: Generates CSF3 story files with satisfies Meta<typeof Component>, default stories, variant matrices, per-state stories (Hover, Focus, Disabled, Loading, Error), and interaction stories with assertion-backed play functions using @storybook/test. - Workspace Configuration: Sets up .storybook/main.ts and .storybook/preview.tsx, registers addons (a11y, docs, vitest, themes), wires MSW network mocking, the Vitest addon, the test runner, and Chromatic visual regression. - Story Auditing: Reviews existing story files across five dimensions — story shape, play-function smells, real network leaks, coverage gaps, and configuration — producing severity-ranked findings with file:line locations. - Use Case: A developer adds a new DatePicker component to a React library and asks for full story coverage; the Skill produces a story plan, a typed CSF3 file with default, variant, state, and interaction stories, and confirms the play functions pass under the Vitest addon. ## Quick Start Write complete CSF3 stories with variants, states, and an interaction play function for my Button component.

Frequently Asked Questions about storybook

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write CSF3 stories in Storybook?

Define a default-exported meta object using `satisfies Meta<typeof Component>` with shared args and argTypes, then export named stories typed as `StoryObj<typeof meta>`. Include a Default story, one story per variant axis, and one per applicable interaction state.

How do I write a play function in Storybook?

Import `expect`, `fn`, `userEvent`, and `within` from `@storybook/test`, then add an async `play` function to the story that queries by accessible role, awaits every userEvent, and asserts observable outcomes like rendered text or spy calls.

Storybook Vitest addon vs test runner — which should I use?

The Vitest addon runs story files as browser tests for fast local feedback and CI-blocking play-function assertions, and is the default for new workspaces. The test runner is better when stories must run against a built or deployed Storybook.

How do I mock API calls in Storybook stories?

Use the msw-storybook-addon: initialize it in preview and register the mswLoader, then define per-story handlers under `parameters.msw.handlers`. This replaces real fetch or axios calls so stories never hit production networks.

Why do my Storybook stories render unstyled?

Stories render unstyled when the global CSS carrying design tokens is not imported in `.storybook/preview.ts`. Import the global stylesheet there once rather than in individual story files, and verify components render in every registered theme.

Why do Chromatic snapshots show false visual diffs?

False diffs come from nondeterministic render sources like `Date.now()`, `Math.random()`, animations, or late-loading fonts. Inject deterministic values via args or decorators, preload fonts, and disable snapshots on intentionally nondeterministic stories.