Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

generating-code-connect

БесплатноЗапускает вложенные скриптыНе проверен

Generates Figma Code Connect mappings for React or Angular repos, validates them with pre-checks and the Figma CLI, and can publish via figma connect. Use…

bitoviот bitovi★ 24 звезды на GitHub14 установок в других каталогах

Об этом скилле

Generating Code Connect

Scope

Create Code Connect files, write figma.config.json, validate mappings, and optionally publish

Command line first

  • Prefer rg, jq, and ast-grep over manual inspection
  • Use CLI tools or tiny scripts to validate and inspect outputs before editing by hand
  • When extracting or transforming JSON, use jq instead of ad-hoc parsing

Inputs to collect

  • Repo path, default current working directory
  • Figma file URL
  • Framework, auto-detect or ask React vs Angular
  • Component scope, comma-separated list or Enter for all
  • Output directory, default codeConnect
  • Permission to install @figma/code-connect locally if missing

Default behaviors

  • Generate all components when the user hits Enter on scope
  • Prefer local @figma/code-connect over global installs
  • Do not overwrite existing Code Connect files unless the user agrees

Workflow

  1. Pre-flight checks
  • Parse the file key from the Figma URL
  • Validate the token against the target file without printing it:
    • curl -s -o /dev/null -w "%{http_code}\n" -H "X-Figma-Token: $FIGMA_ACCESS_TOKEN" https://api.figma.com/v1/files/<fileKey>
  • Check for @figma/code-connect with scripts/check_figma_cli.sh
  • If the token check returns 403 but the user says it is valid:
    • Locate the token source without printing it: rg -l -g '.env*' -g 'superconnect.toml' "FIGMA_ACCESS_TOKEN|figma_access_token"
    • Ask the user to set the token in the current shell and re-run the check
    • Confirm the token is non-empty without printing it: echo ${#FIGMA_ACCESS_TOKEN}
    • Do not echo or paste the token value in any command or response
  1. Detect framework
  • Read package.json and look for react or @angular/core
  • If ambiguous, ask the user to choose
  1. Extract Figma data with figma-scan.js
  • Use the bundled script for reliable extraction:
    node scripts/figma-scan.js <figmaFileUrl> \
      --token $FIGMA_ACCESS_TOKEN \
      --output codeConnect/.figma-evidence \
      --index codeConnect/.figma-evidence/figma-components-index.json
    
  • The script handles all Figma API complexity including:
    • Fetching componentPropertyDefinitions via /v1/files/:key/nodes endpoint
    • Parsing variant properties from component names
    • Extracting text layers for figma.textContent()
    • Extracting slot layers for figma.children()
    • Normalizing property names to camelCase
  • Do NOT use raw curl + jq for extraction - the API has edge cases the script handles
  • See references/figma-extraction-spec.md for output format details

Evidence output structure

Each evidence file contains:

{
  "schemaVersion": "figma-component@1",
  "componentSetId": "6:4335",
  "componentName": "Button",
  "variantProperties": { "Size": ["Compact", "Base", "Wide"] },
  "variantValueEnums": {
    "Size": { "normalizedKey": "size", "enums": ["compact", "base", "wide"] }
  },
  "componentProperties": [
    { "name": "Disabled", "type": "BOOLEAN" },
    { "name": "Label", "type": "STRING" }
  ],
  "textLayers": [{ "name": "Label", "type": "TEXT" }],
  "slotLayers": [{ "name": "Icon", "type": "FRAME" }]
}

Evidence quality gate

Before proceeding to generation, verify evidence is not empty:

for f in codeConnect/.figma-evidence/*.json; do
  props=$(jq '.variantProperties | length' "$f")
  comps=$(jq '.componentProperties | length' "$f")
  if [ "$props" -eq 0 ] && [ "$comps" -eq 0 ]; then
    echo "WARNING: Empty evidence for $f"
  fi
done

If evidence is empty, the script may need --layer-depth increased or the Figma component genuinely has no configurable properties.

  1. Extract code component inputs
  • For Angular, find all inputs in each component:
    rg "= input[<\(]" projects/zap/src/lib/components/button/button.component.ts
    
  • For React, find props interface or destructured props:
    rg "interface.*Props|type.*Props|function.*\(\{" src/components/Button.tsx
    
  • Update codeConnect/mapping.json with discovered inputs, see references/mapping-spec.md

Mapping Figma to code

Create figmaToCodeMap in mapping.json to link Figma property names to code input names:

{
  "figmaToCodeMap": {
    "Size": "size",
    "Disabled": "disabled",
    "Label": "text"
  }
}

Use these heuristics for matching:

  1. Case-insensitive match first (Size → size)
  2. Remove spaces and normalize (Has Icon → hasIcon)
  3. Common synonyms (Label → text, Title → heading)
  4. If ambiguous, prompt the user for confirmation
  1. Read the relevant Figma docs and extract rules
  • Read bundled references first:
    • references/figma-code-connect-overview.md
    • references/figma-code-connect-understand-files.md
    • references/figma-code-connect-react.md or references/figma-code-connect-html.md
    • references/figma-code-connect-config-file.md
    • references/figma-code-connect-common-issues.md
  • If more detail is needed, consult the authoritative sources linked in each reference
  • Enforce these rules from the docs:
    • figma.connect uses an object lit
Полный SKILL.md на GitHub

Установить generating-code-connect в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

references/code-connect-format.mdreferences/figma-code-connect-common-issues.mdreferences/figma-code-connect-config-file.mdreferences/figma-code-connect-html.mdreferences/figma-code-connect-overview.mdreferences/figma-code-connect-react.mdreferences/figma-code-connect-understand-files.mdreferences/figma-extraction-spec.mdreferences/mapping-spec.mdscripts/check_figma_cli.shscripts/colors.jsscripts/figma-scan.jsscripts/validate_code_connect.js

FAQ

Что делает скилл generating-code-connect?

Generates Figma Code Connect mappings for React or Angular repos, validates them with pre-checks and the Figma CLI, and can publish via figma connect. Use when a user provides a Figma file URL and a component repo and asks for Code Connect files, figma.config.json, or validation.

Как установить скилл generating-code-connect?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл generating-code-connect запускает скрипты?

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

Похожие скиллы

Сравнить generating-code-connect с