svelte-storybook-setup — Claude Code command: Storybook setup
Sets up Storybook for SvelteKit projects with framework settings, addons, story folders, and npm scripts.
npx claude-code-templates@latest --command svelte/svelte-storybook-setupWhat svelte-storybook-setup does
This slash command prepares Storybook for a SvelteKit project. It can start setup with npx storybook@latest init or guide a manual configuration using @storybook/sveltekit, Svelte CSF, accessibility, and interaction addons.
The command creates .storybook/main.js and .storybook/preview.js, imports src/app.css, discovers stories under src/**/*.stories.@(js|ts|svelte), and serves files from ../static. It also lays out component stories under src/lib/components and documentation stories under src/stories, then adds Storybook and Chromatic scripts.
The generated configuration points to ../static, so the project needs that static-assets directory in its expected location. Manual setup also covers module mocking, path aliases, and SvelteKit SSR considerations.
What it helps with
- set up Storybook in a SvelteKit project
- add native Svelte stories with
@storybook/addon-svelte-csf - enable accessibility and interaction checks
- organize components and
.stories.sveltefiles - add Storybook and Chromatic npm scripts
Example prompts for the agent
- Set up Storybook for my SvelteKit project with
/svelte:storybook-setup. - Inspect the project and create component stories under
src/lib/components. - Add
@storybook/addon-a11yand configure thestorybookandbuild-storybookscripts.
How to install svelte-storybook-setup
1claude-code-templates
npx claude-code-templates@latest --command svelte/svelte-storybook-setup2Manually: put the files in place
.claude/commands/svelte-storybook-setup.mdCall it with /svelte-storybook-setup. For all projects use ~/.claude/commands/
Manually: put the files in place
~/.codex/prompts/svelte-storybook-setup.mdCall it with /prompts:svelte-storybook-setup. Codex marks this format deprecated in favour of skills
Manually: put the files in place
.github/prompts/svelte-storybook-setup.prompt.mdManually: put the files in place
.gemini/commands/svelte-storybook-setup.tomlGemini stores commands as TOML: the prompt text goes into the prompt field
Questions about svelte-storybook-setup
How do I install svelte-storybook-setup in Claude Code?
Run npx claude-code-templates@latest --command svelte/svelte-storybook-setup, then create .claude/commands/svelte-storybook-setup.md.
What does svelte-storybook-setup do?
It configures Storybook for SvelteKit, creates .storybook settings, adds relevant addons, organizes story files, and defines npm scripts.
Which Storybook integrations does the command configure?
It uses @storybook/sveltekit, Svelte CSF, accessibility, interactions, and Chromatic. The setup also addresses module mocking, path aliases, and SvelteKit SSR.
Source text
svelte-storybook-setup.md · MIT
---
description: "Initialize and configure Storybook for SvelteKit projects with optimal settings and structure."
---
# /svelte:storybook-setup
Initialize and configure Storybook for SvelteKit projects with optimal settings and structure.
## Instructions
You are acting as the Svelte Storybook Specialist Agent focused on Storybook setup. When setting up Storybook:
1. **Installation Process**:
**New Installation**:
```bash
npx storybook@latest init
```
**Manual Setup**:
- Install core dependencies
- Configure @storybook/sveltekit framework
- Add essential addons
- Set up Svelte CSF addon
2. **Configuration Files**:
**.storybook/main.js**:
```javascript
export default {
stories: ['../src/**/*.stories.@(js|ts|svelte)'],
addons: [
'@storybook/addon-essentials',
'@storybook/addon-svelte-csf',
'@storybook/addon-a11y',
'@storybook/addon-interactions'
],
framework: {
name: '@storybook/sveltekit',
options: {}
},
staticDirs: ['../static']
};
```
**.storybook/preview.js**:
```javascript
import '../src/app.css'; // Global styles
export const parameters = {
actions: { argTypesRegex: '^on[A-Z].*' },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/i
}
},
layout: 'centered'
};
```
3. **Project Structure**:
```
src/
├── lib/
│ └── components/
│ ├── Button/
│ │ ├── Button.svelte
│ │ ├── Button.stories.svelte
│ │ └── Button.test.ts
│ └── Card/
│ ├── Card.svelte
│ └── Card.stories.svelte
└── stories/
├── Introduction.mdx
└── Configure.mdx
```
4. **Essential Addons**:
- **@storybook/addon-essentials**: Core functionality
- **@storybook/addon-svelte-csf**: Native Svelte stories
- **@storybook/addon-a11y**: Accessibility testing
- **@storybook/addon-interactions**: Play functions
- **@chromatic-com/storybook**: Visual testing
5. **Scripts Configuration**:
```json
{
"scripts": {
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build",
"test-storybook": "test-storybook",
"chromatic": "chromatic --exit-zero-on-changes"
}
}
```
6. **SvelteKit Integration**:
- Configure module mocking
- Set up path aliases
- Handle SSR considerations
- Configure static assets
## Example Usage
User: "Set up Storybook for my new SvelteKit project"
Assistant will:
- Check project structure and dependencies
- Run Storybook init command
- Configure for SvelteKit framework
- Add Svelte CSF addon
- Set up proper file structure
- Create example stories
- Configure preview settings
- Add helpful npm scripts
- Set up GitHub Actions for Chromatic
© davila7 · MIT · davila7/claude-code-templates