design-system-extractor/SKILL.md
Extract a reusable design-system specification from UI screenshots/images, Figma URLs or exports, Figma Variables, existing app/project folders, or prototype code. Use when Codex must produce evidence-backed design principles, design elements, token architecture, component inventory, component token specs, anti-AI style constraints, static HTML documentation for developers, cross-agent handoff guidance for Claude Code/Cursor/Codex, and a checkpoint before any product implementation.
npx skillsauth add harrychuang/cursor-skills design-system-extractorInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Act as a Design System Architect. Extract a reusable design-system package from visual and code references. Do not implement product screens during this skill unless the user explicitly chooses that after the checkpoint.
<skill-root>. Use <skill-root>/assets/... and <skill-root>/scripts/... when copying templates or running bundled scripts.<skill-root>/assets/design-system-template/ into the target root.AGENTS.md, CLAUDE.md, .cursorrules, .cursor/rules/*, and prior design-system/SESSION_STATE.md when present.Record source types, paths/URLs, confidence, and known gaps in design-system/SESSION_STATE.md.
For screenshots, list every image. For Figma, list node/page names, component set names, variable collections, and MCP-ready identifiers when available. For project folders, list token files, component directories, Storybook entries, and screenshot/render routes if available.
Before using sources as evidence, run a source duplicate review:
design-system/DESIGN_EVIDENCE_MAP.md.sha256:<hash> for exact matches and add phash:<hash> or a screenshot crop note when perceptual comparison is available.figma:<file-key>#<node-id> when a node is known, or figma:<file-key>#page:<page-name> when only a page is known. Use MCP node-id form with : in fingerprints and retain URL node-id form with - in the URL.reuse existing source, ignore duplicate, or keep distinct.design-system/DESIGN_EVIDENCE_MAP.md under Source Duplicate Review before using duplicate inputs to support separate design decisions.Fill design-system/DESIGN_EVIDENCE_MAP.md before writing final design decisions.
Each important decision needs an evidence row with:
Use references/visual-analysis-rubric.md when evaluating screenshots or rendered UI.
For Figma sources, DESIGN_EVIDENCE_MAP.md must preserve enough information for a downstream agent to call Figma MCP without re-discovering the source:
node-id when available12:34get_design_context and get_screenshot for component nodes, get_metadata for page-level sources, and get_variable_defs for variable collectionsIf Figma MCP is unavailable during extraction, still record the URL, page/frame/node names visible from the prompt or export metadata, and mark the MCP target as unresolved - MCP unavailable instead of dropping the trace.
Fill design-system/DESIGN_PRINCIPLES.md and design-system/DESIGN_ELEMENTS.md.
Cover color proportions, typography, text composition, spacing, density, shape, elevation/depth, iconography, imagery, data display, and state language. Every principle must include evidence and an implementation rule.
For graphic design references, inspect typography as composed structures, not only individual type tokens. Capture repeated or reusable combinations such as headline + kicker, headline + deck, eyebrow + title + body, price + qualifier, metric + label, caption overlays, editorial pull quotes, CTA text clusters, and stacked brand statements. Record hierarchy, line breaks, alignment, rhythm, optical spacing, case, tracking, max line length, emphasis, and relationship to nearby imagery or containers.
Fill design-system/TOKEN_ARCHITECTURE.md and token files under tokens/.
Default to strict ref -> sys -> comp inheritance when the project has no stronger convention:
Use references/token-architecture.md before creating or changing token layers.
Before finalizing token files, run a token candidate review:
100 is lightest and 0 is darkest.ref -> sys -> comp, resolve each system/component token to its raw reference value, and compare purpose fingerprints before deduping. Purpose fingerprints include layer, semantic role, component name/category, slot/anatomy, state, resolved raw value, and inheritance chain.merge or keep distinct.design-system/TOKEN_ARCHITECTURE.md under Near Token Decisions, or add an adjacent token-review: CSS comment when the decision must stay next to the token.ref, sys, and comp tokens.Fill design-system/COMPONENT_INVENTORY.md.
Inventory repeated patterns from the references. Mark each component as extracted, planned, blocked, or out-of-scope. Include priority, observed sources, required token groups, missing states, and implementation notes.
Treat reusable text compositions as component candidates even when they come from flat graphic references rather than app UI. Name them with typographic- or a clear product role, such as typographic-hero-lockup, typographic-section-heading, typographic-metric-pair, typographic-price-stack, typographic-caption-overlay, or typographic-pull-quote. Mark them extracted when the component spec and component tokens exist, planned when the visual structure is observed but implementation details need another pass, and out-of-scope only when the text treatment is clearly one-off artwork.
Before finalizing inventory or adding a new component spec, run a component similarity review:
COMPONENT_INVENTORY.md, design-system/components/*.md, and relevant component tokens.node <skill-root>/scripts/audit_components.mjs <target-root> during extraction to surface automatically detected fingerprint similarities before strict checkpoint.merge, make variant, keep distinct, or block pending more evidence.COMPONENT_INVENTORY.md under Component Similarity Review before creating or updating component specs.design-system/assets/component-review/ and link them from the similarity table.schematic fallback - source preview unavailable; it is not design evidence.Extract at least one high-value component when the user did not specify one, usually the primary action component for product UI or the most reusable typographic composition for graphic design references. Extract additional repeated shell/navigation components when they are central to the reference.
For each extracted component, create design-system/components/<component-name>.md from design-system/COMPONENT_SPEC_TEMPLATE.md and update tokens/tokens-comp.css. Use lowercase hyphen-case filenames, such as primary-button.md or bottom-navigation.md.
For each component spec, fill Source Trace whenever source material exists. Include the exact Figma node or design URL, Figma MCP target (fileKey, nodeId, page/frame/node names, suggested MCP calls), screenshot crop/export path, rendered route with viewport/state, prototype/source files, and existing product component candidates. If a trace type is unavailable, mark it not available with a short reason instead of leaving it ambiguous.
When a component comes from Figma, do not treat a screenshot crop as a replacement for the Figma source trace. The crop is a visual reference; the Figma URL and MCP target are the handoff path for downstream implementation.
Use references/component-spec-rules.md for anatomy, variants, state coverage, accessibility, and token naming.
For typographic components, the spec must define text slots, hierarchy, responsive wrapping, line-count limits, alignment, spacing between text lines/groups, allowable emphasis, truncation rules, and content semantics. Component tokens should cover the composition slots, such as title, kicker, body, metadata, value, qualifier, divider, and caption, while mapping each slot back to system typography, color, spacing, and alignment tokens.
Fill or update:
design-system/PAGE_COMPOSITION_RULES.mddesign-system/INTERACTION_STATES.mddesign-system/ANTI_AI_STYLE_RULES.mdUse references/page-composition-rules.md and references/anti-ai-style-rules.md.
The output must protect the observed product character. Do not add generic SaaS hero layouts, decorative gradients, glassmorphism, outline-card overuse, inflated whitespace, or unsupported illustration styles unless the references prove those patterns exist.
Generate developer-facing static HTML docs after design-system Markdown and token files are updated:
node <skill-root>/scripts/generate_docs_html.mjs <target-root>
node <skill-root>/scripts/generate_review_html.mjs <target-root>
Default outputs:
docs/design-system/index.html
docs/design-system/review.html
The HTML shell supports zh-Hant (default), en, and ja UI locales with a sidebar language switcher. Markdown body content remains in the extraction language.
Use references/html-documentation.md when changing the HTML documentation behavior.
Run strict source, token, and component audits after an extraction or component expansion:
node <skill-root>/scripts/audit_sources.mjs <target-root> --strict
node <skill-root>/scripts/audit_tokens.mjs <target-root> --strict
node <skill-root>/scripts/audit_components.mjs <target-root> --strict
Use non-strict mode only for an empty starter package or early setup check.
Update design-system/SESSION_STATE.md with:
Then stop and ask the user what to do next. Suggested choices:
Use this pass when the user chooses to expand component tokens after the initial extraction.
planned components from design-system/COMPONENT_INVENTORY.md.design-system/DESIGN_EVIDENCE_MAP.md.design-system/components/<component-name>.md from design-system/COMPONENT_SPEC_TEMPLATE.md.tokens/tokens-comp.css; component tokens must reference system tokens only.COMPONENT_INVENTORY.md status and missing states.docs/design-system/index.html and docs/design-system/review.html.node <skill-root>/scripts/audit_sources.mjs <target-root> --strict, node <skill-root>/scripts/audit_tokens.mjs <target-root> --strict, and node <skill-root>/scripts/audit_components.mjs <target-root> --strict.SESSION_STATE.md, then stop and ask for the next step.If an important design rule has no source evidence, mark it Low confidence or ask the user before making it normative.
Do not count duplicate screenshots, duplicate Figma nodes, or duplicate rendered routes as independent evidence until the duplicate source decision is recorded. If a source fingerprint matches or appears very close to another source, ask the developer for a reuse/ignore/keep-distinct decision before it changes confidence.
If a component needs a semantic or component token that does not exist, create or propose the token at the correct layer. Never use hardcoded fallback values in implementation guidance.
Do not silently merge or split close token values. When near duplicate colors or numbers are found, ask the developer for a merge/keep-distinct decision and document it before the checkpoint.
Do not silently create system/component token aliases that resolve to the same value in the same semantic audit group. If duplicate aliases are intentional, document why they must remain distinct.
Do not dedupe component tokens only because their reference values are close. Use the inheritance chain and usage fingerprint first; component tokens in different component categories or slots can stay distinct when their purpose differs.
Before adding a new component spec, check COMPONENT_INVENTORY.md and existing component docs. Reuse or extend a known component when intent, anatomy, slots, and states match.
Do not create a new component only because the Figma layer name is new. If a candidate resembles an existing component, present the visual comparison and fingerprint difference, then ask for a merge/variant/keep-distinct/block decision.
Strict component audit automatically compares component fingerprints. If it reports an automatic similarity candidate, resolve it in COMPONENT_INVENTORY.md before treating the extraction as complete.
When a source is Figma, do not mark the extraction ready for implementation until Figma source rows and affected component specs include either a usable Figma URL plus MCP target, or a documented reason why the target cannot be resolved. Downstream Storybook implementation depends on these traces to inspect the original node with Figma MCP before writing component code.
Do not generate product UI code, Storybook implementation code, or app routes inside this skill before the checkpoint unless the user explicitly requests product implementation.
If the user wants to use the extraction package with Claude Code, Cursor, or Codex, read references/agent-integration.md and generate the appropriate instruction files from the extracted rules. Keep agent instructions short and point them back to the design-system docs, token audit, and Figma MCP source traces.
references/visual-analysis-rubric.md: how to analyze images, Figma, and rendered UI.references/token-architecture.md: token naming and inheritance rules.references/component-spec-rules.md: component anatomy, state, accessibility, and token spec rules.references/page-composition-rules.md: layout, density, page shell, and composition rules.references/anti-ai-style-rules.md: constraints that prevent generic AI-looking UI.references/agent-integration.md: Claude Code, Cursor, and Codex handoff guidance.references/html-documentation.md: static HTML documentation output rules.assets/design-system-template/: starter output package.scripts/audit_sources.mjs: source inventory and duplicate source review audit; pass --strict after real extraction work.scripts/audit_tokens.mjs: token layer audit; pass --strict after real extraction work.scripts/audit_components.mjs: component similarity review audit; pass --strict after inventory or component spec changes.scripts/generate_docs_html.mjs: generated developer-facing HTML docs, including design-system/components/*.md.scripts/generate_review_html.mjs: generated visual review queue for duplicate sources, near tokens, color scale issues, and similar components.development
Build or update token-backed Storybook foundations, shared UI components, and stories from an extracted design-system package. Use after design-system-extractor, or when Codex must read design-system Markdown and token files, automatically trace original design sources such as Figma URLs/nodes, UI images, rendered routes, and frontend folders, infer component dependency order so core primitives are built before composed components, map component specs into a product repo, create or update Storybook docs, plan component batches, and verify implementation with the bundled Figma export addon without bypassing tokens.
development
Create, apply, audit, and understand Variables in Figma using Google Material Design's three-tier token inheritance (Ref → Sys → Comp). Use when: creating Variables for components or screens, applying existing Variables to nodes, auditing token naming and structure for compliance, or having AI read existing Variables to reverse-engineer design components. Triggers: create Variables, apply Variables, Figma variables, M3 token, design token, token inheritance, token audit, audit variables, design component from variables, three-tier token.
tools
Turn screenshots or Figma exports into token-backed Storybook components and composed product screens.
tools
Turn screenshots or Figma exports into token-backed Storybook components and composed product screens.