/design-system:new-componentfrom design-system
Guides creation of new design-system components through 6 phases: spec, family classification, 7-dim spec, tsx, stories, and self quality-gate. Complements the review-phase quality gate.
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.
This canonical workflow contains a committed inventory of legacy assumptions. Resolve them exactly as follows; an unavailable resolution or inventory drift is ADAPTER-BLOCKED:
provider-surface-path: Resolve legacy repository paths through generated views while treating ds-canonical as the semantic owner./component-quality-gate 是 review-phase gate(元件做完後驗 35 項),但建 create-phase 沒 workflow guide → AI 每次從 AGENTS.md + canonical rules 零散規則自己湊,容易漏規則、誤套 pattern。
本 skill 填 create-phase 空缺:6 phase 帶著 AI 一步一步建元件,對齊 AGENTS.md + canonical rules 所有規則(Layout Family / Props 命名 / Spec 7 維度 / Stories 真實業務場景 / visual audit),最後自動 chain /component-quality-gate 做 exit check。
跟 /component-quality-gate 互補:create(本 skill)在元件沒寫前先指引;quality-gate 在元件寫完後驗收。兩者不重疊。
mkdir packages/design-system/src/components/Xyz/不 invoke 的情境:
/component-quality-gate/prototype(exploration 不進 DS)/component-quality-gate reviewpackages/design-system/src/components/(真的是新的)對齊 AGENTS.md mindset #2 + # 遇不確定時的協議 Step 2 + packages/design-system/ds-canonical/references/ssot-consultation.md「5-step pre-check」(寫 tsx 前必含 repository instruction SSOT 清單 + tsx 開頭「── 消費的 SSOT ──」段)。
StatusChip → 近親 Tag / Badge / Chip)MultiSelect → 近親 Select / Combobox)TimeRangePicker → 近親 DatePicker.Range / TimePicker)ls packages/design-system/src/components/ 確認名字衝突;grep AGENTS.md「失敗記憶索引」看有沒同類別的歷史 bug。check_ssot_header_declaration.sh P0 驗新檔必有)。記錄:
# 命名與語言一致性 三重 test)若名稱、scope 或 public component semantics 仍有多個可行選擇,且會導向不同產品/ UI/UX outcomes,才把唯一剩餘取捨整理成 exact target-bound P2H decision。若 user requirement、近親 SSOT 與 benchmark 已唯一決定 positioning,直接記錄 selection receipt 並進 Phase 2;不得把 checkpoint 本身當成 user approval gate。
對齊 AGENTS.md # 4-Family Layout Model。
判斷流程(照 AGENTS.md 既有):
輸出:
patterns/element-anatomy/item-anatomy 的 <MenuItem> + slot components,不重寫 row 結構對齊 packages/design-system/ds-canonical/rules/spec-rules.md。7 維度缺一不可(除非元件本質無該面向,寫「本元件無 X 狀態」):
Positioning receipt / conditional P2H checkpoint:spec 寫完先以近親 SSOT、benchmark 與 user 已明示 requirement 驗證 positioning。若答案唯一或 user 已 exact 指定,記錄 receipt 後直接進 Phase 4;只有仍有多個可行 public component semantics/UI outcomes 時,才請 user 做 exact target-bound P2H decision。不得把 spec milestone 本身當 approval gate。
對齊 packages/design-system/ds-canonical/rules/ui-development.md「shadcn 元件規範」 + packages/design-system/ds-canonical/references/cva-patterns.md。
forwardRef + cva + VariantProps + cn() + { Component, componentVariants } exportpackages/design-system/ds-canonical/rules/ui-development.md「元件 Props 命名」:
onDismiss / onClose / onClear / onRemove(語意分層,見 packages/design-system/ds-canonical/references/props-naming.md)startIcon / endIcon(type LucideIcon)avatar(type ReactNode)packages/design-system/ds-canonical/rules/ui-development.md 三層分層)bg-popover / text-muted-foreground 等)—— 用 direct tokensize="md" 對齊 field-height family(見 tokens/uiSize/uiSize.spec.md)chain /story-writing skill(如果 user 沒自己啟,本 skill 自動走其規則):
Phase 5.0 — Trait 宣告(2026-04-26 M19 ensure-canonical pipeline):
寫 stories 前,在 spec.md frontmatter 宣告元件 traits(對齊 category-templates.md v2):
---
component: {Name}
family: {1|2|3|4|self-contained}
traits:
- hasVariants # 若 cva 有 ≥ 2 visual variants
- hasSizes # 若 cva 有 ≥ 2 sizes
- hasInteractiveStates # 若有 hover/focus/disabled/loading
- isOverlay # 若是 portal-rendered overlay
- isInputLike # 若是 text/number field
- isSelectionMulti # 若是 Checkbox/Radio 多選
- isSelectionSingle # 若是 Switch 單一 toggle
- isMatrixHeavy # 若 token × size 正交視覺軸(Avatar/Skeleton)
- isStructural # 若結構主導(DataTable/Steps/Tabs)
- isInternal # 若 L3 building block
---
判斷法:讀本元件 cva variants / 行為 → 對照 traits 表 → 列適用的。scope-N/A 的 trait 在 spec.md「邊界案例 scope」段明寫 rationale(例:「Toast hasSizes=false,單尺寸對齊 Sonner idiom」)。
Phase 5.1-5.3 — 三層 stories:
{name}.stories.tsx 展示:per Phase 5.0 declared traits → 對照 category-templates.md 衍生 required core stories(hasVariants → AllVariants / hasSizes → AllSizes / isOverlay → OpenSnapshot 等)。再加 1-2 真實業務 scenario(Jira / Stripe / Notion 過 earn-existence)。Hook check_story_invariants.sh R3 category(原 check_story_category.sh folded 折入)write-time 攔不符 trait core。{name}.anatomy.stories.tsx 設計規格:5-story 標準(Overview + SizeMatrix + ColorMatrix + StateBehavior + Inspector)或合理 subset + rationale。{name}.principles.stories.tsx 設計原則:預設單一完整 UsageGuidance(何時用 + 何時不用 + sibling boundary)即 sufficient。只有 distinct topic 通過 earn-existence 才加第二篇;若採 split style,至少涵蓋 2 個不同 decision dimensions(WhenToUse / WhenNotToUse / Vs{Sibling}Rule / ContentGuidelines)。Hook check_canonical_propagation.sh E.1 write-time 同規則。兩個 test:
Mandatory。chain /component-quality-gate 走 35 項 checklist + Phase 4.5 visual audit(Layer A + B)+ Dim 27 code quality audit(2026-04-24 新:node scripts/code-quality-audit.mjs --scope=component:{Name} --check,P0 violation 必 block)。對齊 AGENTS.md # 稽核 canonical Tier 1 stakeholder-gate:元件要 merge 前 code + visual + clean-code 三層過關。
如何 chain:
/component-quality-gate skill,以本元件為 scopepackages/design-system/src/components/(explorations/ 才是實驗場;prototype 階段跑 /prototype skill)packages/design-system/ds-canonical/rules/spec-rules.md:先 spec 後 code,spec 是 judgment home)references/new-component-checklist.md — 完整 6 phase checklist + 各項 AGENTS.md pointer/component-quality-gate — review-phase gate,本 skill Phase 6 chain 進去(create/review 兩端互補)/story-writing — Phase 5 chain 進去寫 stories/design-system-audit — DS-wide audit(全 dim per design-system-audit SSOT,Phase 0 自建 baseline),不是 per-componentWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Other plugins' skills for the same job
npx claudepluginhub ajenchen/design-system --plugin design-system27 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。