From a32830b73d594c28c9ef5623e4d5707d20446de6 Mon Sep 17 00:00:00 2001 From: Zared Rogers Date: Thu, 5 Nov 2026 15:17:51 +0200 Subject: [PATCH 1/3] feat(skills): add site-to-figma-components skill (#3992) Crawl a live site, propose and review a component inventory, build it in Figma against the token library, verify it and write a Figma node to WordPress target manifest. - crawl-site-structure, propose-inventory and write-manifest TypeScript scripts with 85 Jest tests - route registered in the ai-readiness-agent routing map - npm run test:site-to-figma-components Co-Authored-By: Claude Sonnet 5.5 --- CHANGELOG.md | 2 + .../references/routing-map.yaml | 16 + package.json | 1 + skills/site-to-figma-components/SKILL.md | 98 ++ .../agents/openai.yaml | 4 + .../references/classification.md | 78 + .../references/crawling.md | 53 + .../references/figma-build.md | 44 + .../references/inventory-review.md | 55 + .../references/manifest.md | 66 + .../references/verification.md | 34 + .../__tests__/crawl-site-structure.test.ts | 595 +++++++ .../scripts/__tests__/fixtures.ts | 488 ++++++ .../__tests__/propose-inventory.test.ts | 659 +++++++ .../scripts/__tests__/tokens.test.ts | 111 ++ .../scripts/__tests__/write-manifest.test.ts | 212 +++ .../scripts/crawl-site-structure.ts | 1122 ++++++++++++ .../scripts/jest.config.cjs | 28 + .../scripts/lib/color.ts | 93 + .../scripts/lib/tokens.ts | 274 +++ .../scripts/propose-inventory.ts | 1509 +++++++++++++++++ .../scripts/tsconfig.json | 9 + .../scripts/write-manifest.ts | 312 ++++ 23 files changed, 5863 insertions(+) create mode 100644 skills/site-to-figma-components/SKILL.md create mode 100644 skills/site-to-figma-components/agents/openai.yaml create mode 100644 skills/site-to-figma-components/references/classification.md create mode 100644 skills/site-to-figma-components/references/crawling.md create mode 100644 skills/site-to-figma-components/references/figma-build.md create mode 100644 skills/site-to-figma-components/references/inventory-review.md create mode 100644 skills/site-to-figma-components/references/manifest.md create mode 100644 skills/site-to-figma-components/references/verification.md create mode 100644 skills/site-to-figma-components/scripts/__tests__/crawl-site-structure.test.ts create mode 100644 skills/site-to-figma-components/scripts/__tests__/fixtures.ts create mode 100644 skills/site-to-figma-components/scripts/__tests__/propose-inventory.test.ts create mode 100644 skills/site-to-figma-components/scripts/__tests__/tokens.test.ts create mode 100644 skills/site-to-figma-components/scripts/__tests__/write-manifest.test.ts create mode 100644 skills/site-to-figma-components/scripts/crawl-site-structure.ts create mode 100644 skills/site-to-figma-components/scripts/jest.config.cjs create mode 100644 skills/site-to-figma-components/scripts/lib/color.ts create mode 100644 skills/site-to-figma-components/scripts/lib/tokens.ts create mode 100644 skills/site-to-figma-components/scripts/propose-inventory.ts create mode 100644 skills/site-to-figma-components/scripts/tsconfig.json create mode 100644 skills/site-to-figma-components/scripts/write-manifest.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 899e8fa394..03645eb49a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- **Site to Figma Components Skill** — For website rebuilds, after the design tokens: crawls the live site at mobile and desktop widths, finds its repeated components, patterns, template parts and page templates with their variants and states, and writes an approval report that maps each to its WordPress block and proposes a variable for every value with no token. Once the reviewer approves the inventory and the templates to build, it builds them in Figma bound to the tokens, checks them against the live pages, and writes a manifest for `figma-to-block-theme` Pattern mode. ([#3992](https://github.com/lightspeedwp/.github/issues/3992)) + - **WordPress Schema Audit Agent** — Checks the structured data a WordPress site publishes against schema.org and Google's rules, then writes a client report and a spreadsheet of fixes. ([PR #3962](https://github.com/lightspeedwp/.github/pull/3962)) - **Studio Migration Import Choices** — The agent asks about the table prefix, local accounts, tables to skip and the Studio site URL. Wordfence tables are skipped by default. ([PR #3961](https://github.com/lightspeedwp/.github/pull/3961)) - **WordPress Studio Migration Agent** — Moves sites between Studio and staging or live: fixes exports Studio rejects, checks exports and replaces the site URL safely. ([PR #3959](https://github.com/lightspeedwp/.github/pull/3959)) diff --git a/agents/ai-readiness-agent/skills/lightspeed-project-onboarding/references/routing-map.yaml b/agents/ai-readiness-agent/skills/lightspeed-project-onboarding/references/routing-map.yaml index 1e588edd54..c5e34db015 100644 --- a/agents/ai-readiness-agent/skills/lightspeed-project-onboarding/references/routing-map.yaml +++ b/agents/ai-readiness-agent/skills/lightspeed-project-onboarding/references/routing-map.yaml @@ -407,6 +407,22 @@ routes: use_when: Figma variables or codebase tokens need to become WordPress theme.json settings, presets, or style variations. prompt_starter: "Use the theme.json extractor orchestrator to route token extraction across palette, typography, spacing, shadows, and style variations." + - match: + intents: + - website_rebuild + - live_site_to_figma + - rebuild_components + - rebuild_templates + primary_skill: site-to-figma-components + related_skills: + - site-to-design-tokens + - figma-to-block-theme + - figma-generate-library + - figma-generate-design + - audit-design-system + use_when: a live website is being rebuilt and its components, patterns, template parts and templates need to exist in Figma, bound to the design tokens, before the theme is built. + prompt_starter: "Use site-to-figma-components after site-to-design-tokens: crawl the live site, approve the inventory and build scope, build the approved set in Figma, then hand the manifest to figma-to-block-theme Pattern mode." + - match: intents: - linear_triage diff --git a/package.json b/package.json index 38a866c897..ae45bfbcc0 100644 --- a/package.json +++ b/package.json @@ -154,6 +154,7 @@ "metrics:run": "node metrics/frontmatter-metrics.js", "metrics:ci": "node metrics/frontmatter-metrics.js", "test:js": "jest --config .jest.config.cjs --coverage --forceExit --detectOpenHandles", + "test:site-to-figma-components": "jest --config skills/site-to-figma-components/scripts/jest.config.cjs", "test:agent-spec-validation": "node .github/scripts/__tests__/validate-agent-specs.test.js", "test:index-generator": "node .github/scripts/__tests__/generate-agent-index.test.js", "test:create-agent-spec": "node .github/scripts/__tests__/create-agent-spec.test.js", diff --git a/skills/site-to-figma-components/SKILL.md b/skills/site-to-figma-components/SKILL.md new file mode 100644 index 0000000000..9bd294c3a3 --- /dev/null +++ b/skills/site-to-figma-components/SKILL.md @@ -0,0 +1,98 @@ +--- +name: site-to-figma-components +description: Rebuild a live website's building blocks in Figma as a design system for a WordPress rebuild. Use after site-to-design-tokens has created the Figma variables, when a project needs the site's components (buttons, cards, form fields, navigation, accordions, sliders), patterns (heroes, card grids, call-to-action bands), template parts (header, footer, sidebar) and templates (one frame per page type) built in Figma from those variables. Crawls chosen pages at 390px and 1440px, writes an inventory report for approval, then builds component sets, parts, patterns and templates bound to semantic tokens, verifies them against the live pages, and writes a manifest that maps each Figma node to its WordPress target for figma-to-block-theme Pattern mode. +--- + +# Site to Figma Components + +## Overview + +The third step of a rebuild. Tokens come first, then this skill, then the theme. + +```text +site-to-design-tokens → crawl → inventory report → approval → Figma build → verify → manifest → figma-to-block-theme (Pattern mode) +``` + +It stops for approval between stages. Nothing is written to Figma before the reviewer approves the inventory. + +## Companion skills + +- `figma-use`: **required before every `use_figma` call**, read-only ones included. +- `figma-generate-library`: component sets, variant properties and variable bindings (stage 3). +- `figma-generate-design`: composing parts, patterns and templates from instances (stage 3). +- `audit-design-system` and `fix-design-system-finding`: the design system audit (stage 4). +- `site-to-design-tokens`: must have run first. Its variables export is this skill's `--tokens` input. +- `figma-to-block-theme`: reads the manifest in Pattern mode. `wp-block-themes` and `wp-patterns` cover the WordPress side. + +If a companion skill is missing, say so and stop rather than calling Figma tools directly. + +## Stage 1: Inventory + +1. **Agree the pages** with the reviewer: one or two public pages per template, from the site's sitemap. See [references/crawling.md](references/crawling.md). +2. **Crawl** (scratch folder outside the repository): + + ```bash + npx tsx ${CLAUDE_SKILL_DIR}/scripts/crawl-site-structure.ts --url https://www.example.com \ + --pages '/,/tours/example/,/blog/,/?s=safari' --out site-structure.json --shots shots + ``` + +3. **Get the tokens.** Use the `variables.json` from `site-to-design-tokens`, or export the variables from the project's Figma file with the script in `figma-to-block-theme`'s `references/figma-access.md`. +4. **Propose**, then take one example screenshot per item: + + ```bash + npx tsx ${CLAUDE_SKILL_DIR}/scripts/propose-inventory.ts site-structure.json --tokens variables.json \ + --theme --out inventory.json --report inventory.md --shots shots + npx tsx ${CLAUDE_SKILL_DIR}/scripts/crawl-site-structure.ts --url https://www.example.com \ + --shoot inventory.json --shots shots + ``` + +## Stage 2: Approval report + +Present `inventory.md`: the decisions list first (with a proposal for every value that has no token), then each table. [references/inventory-review.md](references/inventory-review.md) explains the sections. The reviewer approves, renames, merges or cuts items. Record the answers in `decisions.json`, including the **build scope** (`"build"`: the templates and items to import), re-run `propose-inventory.ts` with `--decisions decisions.json`, and repeat until the report says **approved** and lists the build scope. How items are found, named and mapped is in [references/classification.md](references/classification.md). + +## Stage 3: Figma build + +Confirm the target file and pages, add the variables the reviewer approved, then follow [references/figma-build.md](references/figma-build.md). Build only the approved scope, in this order: + +1. **Components**: component sets with variant properties, Auto Layout, text styles and a variable on every fill, stroke, gap, padding, radius, font and effect. Each description names its WordPress block. +2. **Template parts and patterns**: composed from component instances. +3. **Templates**: composed from parts and patterns, at 1440px, and at 390px where the report says the layout changes. + +Record each built node ID in `figma-nodes.json` as you go. + +## Stage 4: Verify + +Compare each frame with the live page at both widths, list the differences, and run the design system audit until it is clean. See [references/verification.md](references/verification.md). + +## Stage 5: Hand-off + +```bash +npx tsx ${CLAUDE_SKILL_DIR}/scripts/write-manifest.ts inventory.json --nodes figma-nodes.json \ + --out manifest.json --markdown manifest.md +``` + +Add `--partial` while only some items are built. Hand `manifest.json` to `figma-to-block-theme` Pattern mode and post `manifest.md` on the project's Linear issue. See [references/manifest.md](references/manifest.md). + +## Rules + +- **Approval first.** No Figma writes before the inventory is approved, and confirm the target file and pages before the first write. +- **Tokens only.** Every colour, size, space, radius and shadow binds to a variable, semantic tokens before primitives. A value with no token gets a proposal for the reviewer: fonts match the live site (an `Alternate` family), colours fit the ramps, sizes get a new ramp step in order, and one-offs become semantically named `custom/*` variables. Nothing is added without approval. +- **Approved build scope.** The reviewer approves which templates to build before any import. +- **Public pages only**, one at a time at the default pace. Never log in, submit a form, click or type. Hovering and focusing to read states is allowed. +- **Archive, don't delete.** Move superseded Figma items to an archive page (`node.remove()` is blocked) and check prototype link destinations before moving anything. +- **No em dashes** in Figma copy or document text. +- **Real content.** Use the site's headings, labels and images, uploaded with the Figma image tools. + +## Scripts + +TypeScript run with `tsx` (`npx tsx