extracting-design-systems
Extract a complete, Figma-grade design system from the HTML mocks in docs/mocks/ into docs/design-system/: design tokens (colour with light and dark themes, typography, spacing, layout grid with gutters and margins, radius, elevation, motion, z-order), foundation pages, one HTML page per component with anatomy, variants, sizes, every state, responsive behaviour, theming, WCAG 2.2 AA accessibility, content rules, do/don't, tokens and code, plus patterns, a DTCG tokens.json and verified contrast. Use whenever the user mentions a design system, style guide, component library, UI kit, pattern library, tokens, theming, dark mode, brand colours, type or spacing scale, accessibility or contrast audit, or asks to make the UI consistent, document the components, extract the styles, or build frontend components from mocks; and proactively after writing-html-mocks finishes or when docs/mocks exists without docs/design-system. Requires docs/mocks; if absent, run writing-html-mocks first.
- License 许可
- MIT
- 最近更新
- 2026-10-19
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- extracting-design-systems
- description
- Extract a complete, Figma-grade design system from the HTML mocks in docs/mocks/ into docs/design-system/: design tokens (colour with light and dark themes, typography, spacing, layout grid with gutters and margins, radius, elevation, motion, z-order), foundation pages, one HTML page per component with anatomy, variants, sizes, every state, responsive behaviour, theming, WCAG 2.2 AA accessibility, content rules, do/don't, tokens and code, plus patterns, a DTCG tokens.json and verified contrast. Use whenever the user mentions a design system, style guide, component library, UI kit, pattern library, tokens, theming, dark mode, brand colours, type or spacing scale, accessibility or contrast audit, or asks to make the UI consistent, document the components, extract the styles, or build frontend components from mocks; and proactively after writing-html-mocks finishes or when docs/mocks exists without docs/design-system. Requires docs/mocks; if absent, run writing-html-mocks first.
02 资源文件 16
- 参考文档agents/openai.yaml383 B
- 资产文件assets/contrast-pairs.json6.6 KB
- 资产文件assets/ds.css18.7 KB
- 脚本assets/ds.js5.5 KB
- 资产文件assets/tokens.css18.7 KB
- 参考文档evals/evals.json4.8 KB
- 参考文档references/accessibility.md5.9 KB
- 参考文档references/component-catalog.md10.9 KB
- 参考文档references/example-component.html26.2 KB
- 参考文档references/page-templates.md11.5 KB
- 参考文档references/responsive-and-layout.md4.3 KB
- 参考文档references/tokens.md6.5 KB
- 脚本scripts/check_contrast.py11.5 KB
- 脚本scripts/check_design_system.py14.4 KB
- 脚本scripts/harvest_styles.py10.7 KB
- 脚本scripts/tokens_to_json.py5.3 KB
03 SKILL.md 正文
Extracting design systems
A design system is the product's visual and interaction language written
down once, so every screen built afterwards is consistent without anyone
re-deciding. This skill mines the finished mocks in docs/mocks/ for the
decisions they already embody, normalises them into tokens, and documents
each component the way a professional Figma design-system kit does, but as
browsable HTML that engineers can lift CSS from directly.
docs/design-system/
README.md GitHub summary: catalog tables, drift log, verification record
index.html entry page linking every foundation, component and pattern
tokens/
tokens.css single source of truth: primitives, semantic tokens, themes
tokens.json DTCG export generated from tokens.css
contrast-pairs.json every fg/bg pairing the components rely on; checked
assets/
components.css the component CSS, token-driven, with data-state hooks
ds.css documentation-site chrome (from this skill's assets/)
ds.js theme toggle, live token values, live contrast ratios
foundations/<topic>.html color, typography, spacing, layout, elevation, shape, motion,
iconography, theming, responsive, accessibility, content
components/<name>.html one page per component, fixed section order
patterns/<name>.html forms, feedback, empty states, navigation, dialogs, tables,
notifications, content
Read the references as you reach the steps that need them:
references/tokens.md— token tiers, naming, categories, theming, the harvest→normalise method.references/component-catalog.md— every component to extract with its variants, states and ARIA pattern.references/page-templates.md— the page shell, component/pattern/foundation section skeletons, index and README.references/example-component.html— a complete, finished Button page to imitate.references/accessibility.md— the WCAG 2.2 AA commitments each page documents.references/responsive-and-layout.md— breakpoints, grid, gutters, margins, padding scale, per-component responsive rules.
Resolve references/, assets/ and scripts/ relative to this installed skill's
folder; resolve docs/ relative to the consuming project.
Step 0 — Mocks gate (do this first, every time)
A design system is extracted from evidence, not invented. Check that
docs/mocks/ exists and contains HTML mocks (manifest.json plus files under
pages/, dialogs/ or notifications/). If the mocks skill is installed,
run its checker first and fix or report what fails:
python "<writing-html-mocks-folder>/scripts/check_mocks.py" docs/mocks
If docs/mocks/ is missing or holds no HTML: stop and tell the user. Say
that the system is extracted from mocks and that writing-html-mocks produces
them; do not scaffold a system from nothing. This is the one hard stop.
If docs/design-system/ already exists, this is an update: keep token names
and page URLs stable, add what the new mocks introduce, and record every
changed value in the README's changelog section.
Step 1 — Harvest the visual vocabulary
python "<installed-skill-folder>/scripts/harvest_styles.py" docs/mocks --classes > docs/design-system/.cache/harvest.md
Read the report. It lists every distinct colour, font, size, weight, line
height, spacing, radius, shadow, duration, z-index, breakpoint and custom
property with counts and files, each spacing value annotated with its
distance from the 4px grid, plus class-name frequencies (the component
inventory). Also read docs/mocks/assets/tokens.css and ui.css when they
exist; they are the mocks' own draft of the system. Keep .cache/ out of git.
Step 2 — Normalise into tokens
Follow references/tokens.md. Start from this skill's assets/tokens.css and
assets/contrast-pairs.json (the structure and names are the standard; the
values are a starter that already passes), then replace the values with the
harvested ones: brand hue, fonts, scale, radii, shadows, motion. Snap
off-grid spacing, collapse near-duplicate colours, keep at most 5 radii and 4
shadows, and log every deviation you corrected as drift. Build the dark theme
from roles. Then verify:
python "<installed-skill-folder>/scripts/check_contrast.py" docs/design-system/tokens/tokens.css
python "<installed-skill-folder>/scripts/tokens_to_json.py" docs/design-system/tokens/tokens.css
The contrast check must exit 0 for both themes. Extend
contrast-pairs.json with every pairing a component introduces (badge text
on badge background, selected row text, tooltip text, chart marks).
Step 3 — Write the component CSS
assets/components.css is the product's stylesheet: every class the
components use, token-driven, with real pseudo-class states and the
matching data-state="hover|focus|active" hooks so the documentation can
show states statically. Start from docs/mocks/assets/ui.css when it exists
(it already follows the conventions), rename and tidy it into the catalog's
component list, and add component tokens (--btn-bg, --field-border, …)
that alias semantic tokens. No raw colour, size or duration is allowed in
this file; the checker rejects them.
Step 4 — Write the foundation pages
One page per topic in foundations/ (all twelve are required; the checker
fails on a missing one), following the shapes in
references/page-templates.md: color (ramps, roles, both themes, every
contrast pair with live ratios), typography (specimens, roles, measure),
spacing (the scale and inside/between rules), layout (breakpoints, columns,
gutters, margins, live grid, page templates), elevation (shadows, surfaces,
z-order), shape, motion (replayable demos, reduced motion), iconography,
theming (how themes work, adding one, tokens.json), responsive (per
references/responsive-and-layout.md), accessibility (per
references/accessibility.md) and content (voice, casing, numbers, error
and empty-state formulas, microcopy library). Every token in tokens.css
appears on exactly one foundation page with a data-token cell.
Step 5 — Write one page per component
Work through references/component-catalog.md: every component that appears
in the mocks plus the starred core set. Each page follows
references/example-component.html exactly, with the thirteen sections in
order (overview, anatomy, variants, sizes, states, responsive,
theming, accessibility, content, do-dont, tokens, code,
sources), a section that does not apply marked data-na="reason", and:
- the full state matrix (default, hover, focus, active, disabled, plus loading / selected / invalid / open where they exist) for every variant, using the real attribute where one exists and
data-stateotherwise; - both themes side by side;
- the keyboard map, focus behaviour, labelling, live contrast pairs, motion and touch under
#accessibility, naming the WAI-ARIA pattern used; - the responsive rules the component follows at each breakpoint;
- the token table with live light and dark values;
- at least two do/don't pairs drawn from real mistakes in the mocks;
- links to the mocks it came from and the drift fixed.
The shared nav lists every page; regenerate it and paste it into all pages when a page is added.
Step 6 — Write the pattern pages
One page per pattern in the catalog (forms, feedback and loading, empty and
error states, navigation and page structure, dialogs and overlays, data
tables and lists, notifications, content and tone), each with the sections
overview, when, structure, states, responsive, accessibility,
content, do-dont, sources and a live composed example.
Step 7 — Index and README
index.html links every foundation, component and pattern page and explains
how to use the system; README.md carries the catalog tables, the token
files, the drift log (mock, issue, resolution) and the verification record.
See references/page-templates.md.
Step 8 — Verify before finishing
python "<installed-skill-folder>/scripts/check_design_system.py" docs/design-system
python "<installed-skill-folder>/scripts/check_contrast.py" docs/design-system/tokens/tokens.css
The structure check fails on: missing required files or foundation pages, a
component or pattern page missing a section, raw colour literals anywhere
outside tokens/, missing doctype/lang/title/viewport/<main>/single
<h1>, unlabelled controls, unnamed buttons or links, images without alt,
broken links or fragments, and any page not linked from index.html and
README.md. Fix every error. Then look at the pages: screenshot
index.html, three component pages and the color page at 360 and 1280 px in
both themes (the mocks skill's screenshot_mocks.py docs/design-system --out docs/design-system/.cache/shots works for this; otherwise open them in a
browser) and fix overflow, clipped specimens, invisible focus rings and
dark-theme surfaces that do not read as raised.
Finally, close the loop with the mocks: point docs/mocks at
../design-system/tokens/tokens.css and assets/components.css, re-run the
mocks checker and screenshots, and record remaining differences as drift. Do
not claim the system is complete until both checkers exit 0 and the
screenshots have been reviewed.
Quality bar
A finished system lets a designer open index.html and find every decision
a Figma kit would hold (tokens, type, colour with contrast, grid, elevation,
motion, every component with anatomy, variants, sizes, states, responsive
and accessibility notes, do/don't), and lets an engineer copy the class names
and tokens.json straight into the product. Every value traces to a mock or
to a logged correction; both themes pass WCAG 2.2 AA; nothing is a
placeholder.
04 同仓库更多 Skills
writing-screen-composition
Create or update docs/screen-composition.md, a document that itemizes every page, dialog, notification and shell part from the HTML mocks and lists, for each, the component-library components it shall be composed of plus the UI that must be built locally. Also ensures AGENTS.md has the "Components library is mandatory (CRITICAL)" section. Use when the user mentions screen composition, which components a page uses, mapping mocks to a component library, local vs library UI, or before implementing an application against a component library; and whenever docs/mocks and a component catalogue exist but docs/screen-composition.md does not or is out of date.
writing-requirements
Create and manage software requirements documents (L1 high-level and L2 detailed with acceptance criteria) in docs/specs/. Use this skill whenever the user mentions requirements, specs, specifications, user stories, features to build, acceptance criteria, ATDD, or wants to define what a system should do before coding. Also use when the user says things like 'what should we build', 'let's plan the feature', 'write up what this needs to do', 'define the behavior', or describes functionality they want implemented -- even if they don't explicitly say 'requirements'. If the user is about to start coding a feature and there are no requirements yet, proactively suggest using this skill first. Requirements come before code. Always.
writing-html-mocks
Write static HTML mocks in docs/mocks/ for EVERY page, dialog and notification of a product in EVERY state (default, loading, empty, error, invalid, busy, success, no-results, forbidden, stacked...), responsive, light and dark, keyboard-accessible, with real copy and a coverage matrix. Use this skill BEFORE writing any frontend code, component, template, view or page; whenever the user says mock, mockup, wireframe, prototype, UI, UX, screen, layout, dialog, modal, toast, banner, empty/error/loading state, "what should this look like", "show me the UI", or describes a feature with a visible result; and whenever docs/specs or docs/detailed-designs exist but docs/mocks does not. Also use it to add missing states to existing mocks. Mocks come before implementation: if asked for frontend code with no mocks, say so and offer this first. Pair with extracting-design-systems to turn finished mocks into docs/design-system/.
writing-feature-prompts
Write a ready-to-run implementation prompt for a feature request or a bug fix in the current repository, save it outside the repository and open it in a text editor (Notepad on Windows). A feature prompt drives mocks, design system, requirements, detailed design, estimate update and incremental acceptance-test-driven implementation end to end without stopping; a bug-fix prompt drives reproduce, root cause, fix and documentation alignment. Use whenever the user asks to "create a prompt", "write a prompt for this feature" or "for this bug", wants a "prompt to build X" or "prompt to fix Y", or asks to open a prompt in Notepad.
writing-design-documents
Create software design documents and architecture write-ups from existing L1/L2 requirements in docs/specs/. Use for detailed designs organized by subsystem and feature, with requirement traceability and rendered PlantUML C4, class, and sequence diagrams in docs/detailed-designs/.
writing-agent-instructions
Writes the agent instruction files a repository needs so coding agents know how to work in it - AGENTS.md plus the CLAUDE.md, GEMINI.md, and .github/copilot-instructions.md pointers - generated from a description of what the project shall be, for a project that does not exist yet. Use this whenever someone mentions AGENTS.md, CLAUDE.md, GEMINI.md, copilot-instructions, "agent instructions", "agent context files", "coding agent guidance", or asks to set up, scaffold, bootstrap, or initialise the conventions for a new project or repository. Use it too when someone describes a project they are about to start and wants an agent to follow its conventions, even if they never name any of these files - if they are standing at an empty directory describing what they intend to build, this is the skill.