Install
openclaw skills install @namepain/style-extractor从 URL、截图或前端项目源码中逆向提取 UI 视觉风格,产出三层 Design Token 系统(Primitive → Semantic → Component),封装为可复用的 WorkBuddy 通用风格技能。
openclaw skills install @namepain/style-extractorExtract a complete design system from any web page, image, or codebase and package it as a reusable WorkBuddy style skill.
This skill provides a multi-phase pipeline with optional mode splitting:
| Phase | Mode | Output |
|---|---|---|
| Phase 1 — Audit | Audit-only mode | Evidence inventory, raw values, duplicates, drift, exceptions |
| Phase 2 — Design | Design mode | Three-layer tokens (Primitive → Semantic → Component), naming, theme mappings |
| Phase 3 — Package | Generate mode | Complete WorkBuddy style skill with all references |
| Phase 4 — Verify | Verify mode | Format, reference, theme, and state validation + optional demo page |
By default, run all phases. The user can request audit-only, design-only, or verify-only mode.
Every extracted value MUST be tagged with one of four evidence levels:
| Grade | Label | Meaning |
|---|---|---|
| D | 已定义 (Defined) | Found in existing CSS variables, theme config, or design token files |
| M | 已测量 (Measured) | Confirmed from source code references, browser computed styles, or rendered output |
| I | 有依据的归纳 (Inferred) | Reasonably deduced from repeated patterns across multiple pages/components |
| A | 暂时假设 (Assumed) | Best guess based on limited data; MUST be explicitly flagged for user review |
Never present an assumed value as a confirmed fact. The evidence grade determines how aggressively the token can be used in migration.
Tokens are organized into three layers, NOT a flat list:
Primitive (原材料) → color.blue.600, space.4, radius.md, font.size.lg
↑ reference only — do not use in components directly
Semantic (设计角色) → color.action.primary, color.bg.surface, space.container.padding
↑ components use these
Component (组件特化) → button.primary.bg.default, input.border.focus, dialog.shadow
↑ only when semantic tokens are insufficient
Why three layers matters:
#FFFFFF in light theme = page background; in dark theme = inverse text. Same primitive value, DIFFERENT semantic roles. If merged into one flat --white, theme switching breaks.color.blue.600 could be used for buttons, links, and focus rings. If a component references the primitive directly, changing the brand color requires hunting down every usage. If it references color.action.primary (which maps to color.blue.600), it changes everywhere at once.Layer decision rules:
Do NOT create a component token when:
card.background.default when it's always color.bg.surface)When the user provides an input, determine the type and follow the corresponding workflow:
| Input Type | Detection | Workflow Section |
|---|---|---|
| URL | starts with http:// or https:// | URL Extraction |
| Screenshot / Image | file path ending in .png, .jpg, .jpeg, .webp, .gif | Screenshot Extraction |
| Project Directory | local folder path | Project Source Extraction |
If input type is ambiguous, ask the user to clarify.
Before extraction:
notion, stripe, my-brand)"brand-style-{name}When input is a URL:
--* variables (grade D), which are inline (grade M), and which are computed (grade M)@font-face vs system stack vs Google FontsTailwind Detection: If the page uses Tailwind CSS, map utility classes to computed values and document both the class name and the equivalent CSS. Grade these as D (defined in config) or M (observed in DOM).
CSS Variable Detection: If the page uses CSS custom properties, extract the full variable hierarchy. These are grade D. Note any variables that reference other variables (e.g., --color-text-primary: var(--gray-900)).
When input is a screenshot/image:
When input is a local project directory:
**/*.css, **/*.scss, **/*.less → grade D/Mtailwind.config.{js,ts,mjs,cjs} → grade D**/theme.{js,ts,tsx}, **/tokens.{js,ts,json} → grade D**/GlobalStyles.{js,ts,tsx}, **/styled.{js,ts,tsx} → grade Mtheme.extend.colors, theme.extend.fontFamily, etc. → grade D:root { } blocks → grade D, but note if variables reference other variablesAfter cataloging raw values, analyze them. See references/common-pitfalls.md for what to avoid.
Output a structured issues list:
#FFFFFF as both page background and inverse text) — these MUST become separate semantic tokensPrimitive tokens — raw materials only:
color.blue.50 → #E8F3FF color.blue.500 → #165DFF color.blue.900 → #001B4D
color.gray.50 → #F7F8FA color.gray.500 → #86909C color.gray.900 → #1D2129
space.1 → 4px space.2 → 8px space.4 → 16px space.6 → 24px
radius.sm → 2px radius.md → 4px radius.lg → 8px
font.size.sm → 12px font.size.base → 14px font.size.lg → 16px
Semantic tokens — design roles referencing primitives:
color.action.primary → color.blue.500
color.action.primary.hover → color.blue.400
color.bg.page → color.gray.50 (light) / color.gray.900 (dark)
color.bg.surface → white (light) / color.gray.800 (dark)
color.text.primary → color.gray.900 (light) / white (dark)
color.text.secondary → color.gray.500
color.border.default → color.gray.200
space.container.padding → space.6
shadow.overlay → {specific shadow}
Show theme mappings for light/dark if applicable. When the same primitive maps to different semantics in different themes, this is exactly why the three-layer system exists — document it explicitly.
Component tokens — only where necessary:
button.primary.bg.default → color.action.primary
button.primary.bg.hover → color.action.primary.hover
input.border.focus → color.action.primary (with alpha)
dialog.shadow → shadow.overlay
table.row.height.compact → 36px
If a component token simply equals a semantic token (e.g., card.bg → color.bg.surface), do NOT create it — just document that cards use color.bg.surface.
Some values are genuinely local and should NOT become tokens:
Document these in the output's Known Gaps / Exceptions section with justification.
Generate the output style skill using the templates in assets/style-skill-template/.
brand-style-{name}/
├── SKILL.md # YAML frontmatter + three-layer overview + quick reference
├── references/
│ ├── colors.md # Primitive color scales + Semantic color roles + theme mappings
│ ├── typography.md # Primitive font scale + Semantic text roles
│ ├── spacing.md # Primitive spacing/radius/shadow scales + Semantic layout tokens
│ ├── components.md # Component tokens and patterns
│ └── known-gaps.md # Unresolved discrepancies, exceptions, assumptions
See references/output-format.md for the detailed specification. Key requirements:
SKILL.md: Must include YAML frontmatter with structured token data. See the template.
All reference files: Every token table must include an Evidence column (D/M/I/A).
known-gaps.md: Required. Documents:
After generating all files, run the validations in references/validation-checklist.md:
{colors.xxx} style reference resolves to a defined tokenReport: file path, total lines, token counts per layer, grades distribution, validation results, and remaining Known Gaps.
After generating the skill, optionally validate it's actually usable:
These are the five most common extraction mistakes. See references/common-pitfalls.md for full details.
#165DFF to color-blue-500 is just a rename. The real value is mapping it to semantic roles that survive theme changes.references/extraction-checklist.md — Comprehensive token extraction checklist with evidence gradingreferences/output-format.md — Detailed specification for output file format and three-layer structurereferences/validation-checklist.md — Post-generation validation steps and criteriareferences/common-pitfalls.md — The five most common extraction mistakes and how to avoid themassets/style-skill-template/ — Template directory for generated style skills