Extract

educlopez/ui-craft/.agents/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 等字面量魔法值。它创建新的组件文件和令牌补充,遵循项目现有的命名、目录位置和令牌约定,并更新所有调用点。产出包括新组件文件、调用点变更表格,以及一行提取组件与令牌数量的摘要。
适用场景
当代码库存在明显重复、硬编码十六进制值或像素尺寸时使用,也适用于用户要求清理代码、提取组件或对样式做令牌化时。它面向设计、UI 或前端工作中需要合并重复模式的场景。
运行要求
仅包含指令,不附带脚本。需要具备 Tailwind 类名的 UI 代码库,最好已安装更上层的 ui-craft 技能,并需要 references/layout.md、references/typography.md、references/color.md 等参考文件。
<!-- 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位于.agents/skills/extract提交ceecc8e

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架