Skip to content

feat(create): move storybook to CLI command#420

Merged
TkDodo merged 7 commits into
TanStack:mainfrom
huang-julien:feat/storybook_cli
Jun 16, 2026
Merged

feat(create): move storybook to CLI command#420
TkDodo merged 7 commits into
TanStack:mainfrom
huang-julien:feat/storybook_cli

Conversation

@huang-julien

@huang-julien huang-julien commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

Hi 👋

This PR moves storybook template into a CLI command.

As we're currently working on an official tanstack integration within storybook, we'd like to have storybook being called as a command for multiple reasons:

  • tanstack users will get the most up-to-date template
    • Storybook CLI can detect if there's any compatible add-on that can be added (like vitest) to make the experience closer to a full storybook integration
    • This moves the maintenance burden of the templates to storybook's side
  • allows Storybook to be aware of possible isssues in the init command

Summary by CodeRabbit

Release Notes

  • Refactor
    • Restructured the Storybook add-on for React projects. Pre-built example components and stories have been removed in favor of Storybook's official initialization command, providing a cleaner and more maintainable starting point with latest recommended configurations.

@coderabbitai

coderabbitai Bot commented Apr 1, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

All pre-built Storybook asset files for the React add-on are deleted: Storybook config (main.ts, preview.ts), five UI components (Button, Dialog, Input, RadioGroup, Slider) with their stories, the barrel index.ts, the /demo/storybook route, and the add-on package.json. info.json is updated to run npx storybook init -y --no-dev as the add-on setup command instead.

Changes

Storybook Add-on Refactor: Static Assets Removed, Init Command Added

Layer / File(s) Summary
Add-on configuration switched to init command
packages/create/src/frameworks/react/add-ons/storybook/info.json, packages/create/src/frameworks/react/add-ons/storybook/package.json
info.json replaces the prior priority/routes config with priority: 1 and a command that executes npx storybook init -y --no-dev; package.json removes storybook/build-storybook scripts and @storybook/react-vite/storybook dependencies.
Storybook config assets deleted
packages/create/src/frameworks/react/add-ons/storybook/assets/_dot_storybook/main.ts, .../preview.ts
main.ts (StorybookConfig with viteFinal Tailwind hook) and preview.ts (Preview with controls.matchers) are fully removed.
UI components and barrel index deleted
packages/create/src/frameworks/react/add-ons/storybook/assets/src/components/storybook/*.tsx, .../index.ts
Button, Dialog, Input, RadioGroup, Slider components and their prop interfaces are removed, along with the barrel index.ts that re-exported all of them.
Story files deleted
packages/create/src/frameworks/react/add-ons/storybook/assets/src/components/storybook/*.stories.ts(x)
All story files (button.stories.ts, dialog.stories.tsx, input.stories.ts, radio-group.stories.ts, slider.stories.ts) and their exported meta and story variants are removed.
Demo route deleted
packages/create/src/frameworks/react/add-ons/storybook/assets/src/routes/demo/storybook.tsx
The /demo/storybook TanStack file route and its StorybookDemo component (using all five components) are removed.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • TanStack/cli#461: Modifies the same Storybook React add-on component files (button.tsx, dialog.tsx, input.tsx, etc.) that this PR deletes entirely.

Poem

🐇 Hop hop, the scaffold is gone!
No more buttons and sliders to spawn,
With a single init call,
Storybook handles it all —
Less code to carry on! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: moving Storybook from a static template system to a CLI command initialization.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@huang-julien huang-julien marked this pull request as ready for review May 14, 2026 08:07
@TkDodo TkDodo requested a review from jherr May 20, 2026 08:31

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/create/src/frameworks/react/add-ons/storybook/info.json`:
- Line 10: The priority field in the Storybook info.json file is set to 1, but
according to the sorting logic in add-ons.ts (which uses bPriority - aPriority
for "Higher priority first"), this causes Storybook to execute second-to-last
rather than last. To ensure Storybook executes last, change the priority value
to 0 or remove the priority field entirely, since undefined values default to 0
and will execute after all higher-priority add-ons.
- Around line 12-13: The current args array in the info.json file passes the
`-y` flag to the storybook init command, but when Storybook is not cached
locally, npx itself will prompt for installation confirmation. To suppress this
prompt and enable automation, add `--yes` as the first element in the args
array, before the storybook command, so that the flag is passed to npx rather
than to storybook init.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7ecb3ae0-8a33-473e-a0d7-ceef6a3282f4

📥 Commits

Reviewing files that changed from the base of the PR and between 477dcdd and 443050e.

📒 Files selected for processing (16)
  • packages/create/src/frameworks/react/add-ons/storybook/assets/_dot_storybook/main.ts
  • packages/create/src/frameworks/react/add-ons/storybook/assets/_dot_storybook/preview.ts
  • packages/create/src/frameworks/react/add-ons/storybook/assets/src/components/storybook/button.stories.ts
  • packages/create/src/frameworks/react/add-ons/storybook/assets/src/components/storybook/button.tsx
  • packages/create/src/frameworks/react/add-ons/storybook/assets/src/components/storybook/dialog.stories.tsx
  • packages/create/src/frameworks/react/add-ons/storybook/assets/src/components/storybook/dialog.tsx
  • packages/create/src/frameworks/react/add-ons/storybook/assets/src/components/storybook/index.ts
  • packages/create/src/frameworks/react/add-ons/storybook/assets/src/components/storybook/input.stories.ts
  • packages/create/src/frameworks/react/add-ons/storybook/assets/src/components/storybook/input.tsx
  • packages/create/src/frameworks/react/add-ons/storybook/assets/src/components/storybook/radio-group.stories.ts
  • packages/create/src/frameworks/react/add-ons/storybook/assets/src/components/storybook/radio-group.tsx
  • packages/create/src/frameworks/react/add-ons/storybook/assets/src/components/storybook/slider.stories.ts
  • packages/create/src/frameworks/react/add-ons/storybook/assets/src/components/storybook/slider.tsx
  • packages/create/src/frameworks/react/add-ons/storybook/assets/src/routes/demo/storybook.tsx
  • packages/create/src/frameworks/react/add-ons/storybook/info.json
  • packages/create/src/frameworks/react/add-ons/storybook/package.json
💤 Files with no reviewable changes (15)
  • packages/create/src/frameworks/react/add-ons/storybook/assets/_dot_storybook/main.ts
  • packages/create/src/frameworks/react/add-ons/storybook/assets/src/components/storybook/radio-group.tsx
  • packages/create/src/frameworks/react/add-ons/storybook/package.json
  • packages/create/src/frameworks/react/add-ons/storybook/assets/src/components/storybook/input.tsx
  • packages/create/src/frameworks/react/add-ons/storybook/assets/_dot_storybook/preview.ts
  • packages/create/src/frameworks/react/add-ons/storybook/assets/src/components/storybook/slider.tsx
  • packages/create/src/frameworks/react/add-ons/storybook/assets/src/components/storybook/dialog.stories.tsx
  • packages/create/src/frameworks/react/add-ons/storybook/assets/src/routes/demo/storybook.tsx
  • packages/create/src/frameworks/react/add-ons/storybook/assets/src/components/storybook/radio-group.stories.ts
  • packages/create/src/frameworks/react/add-ons/storybook/assets/src/components/storybook/button.tsx
  • packages/create/src/frameworks/react/add-ons/storybook/assets/src/components/storybook/dialog.tsx
  • packages/create/src/frameworks/react/add-ons/storybook/assets/src/components/storybook/input.stories.ts
  • packages/create/src/frameworks/react/add-ons/storybook/assets/src/components/storybook/button.stories.ts
  • packages/create/src/frameworks/react/add-ons/storybook/assets/src/components/storybook/slider.stories.ts
  • packages/create/src/frameworks/react/add-ons/storybook/assets/src/components/storybook/index.ts

"jsName": "StorybookDemo"
}
]
"priority": 1,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify how add-on `priority` is sorted/consumed before command execution.
rg -n -C3 '\bpriority\b' packages/create/src
rg -n -C5 'sort\(|order|compare|priority' packages/create/src

Repository: TanStack/cli

Length of output: 50369


Storybook priority is incorrect for execution order requirement.

The sorting logic in packages/create/src/add-ons.ts (lines 9–13) uses return bPriority - aPriority with comment "Higher priority first," meaning higher numeric values execute first and lower values execute last. With priority 1, Storybook will run second-to-last; only add-ons with priority 0 (or undefined, which defaults to 0) run after it.

If the PR objective requires Storybook to execute last, change priority to 0 or remove the field entirely.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/create/src/frameworks/react/add-ons/storybook/info.json` at line 10,
The priority field in the Storybook info.json file is set to 1, but according to
the sorting logic in add-ons.ts (which uses bPriority - aPriority for "Higher
priority first"), this causes Storybook to execute second-to-last rather than
last. To ensure Storybook executes last, change the priority value to 0 or
remove the priority field entirely, since undefined values default to 0 and will
execute after all higher-priority add-ons.

Comment on lines +12 to +13
"command": "npx",
"args": ["storybook", "init", "-y", "--no-dev"]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, let's check the actual file content and surrounding context
cat -n packages/create/src/frameworks/react/add-ons/storybook/info.json

Repository: TanStack/cli

Length of output: 516


🏁 Script executed:

# Check the add-on schema and execution code mentioned in the original scratchpad
fd -e ts packages/create/src/ | head -20

Repository: TanStack/cli

Length of output: 442


🏁 Script executed:

# Search for how commands are executed in the codebase
rg "environment\.execute" packages/create/src/ -A 3 -B 1

Repository: TanStack/cli

Length of output: 2983


🌐 Web query:

npx --yes flag suppress installation prompts

💡 Result:

Yes, the --yes flag (or its shorthand -y) can be used with npx to automatically accept installation prompts [1][2]. When you run an npx command for a package that is not already installed in your local project, npx typically displays a prompt asking for permission to install the package [1][3]. By adding --yes or -y to your command, you explicitly suppress this confirmation prompt, allowing the installation to proceed automatically [1][4]. This is particularly useful for running commands programmatically or in non-interactive environments, such as CI/CD pipelines [5]. Conversely, you can also use the --no flag if you need to reject the prompt [1][2].

Citations:


🌐 Web query:

npx storybook init interactive prompt behavior

💡 Result:

When running npx storybook@latest init (or using npm create storybook), the Storybook CLI utilizes an interactive, Clack-based UI to guide users through the installation process [1][2]. These prompts help configure your project by asking questions such as: - Whether you are new to Storybook (which may trigger an onboarding tour) [1][3]. - What configuration type you prefer (e.g., Recommended vs. Minimal) [3]. - Framework-specific choices, such as selecting between React Native and React Native Web [4]. If you wish to bypass these interactive prompts—for instance, for automated CI/CD pipelines—you can use the --yes flag [2][5]. Important Note for NPM Users: If you are using npm, the --yes flag may not be correctly passed to the Storybook CLI unless you use a double dash (--) separator [6]. NPM interprets flags before the double dash as its own, while those after are passed to the executed command [6]. For a non-interactive installation, use the following syntax: npm create storybook@latest -- --yes [6] Yarn and pnpm do not require this double-dash separator to pass the flag correctly [6]. Additionally, you can use the --features flag to explicitly select features (e.g., docs, test, a11y) and skip the corresponding prompts [2][7]. Using these flags ensures a non-interactive setup identical to a standard installation [2].

Citations:


Add --yes to npx to suppress installation prompt on first run.

The -y flag in the current args applies to storybook init, not to npx itself. When Storybook is not cached locally, npx storybook ... will prompt for installation confirmation and block automation. Pass --yes as the first argument to npx to suppress this prompt.

Suggested change
   "command": {
     "command": "npx",
-    "args": ["storybook", "init", "-y", "--no-dev"]
+    "args": ["--yes", "storybook", "init", "-y", "--no-dev"]
   }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/create/src/frameworks/react/add-ons/storybook/info.json` around
lines 12 - 13, The current args array in the info.json file passes the `-y` flag
to the storybook init command, but when Storybook is not cached locally, npx
itself will prompt for installation confirmation. To suppress this prompt and
enable automation, add `--yes` as the first element in the args array, before
the storybook command, so that the flag is passed to npx rather than to
storybook init.

@TkDodo TkDodo merged commit b0c8ec9 into TanStack:main Jun 16, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants