A Claude Code skill that turns a Canonical web copy doc (.docx) into a configured, filled Figma page built from Sites-Core / Vanilla patterns — not empty component shells.
It extracts the copy, proposes a section → pattern mapping (asking about ambiguities), then generates one JavaScript script you paste into the Canonical Page Builder Figma plugin. The script places each pattern, sets its layout/variants, fills real (verbatim) copy, and toggles off anything the copy doesn't provide. It has been used to build several real ubuntu.com/canonical.com pages end-to-end.
Built collaboratively with Claude in Claude Code. This repo is the shareable source of truth; see "How to run it" for where the files must live to actually execute.
| Path | What it is | Tweak this to… |
|---|---|---|
skill/copydoc-to-figma.md |
The skill — the step-by-step workflow (extract → map → approve → generate → run). | change the overall process, prompts, or generation instructions. |
tools/component-knowledge.json |
The control surface + rules: every pattern's keys, layout options, variants, booleans, content options, text-fill mechanics, and the _contentMapping rules (verbatim copy, heading placement, etc.). |
change build rules, add per-pattern structure/specs, adjust conventions. |
tools/pattern-mappings.json |
When to pick which pattern — learned heuristics mapping copy signals → pattern (e.g. "FAQ → Tiered list", "logo cloud → Logo section"). Grows one entry per real doc. | change/add mapping decisions (which pattern a kind of section becomes). |
tools/page-builder-core.js |
The PB helper library prepended to every generated script (place, swap layout, set variant/boolean, fill text, repeaters, CTAs, clone-to-count, etc.). |
change how the builder manipulates Figma, add helpers. |
tools/component-keys.json |
The Figma component keys for each pattern (extracted once from the Sites-Core library). | add a new pattern's key (get it via the get-key snippet below). |
The three most likely files a non-engineer will tweak are pattern-mappings.json (mapping decisions) and the rules inside component-knowledge.json (_contentMapping), and the skill's copydoc-to-figma.md (workflow wording). They're plain JSON/Markdown.
Every Sites-Core pattern is a Figma component (or component set). Its layout, variants, booleans, content blocks, and slots are all configurable via the Figma Plugin API. The skill reads component-knowledge.json to know how to configure each pattern and pattern-mappings.json to decide which pattern a copy section becomes, then emits one script: the PB helper library (from page-builder-core.js) followed by per-section calls, all wrapped in a single (async () => { … })(). Text is filled through each element's bound component text property (never a raw layer). Repeating things (list items, tabs, resource cards, steps) live in slots and are cloned/removed to match the copy.
The skill is a Claude Code skill. To use it (not just read it), the files must live in the local Claude Code config:
- Copy
skill/copydoc-to-figma.md→~/.claude/commands/copydoc-to-figma.md - Copy everything in
tools/→~/.claude/tools/figma/ - In a Claude Code session, run:
/copydoc-to-figma <path-to-doc.docx> - Claude proposes a section→pattern mapping (and asks about ambiguities). Approve/adjust.
- Claude generates a script and saves it (e.g. to
~/Downloads/…-build.js). - In Figma: enable the Sites - Core library, open the Canonical Page Builder plugin, paste the script, Run.
- Copy the plugin's OUTPUT box back to Claude if anything needs a fix.
Manual bits, every page (by design): images, videos, logos, and hyperlink targets are chosen by hand; and a Tab section's non-active tabs (a tab shows one content at a time).
Battle-tested (built on real docs): Hero, Basic section, Tiered list, Equal heights, Quote, Data spotlight, Tab section, Resources, CTA section, Linked logo, Logo section, Divided section, List-Divided (content option).
Not yet built (would need a first-time "probe" when a doc uses one): Text spotlight, Rich vertical list, Newsletter signup, Pricing, Blog.
- Get its component key — in the Canonical Page Builder plugin, select the pattern on canvas and run this snippet; it logs the library key:
(async () => { for (const n of figma.currentPage.selection) { let k = "(none)"; if (n.type === "INSTANCE") { const m = await n.getMainComponentAsync(); k = (m.parent && m.parent.type === "COMPONENT_SET") ? m.parent.key + " [SET]" : m.key; } else if (n.type === "COMPONENT" || n.type === "COMPONENT_SET") k = n.key; console.log(n.name + " → " + k); } figma.notify("key logged"); })();
- Add the key to
tools/component-keys.json. - Add a structure probe (dump the pattern's text-node parents, slots, booleans) so Claude knows how to fill it — record the findings in
tools/component-knowledge.json. - Add a mapping entry to
tools/pattern-mappings.json(which copy signals → this pattern).
Claude does steps 3–4 automatically the first time a doc uses the pattern; this is just the manual path.
- Use the copydoc's copy verbatim — never paraphrase, condense, or invent.
- Follow the copydoc's structure — pick the pattern variant that matches (e.g. plain text + a link → CTA section
Default/100, not an invented button). - Section headings go in the left heading slot (except Hero).
- Only show what the copy provides — toggle off optional CTAs / subheadings / descriptions.
- Use H5 for sub-headings (H4 is rarely used).
- Logo section for a plain logo cloud; Linked logo only when logos have CTA links.
- FAQ → Tiered list even if the doc labels it "resources list".
- Verify mapping ambiguities with the reviewer up front, not after building.
- The per-section build calls are generated fresh by Claude each run (using the knowledge base) — this is LLM-assisted generation, not a fixed template. Expect a short review loop per doc.
- The Canonical Page Builder Figma plugin is a separate dependency (a generic "paste a script, Run" plugin). Not included here.
- Requires the Sites - Core component library enabled in the target Figma file.