/svelte-5:storybookfrom svelte-5
Provides Storybook authoring guidance for Svelte projects: MCP integration, preview verification, CSS import tracing, and Svelte 4 store wrapper patterns for stories.
Ships in svelte-5. 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.
None: SKILL.md is the whole skill.
get-storybook-story-instructions tool before writing stories: it returns Storybook's instructions for writing, testing and fixing stories (story structure, imports, play functions, mocking). After writing them, ALWAYS preview them with its preview tool (stories-preview, or preview-stories if that is the name your server lists). The tool prefix is your MCP server's name (mcp__storybook__get-storybook-story-instructions when the server is called storybook)beforeEach({ msw }), msw-storybook-addon wiring, the msw 2 to 3 migration): svelte-5:msw skillstorybook script. With -p <port> or --port <port> (sv add storybook leaves storybook dev -p 6006 in package.json), open http://127.0.0.1:<port> with Playwright MCP to check whether Storybook runs; if the page does not load, go to step 3. With no storybook script, or no port in it, ask the user whether Storybook runs and on which URL; if it does not run, go to step 3storybook script in the background with pnpm storybook --ci (--ci: no browser, no prompts), wait for the Local: URL it prints, and when done stop the background process you started. With no storybook script, starting Storybook is not covered here: ask the user to start it, then continue with step 2App.svelte, or src/routes/+layout.svelte on SvelteKit) and from .storybook/preview.ts. Moving an import out of the SCSS chain breaks Storybook unless you also add it to preview.ts or to the stylesheet preview.ts importsComponents that import and read from Svelte 4 module-level
writable() stores (from svelte/store) render with default
or empty data in Storybook until the stores are set. A
component that subscribes ($store) updates when the store is
set later; one that reads it once at init (get(store)) only
sees a value set before it mounts. Svelte 5 runes state in
.svelte.ts modules behaves the same way: a template read
updates on a later change, a copy taken in the component
script (const v = state.v) does not. Set stores and runes
state in the wrapper, which runs before the component mounts.
Pattern: Create a <ComponentName>Wrapper.svelte that:
setContext() for any required Svelte contextsstore.set() with mock data for every Svelte 4
writable() store the component imports, and sets mock
values on the properties of any runes module state
(.svelte.ts) it readsmax-width, as in the example belowRender the wrapper inside <Story asChild>, as below, and pass any props to
the component there. The wrapper also works as a decorator when the decorator
returns { Component }: decorators: [() => ({ Component: MyComponentWrapper })].
A decorator that returns the bare component (() => MyComponentWrapper) works in
the Storybook UI, but in the Vitest run an argless instance of the defineMeta
component (if it has one) renders in its place. The wrapper markup, setContext and
store.set are always missing; depending on the defineMeta component, an asChild
story's content or an args story's own instance can disappear, an args story's component
can render twice, or the story fails when that component throws without props. The decorator internals and the full wrapper pattern are in
svelte-5:storybook-vitest (references/storybook-decorator.md).
<!-- stories/MyComponentWrapper.svelte -->
<script lang="ts">
import { setContext, type Snippet } from 'svelte'
import { myWritableStore } from '../stores' // a writable() store from svelte/store
let { children }: { children: Snippet } = $props()
setContext('myContext', true)
myWritableStore.set({ /* mock data */ })
</script>
<div style="max-width: 600px; padding: 1rem;">
{@render children()}
</div>
<!-- stories/MyComponent.stories.svelte -->
<script module>
import { defineMeta } from '@storybook/addon-svelte-csf'
import MyComponent from '../MyComponent.svelte'
import MyComponentWrapper from './MyComponentWrapper.svelte'
const { Story } = defineMeta({ title: 'MyComponent', component: MyComponent })
</script>
<Story name="Default" asChild>
<MyComponentWrapper>
<MyComponent />
</MyComponentWrapper>
</Story>
Using () => {} for callback props in stories means the
callback is never verified. If the component passes wrong
data types to the callback, the noop silently swallows it.
For critical callbacks (onChange, onSubmit, onSelect):
svelte-5:storybook-vitest,
".stories.svelte + play")When excluding a story from the Vitest run (the !test tag, or
a custom opt-out tag), verify IMMEDIATELY that it renders
in the Storybook UI via Playwright MCP. Navigate to the story
(how to build a story's URL is not covered here), wait for render, take a screenshot, check console for 0
errors. The opt-out removes the story from the automated run, so
this check is the only one it gets.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
storybook, svelte-stories, component-testing, visual-testing
8 skills in this plugin
/code-style-svelteSvelte component code style rules. Auto-invoke when creating .svelte files, editing component structure, transitions or layout reads, or SvelteKit URL state and navigation guards. Covers component docs and Svelte style conventions./composition-svelteUse when composing a Svelte 5 feature from provider/wrapper components, content snippets, reactive state, or third-party DOM bridging (maplibre, leaflet, d3, tippy, popper). Covers overlay wrappers, snippet APIs, and state location./doc-componentDocument a Svelte component using @component JSDoc. Auto-invoke when asked to document a .svelte component. Reads the component, analyzes its interface, and writes a structured @component comment block.npx claudepluginhub fubits1/svelte-skills --plugin svelte-5Other plugins' skills for the same job