/fe:storybookfrom Frontend Skills
Storybook 10 for a Next.js or React project, where every story is also a test — setting it up (the framework package, built-in essentials plus a11y, vitest and docs, Tailwind once, a preview with the tier order, providers, toolbar dark mode, module mocks, accessibility failing from day one, browser tests in CI) and writing stories in CSF3 (`satisfies Meta`, `fn()` spies, a control per prop, tier-first titles, a fixed story order, keyboard `play` stories asserting by role). Use when adding, configuring or writing stories.
Ships in Frontend Skills. 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.
A story is two things at once: the page where a person sees a component in each state that matters, and — run by the Vitest addon in a real browser — that component's test (testing). So every story earns its place by showing or proving something; one written to fill a list is noise in both. Setting Storybook up is a one-off, summarised below and detailed in references/setup.md.
Before applying this skill, read the project's root AGENTS.md, the AGENTS.md closest to the files in question, and any doc they link for this skill's topic. Names, values and choices — budgets, tiers, tokens, voice, paths — come from those files, never from this skill.
pnpm create storybook@latest with the framework package that matches the consumers — @storybook/nextjs-vite for components rendered in Next.js, @storybook/react-vite otherwise. Storybook 10 is ESM-only; every Storybook package moves at one version.@storybook/addon-a11y, @storybook/addon-vitest and @storybook/addon-docs — plus eslint-plugin-storybook in the shared lint config.a11y: { test: "error" }.In a monorepo the Storybook app is its own app pointed at the UI package; in a single app it's a .storybook/ folder. Either way, a story file lives beside its component. The details, main.ts, the preview and troubleshooting are in references/setup.md.
button.stories.tsx beside button.tsx in a package that uses kebab-case files, Button.stories.tsx in an app — naming).import type { Meta, StoryObj } from "@storybook/nextjs-vite"; // the framework package, never the renderer package
import { fn } from "storybook/test";
import { Button } from "./button";
const meta = {
title: "Base/Button",
component: Button,
parameters: { layout: "centered" }, // centered · padded · fullscreen
args: { children: "Save", onClick: fn() }, // a spy for every callback prop
argTypes: {
variant: { control: "select", options: ["primary", "secondary", "ghost"], description: "Visual weight" },
},
} satisfies Meta<typeof Button>;
export default meta;
type Story = StoryObj<typeof meta>;
/** The button as most screens use it. */
export const Default: Story = {};
/** Waiting on a request: the label stays, a spinner joins it, and clicks do nothing. */
export const Loading: Story = { args: { isLoading: true } };
@storybook/nextjs-vite, or @storybook/react-vite outside Next.js) — eslint-plugin-storybook's recommended no-renderer-packages rule fails an import from @storybook/react.satisfies Meta<typeof X>, never : Meta<typeof X>: it ties meta to StoryObj<typeof meta>, so args set on the meta or the story stay type-checked. A file with no single component (an icon gallery, a composition) may annotate Meta plainly.: Story, and shared args live on the meta, so each story holds only what differs.fn() spies from storybook/test — they log in the Actions panel and can be asserted in play. Never argTypes: { onClick: { action: "…" } }.argTypes entry where it isn't (a union as a select, a number with its range) — with a description when the name doesn't say enough./** … */) on each story says what it shows; the docs page uses it as the story's description. A // comment isn't picked up.A spy never updates the arg it replaces, so a controlled component (open with onOpenChange, value with onChange) would freeze. Its stories keep the arg in step with useArgs from storybook/preview-api, or render through a small wrapper that holds the state:
import { useArgs } from "storybook/preview-api";
export const Controlled: Story = {
render: function Render(args) {
const [, updateArgs] = useArgs();
return <Dialog {...args} onOpenChange={(open) => { args.onOpenChange?.(open); updateArgs({ open }); }} />;
},
};
Foundations/…, Assets/…, Icons/…, Base/…, Components/…, Blocks/…, Layouts/…, Pages/… — the tiers design-system defines, in the order the preview sorts them.src/ui/ or components/ — take the app's name first, then the same tiers (Admin/Blocks/AccountTable), so they sort after the shared package's and match the folder Storybook would derive the title from.Disclosure, Display, Feedback, Forms, Navigation, Overlay (Components/Overlay/Dialog). Never by product domain in a shared package, and never by shape: there's no "Cards" bucket. A new subcategory is a decision recorded with the tiers, not drift.WithIcon, WithDescription).Not a story: dark mode (the toolbar shows every story in it), right-to-left, a prop combination nothing uses, or a story whose only purpose is to raise a count. Names are whole words, without the kind repeated (Small, not SmallSize).
import { expect, screen } from "storybook/test";
export const ClosesOnEscape: Story = {
play: async ({ canvas, userEvent, args }) => {
await userEvent.tab(); // keyboard first: reach the trigger the way a keyboard user does
await userEvent.keyboard("{Enter}");
await expect(screen.getByRole("dialog", { name: "Edit profile" })).toBeVisible(); // portals render outside the canvas
await userEvent.keyboard("{Escape}");
await expect(canvas.getByRole("button", { name: "Edit profile" })).toHaveFocus(); // focus returns to the trigger
await expect(args.onOpenChange).toHaveBeenLastCalledWith(false);
},
};
play takes canvas and userEvent from its context; screen reaches what renders outside the story, like a dialog's portal.accessibility).ClosesOnEscape, SubmitsTheForm). A story that exists only to test is hidden from the sidebar and the docs page with tags: ["!dev", "!autodocs"]; it still runs.Axe runs on every story and fails the run (references/setup.md). Fix the component; never switch a rule off or mark the story "todo" to make it pass. A violation in a third-party component is fixed in the copy the project owns, or the component is wrapped so the wrapper passes (accessibility).
testing).sb.mock; a story never mocks the project's own logic.tailwind).Template.bind({}); @storybook/test; a renderer-package import; { action: "…" } argTypes; untyped stories.play that asserts tags or classes; an axe rule turned off.Stories as the UI tests testing · tiers design-system · keyboard patterns and axe accessibility · building the component reusables · tokens and CSS tailwind · file and story names naming · catalog and versions monorepo · CI and hosting devops · the audit storybook-audit.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub timonwa/engineering-skills --plugin fe20 skills in this plugin
/accessibilityBuilding UI that meets WCAG 2.2 AA beyond the markup — text alternatives, contrast checked on the tokens in both themes, reflow and zoom, keyboard and focus (order, visibility, dialogs, skip link, not obscured), target size, pointer and motion, labels, errors people see, accessible sign-in, ARIA states and live regions, and the gates that verify it: lint, Storybook axe at error, keyboard stories and screen-reader passes. Use when building or reviewing any interactive UI, a form, a dialog or a colour token./accessibility-auditManually invoked. Red-team accessibility audit of an app or a diff against WCAG 2.2 AA, organised by POUR with each check citing its success criterion — structure and landmarks, contrast on the tokens in both themes, reflow and zoom, keyboard, focus and dialogs, pointer and target size, forms and errors that are seen, status messages, and the lint, Storybook and end-to-end gates. Verifies each finding and writes a prioritized report./content-auditManually invoked. Copy audit of an app, its emails or a diff, against the project's own voice, word list and banned words and the plain-language standards (GOV.UK, NN/g, WCAG) — point-first writing, marketing claims and calls to action, buttons and links, form labels and errors, empty, success and loading states, sentence case and mechanics, accessible words and alt text, translation-safe strings, and each transactional email's sender, subject, preheader and body. Verifies each finding and writes a prioritized report.Other plugins' skills for the same job