name: figma-extract description: Extract Figma variables through figma_console MCP (read-only), normalize deterministically, and write snapshot JSON artifacts using optional repo config (no CLI dependency).
Figma extract
Purpose
Use this skill when you need to pull design tokens/variables from Figma through figma_console and write deterministic snapshot artifacts directly from the agent flow.
This skill is intentionally repo-agnostic:
- one Figma read call (
figma_get_variables) - no Figma write/mutate calls
- no dependence on a repo-specific extraction helper or CLI wrapper
Read-only rules
Allowed Figma tools:
figma_get_status(preflight)figma_get_variables(extraction)
Do not call Figma mutate tools (create, set, update, delete, instantiate, etc.).
Optional Repo Config
If present, read config from one of these paths (first match wins):
- user-provided path
.codex/figma-extract.jsonfigma-extract.config.json
Config schema (example file: references/repo-config.example.json):
{
"collectionName": "Prism UI Core Tokens",
"outputDir": "domains/ui-core/authoring/snapshots/figma",
"latestFile": "domains/ui-core/authoring/snapshots/figma/latest.json",
"source": {
"serverName": "figma_console",
"toolName": "figma_get_variables"
},
"mcp": {
"format": "full",
"verbosity": "standard",
"refreshCache": true,
"useConsoleFallback": false
}
}
Defaults when config is absent:
collectionName: not enforced unless provided; if multiple collections exist, stop and ask user to disambiguateoutputDir:authoring/snapshots/figmaif that directory exists, otherwise.codex/artifacts/figma/snapshotslatestFile:<outputDir>/latest.jsonsource.serverName:figma_consolesource.toolName:figma_get_variables- MCP payload:
format: "full"verbosity: "standard"refreshCache: trueuseConsoleFallback: false
Workflow
- Resolve file URL:
- If user provided a URL, use it.
- Otherwise call
figma_get_statusand usemonitoredPageUrl.
- Preflight connection:
- Call
figma_get_status. - If no active transport (
websocket/cdp) and no monitored page, stop and report a blocking condition.
- Fetch variables once:
- Call
figma_get_variableswith configured/default MCP payload. - This is the only Figma data call in this skill.
- Normalize payload deterministically in-agent (no repo helper):
- Support both payload shapes:
payload.data.variableCollections+payload.data.variablespayload.data.collections+ nested collection variables
- Build normalized snapshot object:
schemaVersion: 1source:{ transport: "mcp", serverName, toolName, collectionName }collection:id,name,defaultModeIdmodes: sort byname, thenidvariables: sort byname, thenid- keep only stable fields:
id,name,resolvedTypedescription(ornull)hiddenFromPublishing(boolean)scopes(sorted array of strings)valuesByMode(mode IDs sorted)
- recursively sort keys in nested objects
- keep only stable fields:
- Strip/ignore volatile fields (timestamps, session IDs, runtime metadata).
- Validate collection scope:
- If
collectionNameis configured, require exact match and fail otherwise. - If not configured and there is exactly one collection, use it.
- If not configured and multiple collections exist, stop and ask for
collectionName.
- Compute content hash:
- Compute SHA-256 on stable-stringified snapshot object before
contentHashis added. - Add
contentHashto the snapshot.
- Generate snapshot ID:
snapshotId = YYYYMMDDTHHmmssZ-<hash8>(UTC time + first 8 hash chars).
- Write artifacts deterministically:
- Write
<outputDir>/<snapshotId>.json. - Write
latestFile. - JSON must be stable key ordered and pretty-printed with trailing newline.
- Report summary:
- file URL
- collection name
- variable count
- content hash
- snapshot path
- latest path
Blocking conditions
Stop and escalate to the user when:
- Figma transport is not connected
- collection disambiguation is required
- output path cannot be written
- extracted payload is missing collections/variables
Notes
- Never shell out to repo extraction CLIs as part of this skill.
- If a repo offers its own normalizer/writer library, prefer this skill's portable normalization path unless the user explicitly asks to use repo helpers.
- Repeated runs over unchanged Figma data should produce byte-stable JSON content (hash identical; filename may differ due timestamp).