figma-code-connect
Skill0 starsChanged 4 months agoMITView on GitHub
Create or update Figma Code Connect template files (.figma.ts/.figma.js) that map Figma components to code. Use for Code Connect, Figma component mapping, design-to-code.
7 other projects use a version of this, 6 of them edited.
Adopted by
Most recently taken up by
- memi-design/design-skillstheir own version, first seen Nov 8, 2026
- PracticalSwan/agent-skillsedited, first seen Oct 19, 2026
- openai/pluginsedited, first seen Oct 13, 2026
- figma/mcp-server-guideedited, first seen Oct 8, 2026
- SkotAlexsander/skillsedited, first seen Sep 16, 2026
- ferocknew/claude_code_public_skillsedited, first seen Jul 26, 2026
Other versions7 projects use a version of this.
Word for word · 0
None found.
Edited · 6
- openai/plugins★ 7.8k41% same
- figma/mcp-server-guide★ 2.2k41% same
- PracticalSwan/agent-skills★ 2241% same
- ferocknew/claude_code_public_skills★ 942% same
- HK-hub/AgentSkills★ 644% same
- SkotAlexsander/skills★ 141% same
Wrote their own version · 1
- memi-design/design-skills★ 7same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository63 other files it gives its agents.
- .claude/skills/nestjs-best-practices/AGENTS.mdAGENTS.md
- accessibility-a11ySkill
- architecture-blueprint-generatorSkill
- backend-delivery-loopSkill
- backend-designSkill
- backend-dev-guidelinesSkill
- backend-testingSkill
- backend-to-frontend-handoff-docsSkill
- building-componentsSkill
- bullmq-specialistSkill
- canvas-designSkill
- code-patternsSkill
- components-composition-patternsSkill
- conventional-commitSkill
- core-web-vitalsSkill
- create-svgSkill
- css-architectureSkill
- cypress-authorSkill
- cypress-docsSkill
- cypress-explainSkill
- delivery-loop-retroSkill
- diagnoseSkill
- fastify-best-practicesSkill
- frontend-delivery-loopSkill
- frontend-fundamentalsSkill
- fullstack-delivery-loopSkill
- grill-meSkill
- hunt-race-conditionSkill
- impeccableSkill
- mermaid-diagramsSkill
- nestjs-best-practicesSkill
- nextjs-best-practicesSkill
- nextjs-performanceSkill
- nodejs-backend-patternsSkill
- owasp-security-reviewSkill
- performance-hunterSkill
- playwright-best-practicesSkill
- postgresql-code-reviewSkill
- postgresql-optimizationSkill
- postmanSkill
- prisma-postgresSkill
- pro-state-machineSkill
- race-conditionSkill
- react-best-practicesSkill
- react-performanceSkill
- react-querySkill
- redis-coreSkill
- redis-query-engineSkill
- redis-securitySkill
- refactorSkill
- review-panelSkill
- run-delivery-chainSkill
- spec-drivenSkill
- sql-optimizationSkill
- system-designSkill
- testing-strategySkill
- tune-skills-and-agentsSkill
- ui-ux-pro-maxSkill
- vercel-react-view-transitionsSkill
- viteSkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
14 rules. 7 are common, 0 are distinctive, and 7 are very specific to this project.
7
Common
Most of the 7 edited versions we read keep these.
0
Distinctive
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 10
Create Code Connect template files (.figma.ts) that map Figma components to code snippets.
- Very specific: line 54
Always convert nodeId hyphens to colons: 1234-5678 → 1234:5678.
- Very specific: line 76
Call the MCP tool get_context_for_code_connect with:
- Common: line 97
If the user did not specify which code component to connect:
- Very specific: line 99
Check figma.config.json for paths and importPaths to find where components live
- Very specific: line 100
Search the codebase for a component matching the Figma component name.
- Common: line 101
Read candidate files and compare their props interface against the Figma properties from Step 3 — look for matching variant types, size …
- Common: line 102
If multiple candidates match, pick the one with the closest prop-interface match and explain your reasoning to the user
- Common: line 103
If no match is found, show the 2 closest candidates and ask the user to confirm or provide the correct path
- Common: line 105
Confirm with the user: before proceeding to Step 5.
- Very specific: line 107
Read figma.config.json for import path aliases — the importPaths section maps glob patterns to import specifiers, and the paths section …
- Common: line 109
Read the code component's source to understand its props interface — this informs how to map Figma properties to code props in Step 5.
- Very specific: line 143
Read back the .figma.ts file and review it against the following:
- Common: line 151
If anything looks uncertain, consult references/api.md for API details and references/advanced-patterns.md for complex nesting.
“Common” is measured: kept by at least 6 in 10 of the 7 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Code Connect
Overview
Create Code Connect template files (.figma.ts) that map Figma components to code snippets. Given a Figma URL, follow the six-step workflow below to produce a validated template.
Note: This project may also contain parser-based
.figma.tsxfiles (usingfigma.connect(), published via CLI). This skill covers templates files only —.figma.tsfiles that use the MCP tools to fetch component context from Figma.
References
Each file is loaded on demand — read one only when the task needs that depth (progressive disclosure).
references/template-patterns.md— the Step 5 deep dive: property mapping per Figma type, exhaustive variant handling, interpolation rules, finding descendant layers, nested configurable instances, the fullinstance.*/InstanceHandle/TextHandle/SelectorOptions/Export quick reference, and the Rules & Pitfalls checklist · read when writing or reviewing the template body, or when Step 6 flags an issue.references/worked-example.md— a complete start-to-finish walkthrough of all six steps on one Button component · read when you want a concrete end-to-end example to adapt.references/api.md— the full Code Connect template API reference:figma.config.jsonconfiguration, the completefigma/instanceAPI, publishing/CLI commands, type reference, best practices, and troubleshooting · read for authoritative API details, config, or publishing.references/advanced-patterns.md— advanced nesting: descendant/recursive templating,metadata.propspassing between parent/child templates,findConnectedInstancesfiltering, and a multi-generation inheritance example · read for multi-level nested components or metadata prop passing.
Prerequisites
- Figma MCP server must be connected — verify that Figma MCP tools (e.g.,
get_code_connect_suggestions) are available before proceeding. If not, guide the user to enable the Figma MCP server and restart their MCP client. - Components must be published — Code Connect only works with components published to a Figma team library. If a component is not published, inform the user and stop.
- Organization or Enterprise plan required — Code Connect is not available on Free or Professional plans.
- URL must include
node-id— the Figma URL must contain thenode-idquery parameter. - TypeScript types — for editor autocomplete and type checking in
.figma.tsfiles@figma/code-connect/figma-typesmust be added totypesintsconfig.json:{ "compilerOptions": { "types": ["@figma/code-connect/figma-types"] } }
The 6-step workflow
Parse URL → Discover → Fetch props → Identify component → Create template → ValidateStep 1: Parse the Figma URL
Extract fileKey and nodeId from the URL:
| URL Format | fileKey | nodeId |
figma.com/design/:fileKey/:name?node-id=X-Y | :fileKey | X-Y → X:Y |
figma.com/file/:fileKey/:name?node-id=X-Y | :fileKey | X-Y → X:Y |
figma.com/design/:fileKey/branch/:branchKey/:name | use :branchKey | from node-id param |
Always convert nodeId hyphens to colons: 1234-5678 → 1234:5678.
Worked example: Given https://www.figma.com/design/QiEF6w564ggoW8ftcLvdcu/MyDesignSystem?node-id=4185-3778 → fileKey = QiEF6w564ggoW8ftcLvdcu, nodeId = 4185-3778 → 4185:3778.
Step 2: Discover Unmapped Components
The user may provide a URL pointing to a frame, instance, or variant — not necessarily a component set or standalone component. Call the MCP tool get_code_connect_suggestions with:
fileKey— from Step 1nodeId— from Step 1 (colons format)excludeMappingPrompt—true(returns a lightweight list of unmapped components)
This tool identifies published components in the selection that don't yet have Code Connect mappings.
Handle the response:
- "No published components found in this selection" — the node contains no published components. Inform the user they need to publish the component to a team library in Figma first, then stop.
- "All component instances in this selection are already connected to code via Code Connect" — everything is already mapped. Inform the user and stop.
- Normal response with component list — extract the
mainComponentNodeIdfor each returned component. Use these resolved node IDs (not the original from the URL) for all subsequent steps. If multiple components are returned (e.g. the user selected a frame containing several different component instances), repeat Steps 3–6 for each one.
Step 3: Fetch Component Properties
Call the MCP tool get_context_for_code_connect with:
fileKey— from Step 1nodeId— the resolvedmainComponentNodeIdfrom Step 2clientFrameworks— determine fromfigma.config.jsonparserfield (e.g."react"→["react"])clientLanguages— infer from project file extensions (e.g. TypeScript project →["typescript"], JavaScript →["javascript"])
For multiple components, call the tool once per node ID.
The response contains the Figma component's property definitions — note each property's name and type:
- TEXT — text content (labels, titles, placeholders)
- BOOLEAN — toggles (show/hide icon, disabled state)
- VARIANT — enum options (size, variant, state)
- INSTANCE_SWAP — swappable nested instances tied to a specific component (icon, avatar)
- SLOT — flexible content regions (freeform layout, mixed children); use
getSlot()in templates (not the same as INSTANCE_SWAP)
Save this property list — you will use it in Step 5 to write the template.
Step 4: Identify the Code Component
If the user did not specify which code component to connect:
- Check
figma.config.jsonforpathsandimportPathsto find where components live - Search the codebase for a component matching the Figma component name. Check common directories (
src/components/,components/,lib/ui/,app/components/) iffigma.config.jsondoesn't specify paths - Read candidate files and compare their props interface against the Figma properties from Step 3 — look for matching variant types, size options, boolean flags, and slot props
- If multiple candidates match, pick the one with the closest prop-interface match and explain your reasoning to the user
- If no match is found, show the 2 closest candidates and ask the user to confirm or provide the correct path
Confirm with the user before proceeding to Step 5. Present the match: which code component you found, where it lives, and why it matches (prop correspondence, naming, purpose).
Read figma.config.json for import path aliases — the importPaths section maps glob patterns to import specifiers, and the paths section maps those specifiers to directories.
Read the code component's source to understand its props interface — this informs how to map Figma properties to code props in Step 5.
Step 5: Create the Template File (.figma.ts)
File location — place the file alongside existing Code Connect templates (.figma.tsx or .figma.ts files). Check figma.config.json include patterns for the correct directory. Name it ComponentName.figma.ts.
Template structure — every template file follows this shape:
// url=https://www.figma.com/file/{fileKey}/{fileName}?node-id={nodeId}
// source={path to code component from Step 4}
// component={code component name from Step 4}
import figma from "figma";
const instance = figma.selectedInstance;
// Extract properties from the Figma component (see property mapping below)
// ...
export default {
example: figma.code`<Component ... />`, // Required: code snippet
imports: ['import { Component } from "..."'], // Optional: import statements
id: "component-name", // Required: unique identifier
metadata: {
// Optional
nestable: true, // true = inline in parent, false = show as pill
props: {}, // data accessible to parent templates
},
};Write the template body using the property list from Step 3. The full how-to — per-type property mapping, exhaustive variant handling (every enum value must be mapped), interpolation wrapping rules, finding descendant layers, nested configurable instances, conditional props, the instance.*/InstanceHandle/SelectorOptions/Export quick reference, and the Rules & Pitfalls checklist — lives in references/template-patterns.md. For multi-level nesting or metadata prop passing between templates, see references/advanced-patterns.md.
Step 6: Validate
Read back the .figma.ts file and review it against the following:
- Property coverage — every Figma property from Step 3 should be accounted for in the template. Flag any that are missing and ask the user if they were intentionally omitted.
- Valid, correctly typed code — all emitted code must be valid and correctly typed against the code component's
Propsinterface. Never make up component properties — if a Figma property has no corresponding code prop, omit it rather than invent one. - No hardcoded children — verify that every INSTANCE_SWAP property and child component slot uses the dynamic APIs (
getInstanceSwap(),findInstance(),findConnectedInstance(), etc.) withexecuteTemplate(). No slot should contain hardcoded component content. - Rules and Pitfalls — check for the common mistakes listed in references/template-patterns.md (string concatenation of template results, unnecessary
hasCodeConnect()guards, missingtype === 'INSTANCE'checks, etc.) - Interpolation wrapping — strings (
getString,getEnum,textContent) wrapped in quotes, instance/section values (executeTemplate().example) wrapped in braces, slot sections (getSlot) interpolated as snippet sections insidefigma.code`...`, booleans using conditionals
If anything looks uncertain, consult references/api.md for API details and references/advanced-patterns.md for complex nesting.
For a full worked walkthrough of all six steps on one component, see references/worked-example.md.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

