/design-system:story-writingfrom design-system
Guides writing Storybook stories for design systems with real-product scenarios, anatomy 6-story structure, and registry-driven baselines. Activates when creating or reviewing .stories.tsx files.
Ships in design-system. 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.
Purpose: Storybook 是公開文件,範例 = 設計系統品質。本 skill 把「怎麼挑範例 / 怎麼寫 anatomy / 三方連動怎麼不漂移」集中成 invoke-time playbook,shared governance 只留最高準則 + 禁止清單。
.stories.tsx / .principles.stories.tsx / .anatomy.stories.tsxpackages/design-system/ds-canonical/rules/story-rules.md(三層定位 + title 命名 + 範例最高準則).spec.md 已存在且本 session 已讀(stories 必須反映 spec,不發明新規則).tsx 的 cva 定義已看過(TOKEN_MAP / SIZE_SPECS 必須與 code 一致)MUST 在 Phase 0 / 0.5 / 1+ 之前先跑:
packages/design-system/ds-canonical/references/story-baseline-registry.json。檔內列每個 primitive(Sidebar / DataTable / ChromeHeader / etc.)的:
baseline:production-grade canonical story path#StoryNamerequiredHelpers:必 import 的 helper list(WorkspaceBrand / MAIN_NAV / etc.)antiPatterns:regex + severity(block / warn)+ rationaletoolbar.buttonCanonical(DataTable — variant + size + prop combo canonical,eg. toolbar = text + sm + iconOnly + pressed)/ requiredStructure(ChromeHeader)primitive → baseline path → copied structure → deviations(if any with rationale)// @story-baseline: <path>#<StoryName> cite。(per M35 升 registry-driven,Phase 0 內容由 Phase 0.0 自動 cover。保留段供 legacy reference。)
對 {name}.stories.tsx(展示)層,寫前必走 4 步(對齊 packages/design-system/ds-canonical/references/ssot-consultation.md「5-step pre-check」— 若寫 stories 時消費其他元件 tsx,該層也適用):
references/category-templates.md)— 元件屬 A-G 哪 category,suggested core stories 是什麼?WithStartIcon+WithEndIcon → ✓ WithIcon 對照 grid)IconOnly / FullWidth / Disclosure)ColorMatrix / SizeMatrix;狀態放 StateBehavior),展示層不放OverlayBadgeOnIconOnly)Hook check_story_invariants.sh R2 slot_split write-time block 同源反 pattern。Audit /design-system-audit Dim 28 後驗。
問自己:這個 story 的受眾要做什麼?
| 目的 | 寫哪 | 職責 |
|---|---|---|
| 掃視 variant × size × state 渲染結果 | {name}.stories.tsx(展示) | 視覺目錄 |
| 查 token / 尺寸 / Inspect 面板取代 Figma | {name}.anatomy.stories.tsx(設計規格) | 技術查閱 |
| 學「何時用哪個 variant」的判斷 | {name}.principles.stories.tsx(設計原則) | 使用判斷 |
混層 = 污染(principles 放 anatomy 資料 / 展示塞 do/don't)。走錯層 → 重選。
參考 references/example-selection.md——完整合法來源 / 禁止清單 / 2 個 test / 正確範例對照 / Rule note 品質 / 視覺品質。
核心三問:
任一不過 → 改範例,不是補說明文字。
參考 references/anatomy-standard.md——每個元件 anatomy 必備 6 件套(export const Overview / Inspector / ColorMatrix / SizeMatrix / StateBehavior / Accessibility,一字不差;Accessibility 第 6 章 2026-04-24+ 對齊 Material / Polaris / Atlassian) + Inspect 面板規格 + token-first 原則 + 值溯源完整性。
偏離 canonical 規則(shared governance # 稽核 canonical「Consistency 類稽核必 Phase 0 全掃再判」;偏離需 rationale 由 design-system-audit Dim 13 enforce):
VisualTokens 取代 ColorMatrix) → 禁止/design-system-audit Dimension 13 會強制 grep 比對偏離 + rationale 追溯。
Checkpoint: 寫完後必驗:
px-1)var() inline style(dark mode 自動更新)?改 .tsx 或 .spec.md 後寫 story:
defaultVariants → grep star 預設 default 該元件所有檔案,一次改完STOP 條件:若三方(code / spec / story)任一有矛盾且原因不清楚 → 先以 canonical owner、repo evidence 與 tests 分類;只有 task/deliverable 明確要求時才加 independent review。可唯一推導的工程 drift 自主修復;只有涉及產品/UI/UX SSOT 真取捨才交 user;仍無法分類則 fail closed,不默默選邊。
參考 references/self-check.md——7 題 checklist 全部打勾才算完成:範例真實性 / 「人」test / 舉一反三 / 無極端案例 / 無代號 / Rule note 原則>結論 / 無中英夾雜。
若 meta 使用 tags: ['autodocs'],另確認 parameters.docs.description.component 已用人話說清
用途與何時用/近親分界;這是 Docs 首屏導讀,不是貼 component 名或 API 摘要。最後跑
node scripts/audit-content-quality.mjs --check,缺導讀、stub、抽象名稱、可見符號圖或 raw Markdown
任一項都不得交付。
若 story 只供 automation probe(hover/focus/open snapshot、效能量測、import smoke),在 story-level
標 tags: ['test-only']:shared runtime 只把它從 sidebar + Autodocs 隱藏,仍保留 direct URL、index
與 a11y/interaction runner。不得用 !autodocs,也不得搭配 !dev / !test;reader-facing scenario
不得為了縮短目錄而誤標 test-only。語意與 regression 由 story-rules.md +
scripts/test-storybook-test-only-semantics.mjs 看守。
references/category-templates.md — 7 category(A-G)suggested core stories(展示層 emergent typology)references/example-selection.md — 完整範例選擇原則(合法來源 / 禁止清單 / 2 test / 正確範例 / Rule note / 視覺品質)references/anatomy-standard.md — anatomy 6-story 結構 + Inspect 面板 + 品質規則references/self-check.md — 7 題自我檢查 checklistpackages/design-system/ds-canonical/rules/story-rules.md:三層定位 + title 命名(high-level signal)# 失敗記憶索引 → 三方漂移:SegmentedControl cva defaultVariants bugpre_edit_spec_check.sh;check_sync_update.sh 亦 retired/未實作)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
storybook, design-system, component-stories, anatomy-stories
27 skills in this plugin
/bug-fix-rhythmBatch-end-verify rhythm + parallel tool batch + user-listed N-rule MUST-ALL + claim runtime verify. Invoke when entering multi-fix session 或 user 列 numbered rules. Replaces M32(c)(d)(h1)(h2) sub-invariants(2026-05-12 split per Knowledge-Prune Checkpoint 2)。/canonical-reviewerReview governance changes in an isolated read-only context with explicit author identity, complete canonical evidence, and mutation detection./code-quality-auditClean code 量化稽核 — `any` 使用 / dead export / file size / long function / circular dep / magic number。補 `/design-system-audit` 只管「design canonical」的缺口。Invoke via /code-quality-audit scope=all(release / 季度)OR scope=changed(daily)OR scope=component:X(focused)。Auto-chain by `/design-system-audit --deep` Dim 27 + `/component-quality-gate` Ship phase + `/new-component` Phase 4.5。Other plugins' skills for the same job
npx claudepluginhub ajenchen/design-system --plugin design-system