extract-design
Extract a Google DESIGN.md file from an HTML prototype (claude.ai/design or any styled page) using Puppeteer, producing machine-readable tokens and AI-generated prose. Use when the user has an HTML prototype and wants a DESIGN.md to anchor their project's visual identity, or when seed-conventions has just scaffolded a new project.
- License 许可
- MIT
- 最近更新
- 2026-11-10
- Stars
- ★ 292
- Forks
- 23
01 前言 Front Matter
- name
- extract-design
- model
- sonnet
- effort
- standard
- description
- Extract a Google DESIGN.md file from an HTML prototype (claude.ai/design or any styled page) using Puppeteer, producing machine-readable tokens and AI-generated prose. Use when the user has an HTML prototype and wants a DESIGN.md to anchor their project's visual identity, or when seed-conventions has just scaffolded a new project.
02 资源文件 24
- 其他extract-design.feature1.1 KB
- 参考文档REFERENCE.md2.6 KB
- 脚本scripts/classify-colors.js2.5 KB
- 脚本scripts/classify-rounded.js909 B
- 脚本scripts/classify-spacing.js1.5 KB
- 脚本scripts/classify-typography.js1.6 KB
- 脚本scripts/collect-styles.js5.3 KB
- 脚本scripts/detect-components.js2.2 KB
- 脚本scripts/extract.js11.1 KB
- 脚本scripts/generate-prose.js3.4 KB
- 脚本scripts/lib/browser.js6.8 KB
- 脚本scripts/lib/constants.js1.4 KB
- 脚本scripts/lib/logging.js343 B
- 脚本scripts/lib/retry.js682 B
- 脚本scripts/lib/state.js1.1 KB
- 脚本scripts/lib/validator.js947 B
- 脚本scripts/write-designd.js1.8 KB
- 参考文档tests/fixtures/glassmorphism-dark/expected-tokens.json189 B
- 参考文档tests/fixtures/glassmorphism-dark/prototype.html1.2 KB
- 参考文档tests/fixtures/minimal-no-styles/expected-tokens.json50 B
- 参考文档tests/fixtures/minimal-no-styles/prototype.html204 B
- 参考文档tests/fixtures/swiss-grid/expected-tokens.json140 B
- 参考文档tests/fixtures/swiss-grid/prototype.html1.1 KB
- 脚本tests/test-extraction.js14.8 KB
03 SKILL.md 正文
Extract DESIGN.md from HTML
HARD GATE — Do NOT write DESIGN.md without Puppeteer dual-pass extraction. Tokens from static HTML (Cheerio, regex, string scanning) are invalid — they miss cascade, custom properties, and Tailwind resolution.
HARD GATE — Do NOT claim certainty where evidence is thin. Low-confidence color roles, component classifications, and prose assertions MUST be flagged with
<!-- AGENT NOTE: uncertain — validate during grill-me. Evidence: [what was observed] -->.HARD GATE — Do NOT ship DESIGN.md without running
npx @google/design.md lint. Unvalidated output is unverified output. If lint is unavailable (offline), flag prominently in terminal and in DESIGN.md prose.
Quick Start
# First run — extract from HTML prototype
node extract-design/scripts/extract.js --source ./prototype.html
# From a published URL
node extract-design/scripts/extract.js --source https://my-prototype.example.com
# With a custom name
node extract-design/scripts/extract.js --source ./proto.html --name "My Design System"
# Update — re-extract from new HTML, diff against existing
node extract-design/scripts/extract.js --source ./proto-v2.html
# Lint-only — validate existing DESIGN.md without re-extraction
node extract-design/scripts/extract.js --lint-only
Flow
- Launch Puppeteer — dual-pass (light + dark) with retry + timeout. CI flags:
--headless=new --no-sandbox --disable-gpu --disable-dbus --use-gl=angle --use-angle=swiftshader. - Collect styles —
page.evaluate()collects computed styles from every element. Returns raw JSON to Node.js. Browser = sensor; Node = brain. - Classify tokens — modular pipeline: colors (Material 3 roles), typography (scale detection), spacing (tolerance GCD), rounded (clustering), components (visual signature + pseudo-state variants).
- Generate prose — AI heuristics produce all 8 DESIGN.md sections. Overview and Do's/Don'ts flagged with agent notes.
- Write + validate — serialize to
specs/tech-architecture/DESIGN_LATEST.md, runnpx @google/design.md lint, report to terminal. - Handoff — writes
handoff.next_skill: grill-metospecs/state.yamlwith uncertain decisions context.
Inputs
| Parameter | Required | Description |
|---|---|---|
--source <file|url> |
First run: yes. Update: optional | HTML prototype path or URL |
--name <string> |
No | Design system name (defaults to <title> or directory name) |
--lint-only |
No | Validate existing DESIGN.md without re-extraction |
Output
specs/tech-architecture/DESIGN_LATEST.md— replacesDESIGN_PLAN_LATEST.mdas the canonical design artifact- Terminal summary: token counts, component count, lint result, uncertain decisions
- Structured JSON log to stderr: extraction events, timing, counts
specs/state.yaml→handoff.next_skill: grill-mewith context
Error Tiers
| Tier | Condition | Response |
|---|---|---|
| Fatal | No Chrome, page load timeout after retries | Exit non-zero, suggest fixes |
| Degraded | Zero colors, zero typography, SPA shell | Write DESIGN.md with degradation warning |
| Warned | Lint errors, uncertain decisions | Write DESIGN.md, flag in terminal, hand off to grill-me |
Dependencies
- Puppeteer (Chrome binary) — wrapped behind
BrowserExtractorinterface for testability @google/design.md(soft, vianpx) — wrapped behindDesignValidatorinterface. Warns and skips if offline.
verify
node extract-design/tests/test-extraction.js
See REFERENCE.md for extraction algorithms and heuristics.
04 同仓库更多 Skills
skill-verify-fail-open-fixture
Negative-path fixture for run-skill-verify.sh — must never PASS.
negative-path
暂无简介
write-document
Write, organize, and sync high-integrity technical documents using the BMAD methodology. Ensures every document is Bold, Minimal, Actionable, and Durable. Use when creating architectural docs, technical guides, or organizing the specs/ directory.
wire-observability
Add structured JSON logging, observability commands, and idempotent setup scripts to a project. Use when a project needs production-readiness instrumentation, when user wants structured logging, or as a production-readiness gate at any phase of development.
wire-ci
CI pipeline setup with bundled, forge-neutral templates and local validation. Detects the forge from the git remote, generates workflows for supported forges, and skips honestly for the rest. The CI equivalent of wire-observability.
visual-dashboard
Start a browser-based dashboard that visualizes architecture, implementation plans, and project status. Persists artifacts in .bigpowers/dashboard/. Reads specs/state.yaml, release-plan.yaml, epics, and planning-status via HTTP API or opencode panel.