storybook-startup-benchmark
它能做什么
这个技能引导 AI 测量 Storybook 的启动时间,从启动服务器到显示第一个 story。适合希望比较不同版本或改动之间速度的开发者。
适用场景
- ✓当你想知道 Storybook 在你的项目中需要多长时间才能启动的时候。
- ✓当你怀疑某个新版本让 Storybook 启动变慢的时候。
- ✓当你想通过重复测量来比较两个版本或设置的时候。
技能链接
https://github.com/storybookjs/storybook/blob/next/.agents/skills/storybook-startup-benchmark/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请帮我测量我们的 Storybook 启动需要多长时间,运行五次,并给我平均值。”
每周 5 个新技能,1 分钟读完。
工作原理
AI 启动 Storybook 但不自动打开浏览器,等待服务器响应,然后打开页面,计时第一个 story 出现所需的时间。它可以重复运行并汇总结果。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Storybook Startup Benchmark
Purpose
Use this skill to build or explain a repeatable benchmark for Storybook startup:
server: process spawn -> Storybook server respondsbrowser: server responds -> first story renderedtotal: process spawn -> first story rendered
Quick Start
When asked to benchmark Storybook startup:
- Confirm the boundary:
- Start timing immediately before spawning
storybook dev - Open Storybook at
/, notiframe.html - Stop timing on first story mount plus one
requestAnimationFrame()
- Start timing immediately before spawning
- Check whether the repo already has a benchmark script. Reuse it if possible.
- If not, create a Node script that:
- starts Storybook without opening a browser
- waits for the server to respond
- launches a browser it controls
- waits for a preview-side render signal
- prints JSON results
- Add
--repeat <count>support with grouped summary stats.
Measurement Rules
Use these defaults unless the user asks otherwise:
- Start URL:
/ - Browser path: normal manager page, let Storybook load the preview iframe itself
- Render signal: first preview story mount + one
requestAnimationFrame() - Browser launch: external harness launches the browser, not Storybook
- Auto-open: keep Storybook from opening a browser. Storybook 11 opens one only with
--open; Storybook 10 and older need--no-open
Do not measure only CLI output. Server listening is not the same as first story rendered.
Recommended Implementation
1. Preview-side signal
Add a small global preview decorator or component that runs once on the first story mount:
- wait one
requestAnimationFrame() - set a global value like
window.__sbStartupBenchmark - also mirror that value to
window.topwhen same-origin - optionally call
performance.mark('sb:first-story-rendered')
Preferred payload:
{
firstStoryRenderedAt: performance.now(),
storyId: id
}
2. Harness behavior
The benchmark script should:
- Fail fast if the target Storybook port is already in use
- Spawn Storybook without opening a browser
- Start timing immediately before spawn
- Wait for HTTP readiness on the Storybook URL
- Launch a controlled browser to
/ - Wait for the preview-side signal
- Print JSON results
- Kill the full spawned process group during cleanup
3. Repeated runs
For --repeat N, print:
- per-run results
- summary stats grouped by
server,browser, andtotal - human-readable durations like
5.2sor2m15s, not raw millisecond field names
Recommended summary fields:
{
"server": {
"average": "5.2s",
"min": "4.8s",
"max": "6.1s",
"p95": "6.0s"
},
"browser": {
"average": "1.9s",
"min": "1.6s",
"max": "2.4s",
"p95": "2.3s"
},
"total": {
"average": "7.1s",
"min": "6.6s",
"max": "8.2s",
"p95": "8.1s"
}
}
Interpretation Guidance
Use these heuristics when explaining results:
- If
servergrows, the regression is likely on the server/build side. - If
browsergrows, the regression is likely in manager boot, preview boot, or first-story render. - If averages are close but
p95grows a lot, the feature likely increases variability or tail latency. - If newer Storybook without a feature is much faster than older Storybook, but enabling the feature returns timings to older levels, the feature likely erases the newer startup gains.
Common Pitfalls
- Existing Storybook already running on the benchmark port
- Storybook auto-opening a separate browser window
- Measuring direct
iframe.htmlloads instead of normal/ - Leaving child Storybook processes alive between runs
- Treating warm repeated runs as cold-start data
If a repeated benchmark reports unrealistically low server.average, first check for a stale Storybook server on the same port.
Tooling Notes
- Prefer a plain Node script for portability.
- For Chrome-family browsers, remote debugging is a practical control path.
- If Storybook CLI flags or behavior are in question, fetch current Storybook docs first.
Output Style
When reporting results:
- clearly separate
server,browser, andtotal - call out averages and p95 first, with min/max as supporting bounds
- highlight whether the regression affects common-case latency, tail latency, or both
- avoid claiming root cause unless the benchmark isolates server vs render behavior
Example Triggers
Use this skill when the user says things like:
- "How can I test Storybook
常见问题
测量的是哪些时间?
三部分:服务器启动时间、浏览器显示第一个 story 的时间,以及总时间。
它会打开浏览器窗口吗?
说明中提到,Storybook 不应自动打开浏览器,由外部测试工具负责启动浏览器。
它能比较不同版本吗?
能。该技能说明,它可以通过重复运行来比较 Storybook 版本或功能开关。
详情
作者的原始描述
Measure Storybook startup time from spawning `storybook dev` until the first story renders in the browser. Use when the user asks about Storybook boot time, server-ready timing, first story render timing, startup regressions, benchmarking with repeat runs, or comparing Storybook versions or feature flags.
repo: storybookjs/storybook
热度
- GitHub 星标
- 91k
- 排名
- #1321
- 许可证
- MIT
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
handle-pr-comments
91k帮你的智能体逐条处理 GitHub 拉取请求的审查意见,建议修复方案,应用你的选择,并把讨论串标为已解决。
principle-encode-lessons-in-structure
91k教你的智能体把反复出现的错误转化为自动检查,例如 lint 规则或脚本,而不是一再写下同样的提醒。
storybook-upgrade
91k教你的智能体把项目中的所有 Storybook 包升级到指定版本,每次只升级一个大版本。
update-pr-description
91k帮你的智能体检查拉取请求的标题和描述是否仍与代码改动相符,然后提出准确的更新建议。