Extract

educlopez/ui-craft/cli/assets/gemini/skills/extract

作者 educlopezceecc8e1fb0c2befda73da996435900d6dd0c1ac無授權條款375 個星標收錄於 2026年10月9日更新於 2026年10月9日儲存庫5 週前更新

Refactoring pass — extracts repeated Tailwind class combos and markup into components, and lifts magic values into design tokens. Use when the codebase has obvious duplication, hardcoded hex values or pixel sizes, or when the user says "clean this up" / "extract components" / "tokenize styles". Invoke when the user asks for extract on their UI, or mentions 'extract' alongside design / UI / frontend work.

AI 產生的概覽

透過把重複的 Tailwind 類別組合與標記抽取成元件、將硬編碼值提升為設計權杖,重構前端 UI 程式碼。

功能
此技能會對 UI 程式碼庫執行一次重構:掃描出現三次以上的 Tailwind 類別字串、重複的標記區塊,以及十六進位色碼、像素尺寸、陰影、字級和 z-index 等魔法數值。它會建立元件檔案與權杖補充,並沿用專案既有的命名、檔案位置與 CSS 變數慣例,而非強加新規範。接著更新所有呼叫端,並以修改前後對照表和一行差異摘要呈現結果。
適用情境
當程式碼庫出現明顯重複、硬編碼的十六進位色碼或像素尺寸時使用,也適用於使用者要求清理程式碼、抽取元件或將樣式權杖化的情況。它面向設計、UI 與前端工作,用於集中管理重複的 Tailwind 模式或字面值。
執行需求
需要代理能存取目標 UI 程式碼庫及其現有元件庫與慣例。它引用更廣泛的 ui-craft 技能,以及關於版面、字體排印與色彩的參考檔案,本身不附帶指令碼。
<!-- HARNESS MIRROR — do not edit here. Canonical source: skills/ or commands/. After editing source, copy into cli/assets/<harness>/ and repo-root harness mirrors. -->

Context: this sub-skill is one lens of the broader ui-craft skill. If the ui-craft skill is also installed, read its SKILL.md first for Discovery + Anti-Slop + Craft Test, then apply the specific lens below.

Extract reusable pieces from $ARGUMENTS. Load the ui-craft skill.

Step 1 — Scan the target for extraction candidates:

  • Repeated Tailwind class combos — any class string that appears ≥3 times becomes a component (or a cva/tv variant if the project uses one — check first).
  • Magic values — hex colors, pixel sizes, shadow definitions, font sizes, z-index values appearing in literal form. Lift into CSS variables or theme.extend.
  • Repeated markup — blocks that differ only by text/props collapse into a single component with props.

Step 2 — Match the project's conventions, don't impose new ones:

  • Naming — look at neighboring components. PascalCase file? kebab-case file? Named export vs default export? Match exactly.
  • Location — check components/ui/, ui/, primitives/, src/components/ before creating a new directory. Reuse.
  • Tokens — respect existing CSS variable naming (--color-*, --space-*, --font-*, --radius-*). Don't introduce a parallel system.

Step 3 — Anti-Slop Test on every new component (from SKILL.md):

  • Component name must be domain-specific, not generic. MetricCard / PricingTier / InviteRow beats Card / Box / Item.
  • If the component is generic ("a card with a title and description"), ask yourself whether it should instead be an inline composition — premature abstraction is worse than repetition.

Step 4 — Update every call-site. No half-migrations.

Knob-agnostic — DRY is not tunable.

References to read: references/layout.md (composition patterns), references/typography.md and references/color.md (token naming), plus the project's existing component library (scan before writing).

Output:

  1. The new component file(s) + any token additions.
  2. A table showing every call-site update:
FileBeforeAfter
  1. A one-line delta: "Extracted N components, M tokens. Call-sites updated: X."

Next step: /tokens — lift the values you just centralized into the token spine (rung 2).

來源與署名

來源:educlopez/ui-craft位於cli/assets/gemini/skills/extract提交ceecc8e

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架