@fprad0/skill-master-mcp 0.0.9 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/README.md +43 -9
- package/VERSION.md +3 -3
- package/bin/lib/client-config.mjs +268 -0
- package/bin/lib/menu-core.mjs +678 -33
- package/bin/skill-master-bootstrap-global.mjs +15 -1
- package/bin/skill-master-doctor.mjs +181 -0
- package/bin/skill-master-install-global-skills.mjs +30 -10
- package/bin/skill-master-menu.mjs +184 -36
- package/bin/skill-master-register-clients.mjs +43 -99
- package/dist/index.js +30 -5
- package/dist/index.js.map +1 -1
- package/docs/operations/GUIA_MULTI_COMPUTADOR.md +255 -0
- package/docs/operations/GUIA_NPM_PUBLICO.md +147 -0
- package/docs/skill-candidates/v0.0.10/cli-creator/LICENSE.txt +201 -0
- package/docs/skill-candidates/v0.0.10/cli-creator/SKILL.md +160 -0
- package/docs/skill-candidates/v0.0.10/cli-creator/agents/openai.yaml +4 -0
- package/docs/skill-candidates/v0.0.10/cli-creator/references/agent-cli-patterns.md +154 -0
- package/docs/skill-candidates/v0.0.10/developer-workstation-ops/SKILL.md +32 -0
- package/docs/skill-candidates/v0.0.10/figma/LICENSE.txt +2 -0
- package/docs/skill-candidates/v0.0.10/figma/SKILL.md +42 -0
- package/docs/skill-candidates/v0.0.10/figma/agents/openai.yaml +14 -0
- package/docs/skill-candidates/v0.0.10/figma/assets/figma-small.svg +3 -0
- package/docs/skill-candidates/v0.0.10/figma/assets/figma.png +0 -0
- package/docs/skill-candidates/v0.0.10/figma/assets/icon.svg +28 -0
- package/docs/skill-candidates/v0.0.10/figma/references/figma-mcp-config.md +35 -0
- package/docs/skill-candidates/v0.0.10/figma/references/figma-tools-and-prompts.md +34 -0
- package/docs/skill-candidates/v0.0.10/figma-code-connect-components/LICENSE.TXT +2 -0
- package/docs/skill-candidates/v0.0.10/figma-code-connect-components/SKILL.md +349 -0
- package/docs/skill-candidates/v0.0.10/figma-code-connect-components/agents/openai.yaml +14 -0
- package/docs/skill-candidates/v0.0.10/figma-code-connect-components/assets/figma-small.svg +3 -0
- package/docs/skill-candidates/v0.0.10/figma-code-connect-components/assets/figma.png +0 -0
- package/docs/skill-candidates/v0.0.10/figma-code-connect-components/assets/icon.svg +28 -0
- package/docs/skill-candidates/v0.0.10/figma-code-connect-components/references/mapping-checklist.md +7 -0
- package/docs/skill-candidates/v0.0.10/figma-code-connect-components/scripts/normalize_node_id.py +25 -0
- package/docs/skill-candidates/v0.0.10/figma-create-design-system-rules/LICENSE.TXT +2 -0
- package/docs/skill-candidates/v0.0.10/figma-create-design-system-rules/SKILL.md +537 -0
- package/docs/skill-candidates/v0.0.10/figma-create-design-system-rules/agents/openai.yaml +14 -0
- package/docs/skill-candidates/v0.0.10/figma-create-design-system-rules/assets/figma-small.svg +3 -0
- package/docs/skill-candidates/v0.0.10/figma-create-design-system-rules/assets/figma.png +0 -0
- package/docs/skill-candidates/v0.0.10/figma-create-design-system-rules/assets/icon.svg +28 -0
- package/docs/skill-candidates/v0.0.10/figma-create-design-system-rules/references/rule-template.md +15 -0
- package/docs/skill-candidates/v0.0.10/figma-create-design-system-rules/scripts/check_agents_md.sh +9 -0
- package/docs/skill-candidates/v0.0.10/figma-generate-design/LICENSE.TXT +2 -0
- package/docs/skill-candidates/v0.0.10/figma-generate-design/SKILL.md +341 -0
- package/docs/skill-candidates/v0.0.10/figma-generate-design/agents/openai.yaml +14 -0
- package/docs/skill-candidates/v0.0.10/figma-generate-design/assets/figma-small.svg +3 -0
- package/docs/skill-candidates/v0.0.10/figma-generate-design/assets/figma.png +0 -0
- package/docs/skill-candidates/v0.0.10/figma-generate-design/assets/icon.svg +28 -0
- package/docs/skill-candidates/v0.0.10/figma-generate-design/maintainers.yml +1 -0
- package/docs/skill-candidates/v0.0.10/figma-generate-library/LICENSE.TXT +2 -0
- package/docs/skill-candidates/v0.0.10/figma-generate-library/SKILL.md +314 -0
- package/docs/skill-candidates/v0.0.10/figma-generate-library/agents/openai.yaml +14 -0
- package/docs/skill-candidates/v0.0.10/figma-generate-library/assets/figma-small.svg +3 -0
- package/docs/skill-candidates/v0.0.10/figma-generate-library/assets/figma.png +0 -0
- package/docs/skill-candidates/v0.0.10/figma-generate-library/assets/icon.svg +28 -0
- package/docs/skill-candidates/v0.0.10/figma-generate-library/maintainers.yml +3 -0
- package/docs/skill-candidates/v0.0.10/figma-generate-library/references/code-connect-setup.md +260 -0
- package/docs/skill-candidates/v0.0.10/figma-generate-library/references/component-creation.md +1014 -0
- package/docs/skill-candidates/v0.0.10/figma-generate-library/references/discovery-phase.md +518 -0
- package/docs/skill-candidates/v0.0.10/figma-generate-library/references/documentation-creation.md +834 -0
- package/docs/skill-candidates/v0.0.10/figma-generate-library/references/error-recovery.md +540 -0
- package/docs/skill-candidates/v0.0.10/figma-generate-library/references/naming-conventions.md +527 -0
- package/docs/skill-candidates/v0.0.10/figma-generate-library/references/token-creation.md +962 -0
- package/docs/skill-candidates/v0.0.10/figma-generate-library/scripts/bindVariablesToComponent.js +110 -0
- package/docs/skill-candidates/v0.0.10/figma-generate-library/scripts/cleanupOrphans.js +127 -0
- package/docs/skill-candidates/v0.0.10/figma-generate-library/scripts/createComponentWithVariants.js +148 -0
- package/docs/skill-candidates/v0.0.10/figma-generate-library/scripts/createDocumentationPage.js +139 -0
- package/docs/skill-candidates/v0.0.10/figma-generate-library/scripts/createSemanticTokens.js +108 -0
- package/docs/skill-candidates/v0.0.10/figma-generate-library/scripts/createVariableCollection.js +49 -0
- package/docs/skill-candidates/v0.0.10/figma-generate-library/scripts/inspectFileStructure.js +121 -0
- package/docs/skill-candidates/v0.0.10/figma-generate-library/scripts/rehydrateState.js +92 -0
- package/docs/skill-candidates/v0.0.10/figma-generate-library/scripts/validateCreation.js +83 -0
- package/docs/skill-candidates/v0.0.10/figma-implement-design/LICENSE.txt +2 -0
- package/docs/skill-candidates/v0.0.10/figma-implement-design/SKILL.md +258 -0
- package/docs/skill-candidates/v0.0.10/figma-implement-design/agents/openai.yaml +14 -0
- package/docs/skill-candidates/v0.0.10/figma-implement-design/assets/figma-small.svg +3 -0
- package/docs/skill-candidates/v0.0.10/figma-implement-design/assets/figma.png +0 -0
- package/docs/skill-candidates/v0.0.10/figma-implement-design/assets/icon.svg +28 -0
- package/docs/skill-candidates/v0.0.10/figma-use/LICENSE.TXT +2 -0
- package/docs/skill-candidates/v0.0.10/figma-use/SKILL.md +233 -0
- package/docs/skill-candidates/v0.0.10/figma-use/agents/openai.yaml +14 -0
- package/docs/skill-candidates/v0.0.10/figma-use/assets/figma-small.svg +3 -0
- package/docs/skill-candidates/v0.0.10/figma-use/assets/figma.png +0 -0
- package/docs/skill-candidates/v0.0.10/figma-use/assets/icon.svg +28 -0
- package/docs/skill-candidates/v0.0.10/figma-use/maintainers.yml +1 -0
- package/docs/skill-candidates/v0.0.10/figma-use/references/api-reference.md +301 -0
- package/docs/skill-candidates/v0.0.10/figma-use/references/common-patterns.md +512 -0
- package/docs/skill-candidates/v0.0.10/figma-use/references/component-patterns.md +488 -0
- package/docs/skill-candidates/v0.0.10/figma-use/references/effect-style-patterns.md +123 -0
- package/docs/skill-candidates/v0.0.10/figma-use/references/gotchas.md +599 -0
- package/docs/skill-candidates/v0.0.10/figma-use/references/maintainers.yml +12 -0
- package/docs/skill-candidates/v0.0.10/figma-use/references/plugin-api-patterns.md +513 -0
- package/docs/skill-candidates/v0.0.10/figma-use/references/plugin-api-standalone.d.ts +11293 -0
- package/docs/skill-candidates/v0.0.10/figma-use/references/plugin-api-standalone.index.md +441 -0
- package/docs/skill-candidates/v0.0.10/figma-use/references/text-style-patterns.md +203 -0
- package/docs/skill-candidates/v0.0.10/figma-use/references/validation-and-recovery.md +109 -0
- package/docs/skill-candidates/v0.0.10/figma-use/references/variable-patterns.md +354 -0
- package/docs/skill-candidates/v0.0.10/figma-use/references/working-with-design-systems/maintainers.yml +9 -0
- package/docs/skill-candidates/v0.0.10/figma-use/references/working-with-design-systems/wwds-components--creating.md +17 -0
- package/docs/skill-candidates/v0.0.10/figma-use/references/working-with-design-systems/wwds-components--using.md +17 -0
- package/docs/skill-candidates/v0.0.10/figma-use/references/working-with-design-systems/wwds-components.md +50 -0
- package/docs/skill-candidates/v0.0.10/figma-use/references/working-with-design-systems/wwds-effect-styles.md +52 -0
- package/docs/skill-candidates/v0.0.10/figma-use/references/working-with-design-systems/wwds-text-styles.md +90 -0
- package/docs/skill-candidates/v0.0.10/figma-use/references/working-with-design-systems/wwds-variables--creating.md +13 -0
- package/docs/skill-candidates/v0.0.10/figma-use/references/working-with-design-systems/wwds-variables--using.md +13 -0
- package/docs/skill-candidates/v0.0.10/figma-use/references/working-with-design-systems/wwds-variables.md +64 -0
- package/docs/skill-candidates/v0.0.10/figma-use/references/working-with-design-systems/wwds.md +41 -0
- package/docs/skill-candidates/v0.0.10/frontend-design/LICENSE.txt +177 -0
- package/docs/skill-candidates/v0.0.10/frontend-design/SKILL.md +55 -0
- package/docs/skill-candidates/v0.0.10/frontend-ui-ux-systems/SKILL.md +32 -0
- package/docs/skill-candidates/v0.0.10/github/SKILL.md +74 -0
- package/docs/skill-candidates/v0.0.10/github/agents/openai.yaml +6 -0
- package/docs/skill-candidates/v0.0.10/github/assets/github-small.svg +3 -0
- package/docs/skill-candidates/v0.0.10/github/assets/github.png +0 -0
- package/docs/skill-candidates/v0.0.10/image-graphic-design-rendering/SKILL.md +28 -0
- package/docs/skill-candidates/v0.0.10/language-quality-pt-en-fr-it-ru/SKILL.md +28 -0
- package/docs/skill-candidates/v0.0.10/math-physics-reasoning/SKILL.md +28 -0
- package/docs/skill-candidates/v0.0.10/mcp-builder/LICENSE.txt +202 -0
- package/docs/skill-candidates/v0.0.10/mcp-builder/SKILL.md +236 -0
- package/docs/skill-candidates/v0.0.10/mcp-builder/reference/evaluation.md +602 -0
- package/docs/skill-candidates/v0.0.10/mcp-builder/reference/mcp_best_practices.md +249 -0
- package/docs/skill-candidates/v0.0.10/mcp-builder/reference/node_mcp_server.md +970 -0
- package/docs/skill-candidates/v0.0.10/mcp-builder/reference/python_mcp_server.md +719 -0
- package/docs/skill-candidates/v0.0.10/mcp-builder/scripts/connections.py +151 -0
- package/docs/skill-candidates/v0.0.10/mcp-builder/scripts/evaluation.py +373 -0
- package/docs/skill-candidates/v0.0.10/mcp-builder/scripts/example_evaluation.xml +22 -0
- package/docs/skill-candidates/v0.0.10/mcp-builder/scripts/requirements.txt +2 -0
- package/docs/skill-candidates/v0.0.10/mcp-client-readiness/SKILL.md +31 -0
- package/docs/skill-candidates/v0.0.10/openai-docs/LICENSE.txt +201 -0
- package/docs/skill-candidates/v0.0.10/openai-docs/SKILL.md +161 -0
- package/docs/skill-candidates/v0.0.10/openai-docs/agents/openai.yaml +14 -0
- package/docs/skill-candidates/v0.0.10/openai-docs/assets/openai-small.svg +3 -0
- package/docs/skill-candidates/v0.0.10/openai-docs/assets/openai.png +0 -0
- package/docs/skill-candidates/v0.0.10/openai-docs/references/latest-model.md +37 -0
- package/docs/skill-candidates/v0.0.10/openai-docs/references/prompting-guide.md +244 -0
- package/docs/skill-candidates/v0.0.10/openai-docs/references/upgrade-guide.md +181 -0
- package/docs/skill-candidates/v0.0.10/openai-docs/scripts/fetch-codex-manual.mjs +598 -0
- package/docs/skill-candidates/v0.0.10/openai-docs/scripts/resolve-latest-model-info.js +147 -0
- package/docs/skill-candidates/v0.0.10/playwright/LICENSE.txt +201 -0
- package/docs/skill-candidates/v0.0.10/playwright/NOTICE.txt +14 -0
- package/docs/skill-candidates/v0.0.10/playwright/SKILL.md +147 -0
- package/docs/skill-candidates/v0.0.10/playwright/agents/openai.yaml +6 -0
- package/docs/skill-candidates/v0.0.10/playwright/assets/playwright-small.svg +3 -0
- package/docs/skill-candidates/v0.0.10/playwright/assets/playwright.png +0 -0
- package/docs/skill-candidates/v0.0.10/playwright/references/cli.md +116 -0
- package/docs/skill-candidates/v0.0.10/playwright/references/workflows.md +95 -0
- package/docs/skill-candidates/v0.0.10/playwright/scripts/playwright_cli.sh +25 -0
- package/docs/skill-candidates/v0.0.10/polyglot-backend-engineering/SKILL.md +32 -0
- package/docs/skill-candidates/v0.0.10/screenshot/LICENSE.txt +201 -0
- package/docs/skill-candidates/v0.0.10/screenshot/SKILL.md +267 -0
- package/docs/skill-candidates/v0.0.10/screenshot/agents/openai.yaml +6 -0
- package/docs/skill-candidates/v0.0.10/screenshot/assets/screenshot-small.svg +5 -0
- package/docs/skill-candidates/v0.0.10/screenshot/assets/screenshot.png +0 -0
- package/docs/skill-candidates/v0.0.10/screenshot/scripts/ensure_macos_permissions.sh +54 -0
- package/docs/skill-candidates/v0.0.10/screenshot/scripts/macos_display_info.swift +22 -0
- package/docs/skill-candidates/v0.0.10/screenshot/scripts/macos_permissions.swift +40 -0
- package/docs/skill-candidates/v0.0.10/screenshot/scripts/macos_window_info.swift +126 -0
- package/docs/skill-candidates/v0.0.10/screenshot/scripts/take_screenshot.ps1 +163 -0
- package/docs/skill-candidates/v0.0.10/screenshot/scripts/take_screenshot.py +585 -0
- package/docs/skill-candidates/v0.0.10/skill-master-orchestrator/SKILL.md +62 -0
- package/docs/skill-candidates/v0.0.10/skill-master-orchestrator/agents/openai.yaml +4 -0
- package/docs/skill-candidates/v0.0.10/skill-master-orchestrator/references/activation-policy.md +77 -0
- package/docs/skill-candidates/v0.0.10/skill-master-orchestrator/references/human-approval-policy.md +83 -0
- package/docs/skill-candidates/v0.0.10/skill-master-orchestrator/references/persona-dev-senior-master.md +46 -0
- package/docs/skill-candidates/v0.0.10/terminal-menu-operations/SKILL.md +30 -0
- package/docs/skill-candidates/v0.0.10/terminal-pixel-art-tui/SKILL.md +43 -0
- package/docs/skill-candidates/v0.0.10/webapp-testing/LICENSE.txt +202 -0
- package/docs/skill-candidates/v0.0.10/webapp-testing/SKILL.md +96 -0
- package/docs/skill-candidates/v0.0.10/webapp-testing/examples/console_logging.py +35 -0
- package/docs/skill-candidates/v0.0.10/webapp-testing/examples/element_discovery.py +40 -0
- package/docs/skill-candidates/v0.0.10/webapp-testing/examples/static_html_automation.py +33 -0
- package/docs/skill-candidates/v0.0.10/webapp-testing/scripts/with_server.py +106 -0
- package/docs/skill-candidates/v0.0.10/winui-app/LICENSE.txt +202 -0
- package/docs/skill-candidates/v0.0.10/winui-app/SKILL.md +94 -0
- package/docs/skill-candidates/v0.0.10/winui-app/agents/openai.yaml +5 -0
- package/docs/skill-candidates/v0.0.10/winui-app/assets/winui.png +0 -0
- package/docs/skill-candidates/v0.0.10/winui-app/config.yaml +50 -0
- package/docs/skill-candidates/v0.0.10/winui-app/references/_sections.md +96 -0
- package/docs/skill-candidates/v0.0.10/winui-app/references/accessibility-input-and-localization.md +51 -0
- package/docs/skill-candidates/v0.0.10/winui-app/references/build-run-and-launch-verification.md +72 -0
- package/docs/skill-candidates/v0.0.10/winui-app/references/community-toolkit-controls-and-helpers.md +57 -0
- package/docs/skill-candidates/v0.0.10/winui-app/references/controls-layout-and-adaptive-ui.md +84 -0
- package/docs/skill-candidates/v0.0.10/winui-app/references/foundation-environment-audit-and-remediation.md +82 -0
- package/docs/skill-candidates/v0.0.10/winui-app/references/foundation-setup-and-project-selection.md +67 -0
- package/docs/skill-candidates/v0.0.10/winui-app/references/foundation-template-first-recovery.md +62 -0
- package/docs/skill-candidates/v0.0.10/winui-app/references/foundation-winui-app-structure.md +62 -0
- package/docs/skill-candidates/v0.0.10/winui-app/references/motion-animations-and-polish.md +45 -0
- package/docs/skill-candidates/v0.0.10/winui-app/references/performance-diagnostics-and-responsiveness.md +46 -0
- package/docs/skill-candidates/v0.0.10/winui-app/references/sample-source-map.md +37 -0
- package/docs/skill-candidates/v0.0.10/winui-app/references/shell-navigation-and-windowing.md +67 -0
- package/docs/skill-candidates/v0.0.10/winui-app/references/styling-theming-materials-and-icons.md +71 -0
- package/docs/skill-candidates/v0.0.10/winui-app/references/testing-debugging-and-review-checklists.md +77 -0
- package/docs/skill-candidates/v0.0.10/winui-app/references/windows-app-sdk-lifecycle-notifications-and-deployment.md +52 -0
- package/docs/skill-candidates/v0.0.11/frontend-dev-guidelines/SKILL.md +399 -0
- package/docs/skill-candidates/v0.0.11/frontend-dev-guidelines/resources/common-patterns.md +331 -0
- package/docs/skill-candidates/v0.0.11/frontend-dev-guidelines/resources/complete-examples.md +872 -0
- package/docs/skill-candidates/v0.0.11/frontend-dev-guidelines/resources/component-patterns.md +502 -0
- package/docs/skill-candidates/v0.0.11/frontend-dev-guidelines/resources/data-fetching.md +767 -0
- package/docs/skill-candidates/v0.0.11/frontend-dev-guidelines/resources/file-organization.md +502 -0
- package/docs/skill-candidates/v0.0.11/frontend-dev-guidelines/resources/loading-and-error-states.md +501 -0
- package/docs/skill-candidates/v0.0.11/frontend-dev-guidelines/resources/performance.md +406 -0
- package/docs/skill-candidates/v0.0.11/frontend-dev-guidelines/resources/routing-guide.md +364 -0
- package/docs/skill-candidates/v0.0.11/frontend-dev-guidelines/resources/styling-guide.md +428 -0
- package/docs/skill-candidates/v0.0.11/frontend-dev-guidelines/resources/typescript-standards.md +418 -0
- package/docs/skill-candidates/v0.0.11/git-version-control-ops/SKILL.md +34 -0
- package/docs/skill-candidates/v0.0.11/go-engineering/SKILL.md +34 -0
- package/docs/skill-candidates/v0.0.11/java-engineering/SKILL.md +34 -0
- package/docs/skill-candidates/v0.0.11/javascript-engineering/SKILL.md +34 -0
- package/docs/skill-candidates/v0.0.11/json-contract-design/SKILL.md +34 -0
- package/docs/skill-candidates/v0.0.11/multi-client-mcp-ops/SKILL.md +36 -0
- package/docs/skill-candidates/v0.0.11/nextjs/SKILL.md +745 -0
- package/docs/skill-candidates/v0.0.11/nextjs/agents/openai.yaml +3 -0
- package/docs/skill-candidates/v0.0.11/nextjs/references/app-router-files.md +94 -0
- package/docs/skill-candidates/v0.0.11/python-engineering/SKILL.md +34 -0
- package/docs/skill-candidates/v0.0.11/ruby-engineering/SKILL.md +34 -0
- package/docs/skill-candidates/v0.0.11/senior-fullstack/SKILL.md +209 -0
- package/docs/skill-candidates/v0.0.11/senior-fullstack/references/architecture_patterns.md +103 -0
- package/docs/skill-candidates/v0.0.11/senior-fullstack/references/development_workflows.md +103 -0
- package/docs/skill-candidates/v0.0.11/senior-fullstack/references/tech_stack_guide.md +103 -0
- package/docs/skill-candidates/v0.0.11/senior-fullstack/scripts/code_quality_analyzer.py +114 -0
- package/docs/skill-candidates/v0.0.11/senior-fullstack/scripts/fullstack_scaffolder.py +114 -0
- package/docs/skill-candidates/v0.0.11/senior-fullstack/scripts/project_scaffolder.py +114 -0
- package/docs/skill-candidates/v0.0.11/shadcn/SKILL.md +573 -0
- package/docs/skill-candidates/v0.0.11/shadcn/agents/openai.yaml +3 -0
- package/docs/skill-candidates/v0.0.11/sql-postgresql-engineering/SKILL.md +34 -0
- package/docs/skill-candidates/v0.0.11/terminal-shell-ops/SKILL.md +34 -0
- package/docs/skill-candidates/v0.0.11/typescript-expert/SKILL.md +429 -0
- package/docs/skill-candidates/v0.0.11/typescript-expert/references/tsconfig-strict.json +92 -0
- package/docs/skill-candidates/v0.0.11/typescript-expert/references/typescript-cheatsheet.md +383 -0
- package/docs/skill-candidates/v0.0.11/typescript-expert/references/utility-types.ts +335 -0
- package/docs/skill-candidates/v0.0.11/typescript-expert/scripts/ts_diagnostic.py +203 -0
- package/docs/skill-candidates/v0.0.11/ui-component-primitives/SKILL.md +34 -0
- package/docs/skill-candidates/v0.0.11/web-mobile-design-systems/SKILL.md +34 -0
- package/docs/skill-candidates/v0.0.11/windows-linux-platform-ops/SKILL.md +34 -0
- package/manifests/channels/beta.json +7 -7
- package/manifests/channels/stable.json +8 -8
- package/network/unapproved-skill-candidates.json +34 -1
- package/package.json +7 -2
- package/scripts/verify-menu-actions.mjs +115 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# Validation Workflow & Error Recovery
|
|
2
|
+
|
|
3
|
+
> Part of the [use_figma skill](../SKILL.md). How to debug, validate, and recover from errors.
|
|
4
|
+
|
|
5
|
+
## Contents
|
|
6
|
+
|
|
7
|
+
- `get_metadata` vs `get_screenshot`
|
|
8
|
+
- Error Recovery After Failed `use_figma`
|
|
9
|
+
- Cleanup Pattern
|
|
10
|
+
- Recommended Workflow
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
## `get_metadata` vs `get_screenshot`
|
|
14
|
+
|
|
15
|
+
After each `use_figma` call, validate results using the right tool for the job. Do NOT reach for `get_screenshot` every time — it is expensive and should be reserved for visual checks.
|
|
16
|
+
|
|
17
|
+
### `get_metadata` — Use for intermediate validation (preferred)
|
|
18
|
+
|
|
19
|
+
`get_metadata` returns an XML tree of node IDs, types, names, positions, and sizes. Use it to confirm:
|
|
20
|
+
|
|
21
|
+
- **Structure & hierarchy**: correct parent-child relationships, component nesting, section contents
|
|
22
|
+
- **Node counts**: expected number of variants created, children present
|
|
23
|
+
- **Naming**: variant property names follow the `property=value` convention
|
|
24
|
+
- **Positioning & alignment**: x/y coordinates, width/height values match expectations
|
|
25
|
+
- **Layout properties**: auto-layout direction, sizing mode, padding, spacing
|
|
26
|
+
- **Component set membership**: all expected variants are inside the ComponentSet
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
Example: After creating a ComponentSet with 120 variants, call get_metadata on the
|
|
30
|
+
ComponentSet node to verify all 120 children exist with correct names, sizes, and positions
|
|
31
|
+
— without waiting for a full render.
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**When to use `get_metadata`:**
|
|
35
|
+
- After creating/modifying nodes — to verify structure, counts, and names
|
|
36
|
+
- After layout operations — to verify positions and dimensions
|
|
37
|
+
- After combining variants — to confirm all components are in the ComponentSet
|
|
38
|
+
- After binding variables — to verify node properties (use use_figma to read bound variables if needed)
|
|
39
|
+
- Between multi-step workflows — to confirm step N succeeded before starting step N+1
|
|
40
|
+
|
|
41
|
+
### `get_screenshot` — Use after each major creation milestone
|
|
42
|
+
|
|
43
|
+
`get_screenshot` renders a pixel-accurate image. It is the only way to verify visual correctness (colors, typography rendering, effects, variable mode resolution). It is slower and produces large responses, so don't call it after every single `use_figma` — but do call it after each major milestone to catch visual problems early.
|
|
44
|
+
|
|
45
|
+
**When to use `get_screenshot`:**
|
|
46
|
+
- **After creating a component set** — verify variants look correct, grid is readable, nothing is collapsed or overlapping
|
|
47
|
+
- **After composing a layout** — verify overall structure and spacing
|
|
48
|
+
- **After binding variables/modes** — verify colors and tokens resolved correctly
|
|
49
|
+
- **After any fix or recovery** — verify the fix didn't introduce new visual issues
|
|
50
|
+
- **Before reporting results to the user** — final visual proof
|
|
51
|
+
|
|
52
|
+
**What to look for in screenshots** — these are the most commonly missed issues:
|
|
53
|
+
- **Cropped/clipped text** — line heights or frame sizing cutting off descenders, ascenders, or entire lines
|
|
54
|
+
- **Overlapping content** — elements stacking on top of each other due to incorrect sizing or missing auto-layout
|
|
55
|
+
- **Placeholder text** still showing ("Title", "Heading", "Button") instead of actual content
|
|
56
|
+
|
|
57
|
+
## CRITICAL: Error Recovery After Failed `use_figma`
|
|
58
|
+
|
|
59
|
+
> **THIS IS NOT OPTIONAL.** Every `use_figma` error MUST trigger the recovery steps below. Skipping these steps leaves orphaned nodes in the file that will cause duplicates and inconsistencies on retry.
|
|
60
|
+
|
|
61
|
+
**Scripts can partially execute before hitting an error.** A failed `use_figma` does NOT roll back — nodes created before the error line persist in the file. This leaves the file in an **inconsistent, partially-modified state**.
|
|
62
|
+
|
|
63
|
+
**Mandatory recovery steps when `use_figma` returns an error (DO NOT SKIP):**
|
|
64
|
+
1. **STOP — do NOT immediately fix the code and retry.** The file has partial state that must be inspected first.
|
|
65
|
+
2. **Immediately call `get_metadata`** on the parent node (section, page, or ComponentSet) to see what was partially created.
|
|
66
|
+
3. **If `get_metadata` doesn't make the damage clear** (e.g. positions look fine but visual state is uncertain), call `get_screenshot` to assess visual damage.
|
|
67
|
+
4. **Write a cleanup script** to remove orphaned/incomplete nodes before retrying. Use `page.findChildren()` to locate stray nodes.
|
|
68
|
+
5. **Only after cleanup is confirmed**, fix the original script and retry.
|
|
69
|
+
6. **Never retry the failed script blindly** — the partial state means a retry will create duplicates or hit new errors.
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
Example: A script creating 8 components fails on component #5.
|
|
73
|
+
Components 1-4 exist on the page. A naive retry creates components 1-8 again,
|
|
74
|
+
leaving 12 components total (4 orphaned duplicates). Always clean up first.
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Cleanup Pattern
|
|
78
|
+
|
|
79
|
+
```js
|
|
80
|
+
// Cleanup pattern: find and remove orphaned nodes from a failed run
|
|
81
|
+
(async () => {
|
|
82
|
+
try {
|
|
83
|
+
const page = figma.currentPage;
|
|
84
|
+
// Find orphaned components that weren't combined into a ComponentSet
|
|
85
|
+
const orphans = page.findChildren(n =>
|
|
86
|
+
n.type === 'COMPONENT' && n.name.includes('variant=')
|
|
87
|
+
);
|
|
88
|
+
for (const orphan of orphans) orphan.remove();
|
|
89
|
+
figma.closePlugin('Cleaned up ' + orphans.length + ' orphaned nodes');
|
|
90
|
+
} catch(e) { figma.closePluginWithFailure(e.toString()); }
|
|
91
|
+
})()
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Recommended Workflow
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
1. use_figma → Create/modify nodes
|
|
98
|
+
2. get_metadata → Verify structure, counts, names, positions (fast, cheap)
|
|
99
|
+
3. use_figma → Fix any structural issues found
|
|
100
|
+
4. get_metadata → Re-verify fixes
|
|
101
|
+
5. ... repeat as needed ...
|
|
102
|
+
6. get_screenshot → Visual check after each major milestone
|
|
103
|
+
|
|
104
|
+
⚠️ ON ERROR at any step:
|
|
105
|
+
a. get_metadata → Inspect partial state (always do this first)
|
|
106
|
+
b. get_screenshot → Only if metadata doesn't make the damage clear
|
|
107
|
+
c. use_figma → Clean up orphaned/incomplete nodes
|
|
108
|
+
d. THEN retry the failed operation
|
|
109
|
+
```
|
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
# Variable & Token API Patterns
|
|
2
|
+
|
|
3
|
+
> Part of the [use_figma skill](../SKILL.md). How to correctly create, bind, scope, and alias variables using the Plugin API.
|
|
4
|
+
>
|
|
5
|
+
> For design system context (aliasing strategy, mode decisions, code syntax philosophy, grouping conventions), see [wwds-variables](working-with-design-systems/wwds-variables.md).
|
|
6
|
+
|
|
7
|
+
## Contents
|
|
8
|
+
|
|
9
|
+
- Creating Variable Collections and Modes
|
|
10
|
+
- Creating Variables (All Types)
|
|
11
|
+
- Binding Variables to Node Properties
|
|
12
|
+
- Variable Scopes: What They Are and How to Set Them
|
|
13
|
+
- Variable Aliasing (VARIABLE_ALIAS)
|
|
14
|
+
- Code Syntax (setVariableCodeSyntax)
|
|
15
|
+
- Discovering Existing Variables in the File
|
|
16
|
+
- Effect Styles (For Shadows)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
## Creating Variable Collections and Modes
|
|
20
|
+
|
|
21
|
+
```javascript
|
|
22
|
+
const collection = figma.variables.createVariableCollection("MyCollection");
|
|
23
|
+
|
|
24
|
+
// A new collection starts with 1 mode named "Mode 1" — always rename it
|
|
25
|
+
collection.renameMode(collection.modes[0].modeId, "Light");
|
|
26
|
+
|
|
27
|
+
// Add additional modes (returns the new modeId)
|
|
28
|
+
const darkModeId = collection.addMode("Dark");
|
|
29
|
+
const lightModeId = collection.modes[0].modeId;
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**Mode limits are plan-dependent:** Free = 1 mode, Professional = up to 4, Organization/Enterprise = 40+. If you need many modes, split across multiple collections.
|
|
33
|
+
|
|
34
|
+
## Creating Variables (All Types)
|
|
35
|
+
|
|
36
|
+
`figma.variables.createVariable(name, collection, resolvedType)` — the second argument accepts a collection object or ID string (object preferred).
|
|
37
|
+
|
|
38
|
+
```javascript
|
|
39
|
+
// COLOR — values use {r, g, b, a} (all 0–1 range, includes alpha)
|
|
40
|
+
const colorVar = figma.variables.createVariable("my-color", collection, "COLOR");
|
|
41
|
+
colorVar.setValueForMode(modeId, { r: 0.2, g: 0.36, b: 0.96, a: 1 });
|
|
42
|
+
|
|
43
|
+
// FLOAT — for spacing, radii, sizing, numeric values
|
|
44
|
+
const floatVar = figma.variables.createVariable("my-spacing", collection, "FLOAT");
|
|
45
|
+
floatVar.setValueForMode(modeId, 16);
|
|
46
|
+
|
|
47
|
+
// STRING — for font families, font style names, any text value
|
|
48
|
+
const stringVar = figma.variables.createVariable("my-font", collection, "STRING");
|
|
49
|
+
stringVar.setValueForMode(modeId, "Inter");
|
|
50
|
+
|
|
51
|
+
// BOOLEAN
|
|
52
|
+
const boolVar = figma.variables.createVariable("my-flag", collection, "BOOLEAN");
|
|
53
|
+
boolVar.setValueForMode(modeId, true);
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**Note:** Paint colors use `{r, g, b}` (no alpha), but COLOR variable values use `{r, g, b, a}` (with alpha). Don't mix them up.
|
|
57
|
+
|
|
58
|
+
## Binding Variables to Node Properties
|
|
59
|
+
|
|
60
|
+
### Color Bindings (Fills, Strokes)
|
|
61
|
+
|
|
62
|
+
`setBoundVariableForPaint` returns a **NEW paint** — you must capture the return value:
|
|
63
|
+
|
|
64
|
+
```javascript
|
|
65
|
+
// Create a base paint, bind the variable, assign the result
|
|
66
|
+
const basePaint = { type: 'SOLID', color: { r: 0, g: 0, b: 0 } };
|
|
67
|
+
const boundPaint = figma.variables.setBoundVariableForPaint(basePaint, "color", colorVar);
|
|
68
|
+
node.fills = [boundPaint];
|
|
69
|
+
|
|
70
|
+
// Only SOLID paints support color variable binding — gradients/images will throw
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Numeric Bindings (Spacing, Radii, Sizing)
|
|
74
|
+
|
|
75
|
+
`setBoundVariable` binds FLOAT/STRING/BOOLEAN variables to node properties:
|
|
76
|
+
|
|
77
|
+
```javascript
|
|
78
|
+
// Padding
|
|
79
|
+
node.setBoundVariable("paddingTop", spacingVar);
|
|
80
|
+
node.setBoundVariable("paddingBottom", spacingVar);
|
|
81
|
+
node.setBoundVariable("paddingLeft", spacingVar);
|
|
82
|
+
node.setBoundVariable("paddingRight", spacingVar);
|
|
83
|
+
|
|
84
|
+
// Gap
|
|
85
|
+
node.setBoundVariable("itemSpacing", gapVar);
|
|
86
|
+
node.setBoundVariable("counterAxisSpacing", gapVar);
|
|
87
|
+
|
|
88
|
+
// Corner radius — use individual corners, NOT cornerRadius
|
|
89
|
+
node.setBoundVariable("topLeftRadius", radiusVar);
|
|
90
|
+
node.setBoundVariable("topRightRadius", radiusVar);
|
|
91
|
+
node.setBoundVariable("bottomLeftRadius", radiusVar);
|
|
92
|
+
node.setBoundVariable("bottomRightRadius", radiusVar);
|
|
93
|
+
|
|
94
|
+
// Size
|
|
95
|
+
node.setBoundVariable("width", sizeVar);
|
|
96
|
+
node.setBoundVariable("height", sizeVar);
|
|
97
|
+
node.setBoundVariable("minWidth", sizeVar);
|
|
98
|
+
node.setBoundVariable("maxWidth", sizeVar);
|
|
99
|
+
|
|
100
|
+
// Other
|
|
101
|
+
node.setBoundVariable("opacity", opacityVar);
|
|
102
|
+
node.setBoundVariable("strokeWeight", strokeVar);
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
**Not bindable via setBoundVariable:** `fontSize`, `fontWeight`, `lineHeight` — set these directly on text nodes.
|
|
106
|
+
|
|
107
|
+
### Effect Bindings
|
|
108
|
+
|
|
109
|
+
```javascript
|
|
110
|
+
const effectCopy = JSON.parse(JSON.stringify(node.effects[0]));
|
|
111
|
+
const newEffect = figma.variables.setBoundVariableForEffect(effectCopy, "color", colorVar);
|
|
112
|
+
// ⚠️ Returns a NEW effect — must capture return value!
|
|
113
|
+
node.effects = [newEffect];
|
|
114
|
+
// Valid fields: "color" (COLOR), "radius" | "spread" | "offsetX" | "offsetY" (FLOAT)
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Applying a Mode to a Frame
|
|
118
|
+
|
|
119
|
+
```javascript
|
|
120
|
+
// All bound children of this frame will resolve to the specified mode's values
|
|
121
|
+
frame.setExplicitVariableModeForCollection(collection.id, modeId);
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Without this, all nodes use the collection's default (first) mode.
|
|
125
|
+
|
|
126
|
+
## Variable Scopes: What They Are and How to Set Them
|
|
127
|
+
|
|
128
|
+
`variable.scopes` controls which Figma property pickers show the variable. The default is `["ALL_SCOPES"]` which shows it everywhere — this is almost never what you want.
|
|
129
|
+
|
|
130
|
+
```javascript
|
|
131
|
+
variable.scopes = ["FRAME_FILL", "SHAPE_FILL"]; // only fill pickers
|
|
132
|
+
variable.scopes = ["TEXT_FILL"]; // only text color picker
|
|
133
|
+
variable.scopes = ["GAP"]; // only gap/spacing pickers
|
|
134
|
+
variable.scopes = ["CORNER_RADIUS"]; // only radius pickers
|
|
135
|
+
variable.scopes = []; // hidden from all pickers
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
**All valid scope values:**
|
|
139
|
+
`ALL_SCOPES`, `TEXT_CONTENT`, `CORNER_RADIUS`, `WIDTH_HEIGHT`, `GAP`, `ALL_FILLS`, `FRAME_FILL`, `SHAPE_FILL`, `TEXT_FILL`, `STROKE_COLOR`, `STROKE_FLOAT`, `EFFECT_FLOAT`, `EFFECT_COLOR`, `OPACITY`, `FONT_FAMILY`, `FONT_STYLE`, `FONT_WEIGHT`, `FONT_SIZE`, `LINE_HEIGHT`, `LETTER_SPACING`, `PARAGRAPH_SPACING`, `PARAGRAPH_INDENT`
|
|
140
|
+
|
|
141
|
+
**Always check the existing file's scope patterns before creating variables** — match whatever convention is already in use. See "Discovering Existing Variables" below.
|
|
142
|
+
|
|
143
|
+
## Variable Aliasing (VARIABLE_ALIAS)
|
|
144
|
+
|
|
145
|
+
A variable's value can reference another variable via alias. This is how semantic tokens reference primitive tokens:
|
|
146
|
+
|
|
147
|
+
```javascript
|
|
148
|
+
// Set a variable's value as an alias to another variable
|
|
149
|
+
semanticVar.setValueForMode(modeId, {
|
|
150
|
+
type: 'VARIABLE_ALIAS',
|
|
151
|
+
id: primitiveVar.id
|
|
152
|
+
});
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
When the primitive changes, the semantic variable updates automatically across all modes.
|
|
156
|
+
|
|
157
|
+
## Code Syntax (setVariableCodeSyntax)
|
|
158
|
+
|
|
159
|
+
Links a Figma variable back to its code counterpart. Call once per platform:
|
|
160
|
+
|
|
161
|
+
```javascript
|
|
162
|
+
variable.setVariableCodeSyntax('WEB', 'var(--color-bg-default)');
|
|
163
|
+
variable.setVariableCodeSyntax('ANDROID', 'colorBgDefault');
|
|
164
|
+
variable.setVariableCodeSyntax('iOS', 'Color.bgDefault');
|
|
165
|
+
|
|
166
|
+
// Read back: variable.codeSyntax → { WEB: '...', ANDROID: '...', iOS: '...' }
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
**When deriving CSS names from Figma names**, replace both slashes AND spaces with hyphens:
|
|
170
|
+
|
|
171
|
+
```javascript
|
|
172
|
+
// WRONG — leaves spaces in CSS variable name
|
|
173
|
+
`var(--${figmaName.replace(/\//g, '-').toLowerCase()})`
|
|
174
|
+
|
|
175
|
+
// CORRECT — replace all whitespace and slashes
|
|
176
|
+
`var(--${figmaName.replace(/[\s\/]+/g, '-').toLowerCase()})`
|
|
177
|
+
|
|
178
|
+
// BEST — use the original CSS variable name from the source, not a derived one
|
|
179
|
+
`var(${token.cssVar})`
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## Discovering Existing Variables in the File
|
|
183
|
+
|
|
184
|
+
**Always inspect the file's existing variables before creating new ones.** Different files use different naming conventions, scope patterns, and collection structures. Match what's already there.
|
|
185
|
+
|
|
186
|
+
### List collections with mode info
|
|
187
|
+
|
|
188
|
+
```javascript
|
|
189
|
+
(async () => {
|
|
190
|
+
try {
|
|
191
|
+
const collections = figma.variables.getLocalVariableCollections();
|
|
192
|
+
const results = collections.map(c => ({
|
|
193
|
+
name: c.name,
|
|
194
|
+
id: c.id,
|
|
195
|
+
varCount: c.variableIds.length,
|
|
196
|
+
modes: c.modes.map(m => ({ name: m.name, id: m.modeId }))
|
|
197
|
+
}));
|
|
198
|
+
figma.closePlugin(JSON.stringify(results));
|
|
199
|
+
} catch(e) { figma.closePluginWithFailure(e.toString()); }
|
|
200
|
+
})()
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Inspect scope patterns used in existing variables
|
|
204
|
+
|
|
205
|
+
```javascript
|
|
206
|
+
(async () => {
|
|
207
|
+
try {
|
|
208
|
+
const collections = figma.variables.getLocalVariableCollections();
|
|
209
|
+
const scopeGroups = {};
|
|
210
|
+
for (const c of collections) {
|
|
211
|
+
for (const id of c.variableIds) {
|
|
212
|
+
const v = figma.variables.getVariableById(id);
|
|
213
|
+
const key = JSON.stringify(v.scopes);
|
|
214
|
+
if (!scopeGroups[key]) scopeGroups[key] = [];
|
|
215
|
+
scopeGroups[key].push(v.name);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
figma.closePlugin(JSON.stringify(scopeGroups));
|
|
219
|
+
} catch(e) { figma.closePluginWithFailure(e.toString()); }
|
|
220
|
+
})()
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### Build a name→variable lookup for reuse
|
|
224
|
+
|
|
225
|
+
```javascript
|
|
226
|
+
const varByName = {};
|
|
227
|
+
for (const v of figma.variables.getLocalVariables()) {
|
|
228
|
+
varByName[v.name] = v;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// Bind to existing variable by name — no hex values needed
|
|
232
|
+
function bindFill(node, varName) {
|
|
233
|
+
const v = varByName[varName];
|
|
234
|
+
if (!v) throw new Error(`Variable not found: ${varName}`);
|
|
235
|
+
const paint = figma.variables.setBoundVariableForPaint(
|
|
236
|
+
{ type: 'SOLID', color: { r: 0, g: 0, b: 0 } }, 'color', v
|
|
237
|
+
);
|
|
238
|
+
node.fills = [paint];
|
|
239
|
+
}
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
**Only create new variables for tokens that have no match in the file.** After building the lookup, compare against the needed tokens and create variables only for the delta.
|
|
243
|
+
|
|
244
|
+
## Listing Collections with Full Variable Details
|
|
245
|
+
|
|
246
|
+
The async API returns richer data including code syntax and scopes per variable:
|
|
247
|
+
|
|
248
|
+
```javascript
|
|
249
|
+
/**
|
|
250
|
+
* Lists all local variable collections defined in the current Figma file,
|
|
251
|
+
* including metadata for their modes and variables.
|
|
252
|
+
*
|
|
253
|
+
* @returns {Promise<Array<{
|
|
254
|
+
* name: string,
|
|
255
|
+
* id: string,
|
|
256
|
+
* modes: Array<[name: string, modeId: string]>,
|
|
257
|
+
* variables: Array<[name: string, id: string, codeSyntax: object, scopes: string[]]>
|
|
258
|
+
* }>>}
|
|
259
|
+
*/
|
|
260
|
+
async function listVariableCollectionsAndVariables() {
|
|
261
|
+
const collections = await figma.variables.getLocalVariableCollectionsAsync();
|
|
262
|
+
const results = [];
|
|
263
|
+
for (const collection of collections) {
|
|
264
|
+
const vars = [];
|
|
265
|
+
for (const id of collection.variableIds) {
|
|
266
|
+
const v = await figma.variables.getVariableByIdAsync(id);
|
|
267
|
+
vars.push([v.name, v.id, v.codeSyntax, v.scopes]);
|
|
268
|
+
}
|
|
269
|
+
results.push({
|
|
270
|
+
name: collection.name,
|
|
271
|
+
id: collection.id,
|
|
272
|
+
modes: collection.modes.map(m => [m.name, m.modeId]),
|
|
273
|
+
variables: vars
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
return results;
|
|
277
|
+
}
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
Full runnable script:
|
|
281
|
+
|
|
282
|
+
```javascript
|
|
283
|
+
(async () => {
|
|
284
|
+
try {
|
|
285
|
+
const results = await listVariableCollectionsAndVariables();
|
|
286
|
+
figma.closePlugin(JSON.stringify(results));
|
|
287
|
+
} catch(e) { figma.closePluginWithFailure(e.toString()); }
|
|
288
|
+
})()
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
## Setting and Removing Code Syntax
|
|
292
|
+
|
|
293
|
+
Must be executed in the file the variable is defined in:
|
|
294
|
+
|
|
295
|
+
```javascript
|
|
296
|
+
/**
|
|
297
|
+
* Set the code syntax for a variable for a specific platform.
|
|
298
|
+
*
|
|
299
|
+
* @param {string} variableId
|
|
300
|
+
* @param {'WEB'|'ANDROID'|'iOS'} platform
|
|
301
|
+
* @param {string} syntax
|
|
302
|
+
*/
|
|
303
|
+
async function setVariableCodeSyntax(variableId, platform, syntax) {
|
|
304
|
+
const variable = await figma.variables.getVariableByIdAsync(variableId);
|
|
305
|
+
variable.setVariableCodeSyntax(platform, syntax);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Remove code syntax for a variable for one or more platforms.
|
|
310
|
+
*
|
|
311
|
+
* @param {string} variableId
|
|
312
|
+
* @param {Array<'WEB'|'ANDROID'|'iOS'>} platforms — defaults to all three
|
|
313
|
+
*/
|
|
314
|
+
async function removeVariableCodeSyntax(variableId, platforms = ["WEB", "ANDROID", "iOS"]) {
|
|
315
|
+
const variable = await figma.variables.getVariableByIdAsync(variableId);
|
|
316
|
+
for (const platform of platforms) {
|
|
317
|
+
variable.removeVariableCodeSyntax(platform);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Set a value for a variable in a specific mode.
|
|
323
|
+
* For aliases, value must be: { type: 'VARIABLE_ALIAS', id: '<variableId>' }
|
|
324
|
+
*
|
|
325
|
+
* @param {string} variableId
|
|
326
|
+
* @param {string} modeId
|
|
327
|
+
* @param {string|number|boolean|RGB|RGBA|{type: 'VARIABLE_ALIAS', id: string}} value
|
|
328
|
+
*/
|
|
329
|
+
async function setVariableValueForMode(variableId, modeId, value) {
|
|
330
|
+
const variable = await figma.variables.getVariableByIdAsync(variableId);
|
|
331
|
+
variable.setValueForMode(modeId, value);
|
|
332
|
+
}
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
## Effect Styles (For Shadows)
|
|
336
|
+
|
|
337
|
+
Shadows can't be stored as variables. Use effect styles. For comprehensive patterns, see [effect-style-patterns.md](effect-style-patterns.md).
|
|
338
|
+
|
|
339
|
+
```javascript
|
|
340
|
+
const shadow = figma.createEffectStyle();
|
|
341
|
+
shadow.name = "Shadow/Subtle";
|
|
342
|
+
shadow.effects = [{
|
|
343
|
+
type: "DROP_SHADOW",
|
|
344
|
+
color: { r: 0, g: 0, b: 0, a: 0.06 },
|
|
345
|
+
offset: { x: 0, y: 2 },
|
|
346
|
+
radius: 8,
|
|
347
|
+
spread: 0,
|
|
348
|
+
visible: true,
|
|
349
|
+
blendMode: "NORMAL"
|
|
350
|
+
}];
|
|
351
|
+
|
|
352
|
+
// Apply to a node
|
|
353
|
+
frame.effectStyleId = shadow.id;
|
|
354
|
+
```
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
wwds-components--creating.md: mcp_server
|
|
2
|
+
wwds-components--using.md: mcp_server
|
|
3
|
+
wwds-components.md: mcp_server
|
|
4
|
+
wwds-effect-styles.md: mcp_server
|
|
5
|
+
wwds-text-styles.md: mcp_server
|
|
6
|
+
wwds-variables--creating.md: mcp_server
|
|
7
|
+
wwds-variables--using.md: mcp_server
|
|
8
|
+
wwds-variables.md: mcp_server
|
|
9
|
+
wwds.md: mcp_server
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Working with design systems: Creating Components
|
|
2
|
+
|
|
3
|
+
When creating Figma components, you need to start by understanding the source and its intent.
|
|
4
|
+
|
|
5
|
+
If the user is asking you to create a component based on a design or specification, you need to understand the property model before you build anything. What variants are needed? What text, boolean, or instance swap properties exist? Getting the structure right upfront matters because restructuring a component after instances exist is destructive.
|
|
6
|
+
|
|
7
|
+
If you are given a code component as reference (React props, tokens, etc.), your goal is to reflect the property surface as closely as makes sense in Figma's model. Not all code properties translate directly — hover and focus states are not props in web code, but they are variants in Figma. Understand those gaps and make deliberate decisions about how to represent them.
|
|
8
|
+
|
|
9
|
+
Variants are the most important thing to get right. Each combination of variant values creates a node on the canvas. Redundant combinations still exist as explicit nodes — there is no way to conditionally exclude them. Define only the axes you actually need.
|
|
10
|
+
|
|
11
|
+
Non-variant properties (text, boolean, instance swap) should be added after the variant structure is established. These are defined at the component/component set level and referenced by descendant nodes via `componentPropertyReferences`. Always connect them — a property that isn't wired to a descendant is invisible to users of the component.
|
|
12
|
+
|
|
13
|
+
If the user asks you to make architectural decisions, lean toward fewer variants and more boolean/text properties where possible. Variants multiply combinatorially; the other property types do not. An optional slot property in code might be a combination of instance swap and boolean visibility.
|
|
14
|
+
|
|
15
|
+
When naming properties, casing is less important since translation layers like Code Connect can do the mapping to represent the code form. Feel free to take a sentence or capitalized case approach for better readability in Figma.
|
|
16
|
+
|
|
17
|
+
Keep in mind that components often need to be published and connected to Code Connect for the full design-to-code workflow to work. Creating the component is only one part of the system.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Working with design systems: Using Components
|
|
2
|
+
|
|
3
|
+
When using Figma components, you need to start by understanding the state of the source and the state of Figma.
|
|
4
|
+
|
|
5
|
+
For the source, you need to know what component is being referenced. This could come from a component key, a node ID, a name, or a Code Connect mapping. If you have a component key from a design system library, prefer `importComponentByKeyAsync` over finding by name, since names are not unique. If you only have a name, search the page or use `search_design_system` to find the right match.
|
|
6
|
+
|
|
7
|
+
For Figma, you need to know whether the component is local or in a library. Local components can be accessed directly by node ID. Published library components must be imported first — `importComponentByKeyAsync` or `importComponentSetByKeyAsync` — before an instance can be created.
|
|
8
|
+
|
|
9
|
+
Before setting properties on an instance, read `componentPropertyDefinitions` from the main component first. Property names are not simple strings — TEXT, BOOLEAN, and INSTANCE_SWAP properties have a `#uid` suffix (e.g. `"Label#1234"`). Only VARIANT properties are plain names (e.g. `"Size"`). Using the wrong key in `setProperties` will silently do nothing.
|
|
10
|
+
|
|
11
|
+
A component might have multiple text properties, which are not possible to derive from text node layer names. Look to the properties to help you understand what values to set, rather than thinking of setting text node characters directly.
|
|
12
|
+
|
|
13
|
+
When you need to set a nested instance swap (e.g. an icon property), you need the component key of the swap target, not just its name. Import the target component and pass its node ID.
|
|
14
|
+
|
|
15
|
+
Be aware that instances inside other instances are nested and changes made to a nested instance may be treated as overrides. If the intent is to change the default appearance, you need to modify the main component, not the instance.
|
|
16
|
+
|
|
17
|
+
When selecting which variant to use, read the `componentProperties` on the instance to see the current state, and `componentPropertyDefinitions` on the main component to see all available options.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Components
|
|
2
|
+
|
|
3
|
+
Components overlap a lot with the idea of components in a codebase, but with some gaps and other Figma-specific use cases. Components in Figma can be reusable entities that do not have a comparable library pattern, or they can be published and distributed in a library that is aligned to a code forms.
|
|
4
|
+
|
|
5
|
+
Properties can vary from code in different ways, but alignment to code can still happen without a direct relationship. For example, an interactive pattern in code (like a button) can have many states. A lot of these states (active, focused etc) would be expressed in Figma as variants, which is a concept more closely aligned to properties in a code library. In the case of web this is confusing since hover is not a prop, it is a pseudo selector. At the same time, a color variant might be perfectly aligned between design and code (a property in both places). These discrepancies are accounted for in translation with Figma's Code Connect (deterministic context mapping), but in the case of these tools, must be understood to be properly used.
|
|
6
|
+
|
|
7
|
+
Figma has four property types, which can be inspected in the component definition's `componentPropertyDefinitions`. To fully understand the component, its descendants must be traversed. Property types include:
|
|
8
|
+
|
|
9
|
+
- Variant
|
|
10
|
+
- This is reflected as permutations of the component in a Component Set on the canvas. Each variant is explicitly visualized, including an redundant permutations ("Small + Primary + Disabled" may look the same as "Small Secondary Sisabled"). These permutations create different variants implicitly in Figma and it is handled through layer naming (`Variant=Primary,Size=Small,State=Disabled`).
|
|
11
|
+
- Text/String
|
|
12
|
+
- Text properties are stored on the component parent, but can be mapped to Text node descendants.
|
|
13
|
+
- `node.componentPropertyReferences.characters` on a descendant text node are how you determine where the text property is referenced (can be multiple, though unlikely).
|
|
14
|
+
- Boolean
|
|
15
|
+
- Boolean properties are stored on the component parent, but can be mapped to any node descendant that can have its visibility toggled.
|
|
16
|
+
- `node.componentPropertyReferences.visible` on a descendant node are how you determine where the boolean property is referenced.
|
|
17
|
+
- Instance Swap
|
|
18
|
+
- Instance swap properties are stored on the component parent, but can be mapped to Instance node descendants.
|
|
19
|
+
- `node.componentPropertyReferences.mainComponent` on a descendant instance node are how you determine where the instance property is referenced. A classic example of this is an icon property.
|
|
20
|
+
|
|
21
|
+
## Descriptions
|
|
22
|
+
|
|
23
|
+
Components, component sets, and instances all inherit `PublishableMixin`, which includes a writable `description` string. Setting a description is important for any component intended to be used by others — it appears in Figma's dev mode and component panel, and is surfaced in MCP context when reading component metadata.
|
|
24
|
+
|
|
25
|
+
Descriptions should explain the component's intent and any non-obvious usage constraints. They are not a substitute for Code Connect annotations, but they are always visible without any tooling setup.
|
|
26
|
+
|
|
27
|
+
```js
|
|
28
|
+
component.description =
|
|
29
|
+
"Primary action button. Use for the single most important action on a page.";
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Variant components (children of a component set) also have a `description` field, but in practice the component set description is what users see. Set it on the component set, not on individual variant nodes.
|
|
33
|
+
|
|
34
|
+
To read descriptions when auditing:
|
|
35
|
+
|
|
36
|
+
```js
|
|
37
|
+
// Get all component sets and their descriptions
|
|
38
|
+
figma.root
|
|
39
|
+
.findAllWithCriteria({ types: ["COMPONENT_SET"] })
|
|
40
|
+
.map((n) => ({ name: n.name, description: n.description }));
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Usage guidelines
|
|
44
|
+
|
|
45
|
+
- [Creating components](wwds-components--creating.md): What you must consider when creating new components.
|
|
46
|
+
- [Using components](wwds-components--using.md): What you must consider when trying to use the right components.
|
|
47
|
+
|
|
48
|
+
## Code patterns
|
|
49
|
+
|
|
50
|
+
For runnable code examples (creating, importing, discovering, inspecting components), see [component-patterns.md](../component-patterns.md).
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Working with design systems: Effect Styles
|
|
2
|
+
|
|
3
|
+
Effect styles in Figma are named, reusable definitions of one or more visual effects — drop shadows, inner shadows, and blurs. They are the closest equivalent to a shadow or elevation token in a design system.
|
|
4
|
+
|
|
5
|
+
Effect styles are distinct from variables. There is no single variable type that represents a shadow. However, individual numeric and color properties within an effect _can_ be bound to variables, allowing shadow values to participate in a token system.
|
|
6
|
+
|
|
7
|
+
## Model
|
|
8
|
+
|
|
9
|
+
An `EffectStyle` has one core writable property beyond the base style fields:
|
|
10
|
+
|
|
11
|
+
| Property | Type | Notes |
|
|
12
|
+
| ------------- | ----------------------- | ----------------------------------------------------- |
|
|
13
|
+
| `name` | `string` | Slash-delimited for grouping (e.g. `"Elevation/200"`) |
|
|
14
|
+
| `effects` | `ReadonlyArray<Effect>` | **Read-only array** — clone, modify, reassign |
|
|
15
|
+
| `description` | `string` | Inherited from `BaseStyleMixin` |
|
|
16
|
+
|
|
17
|
+
### Effect types
|
|
18
|
+
|
|
19
|
+
An `Effect` is a discriminated union. The most common types:
|
|
20
|
+
|
|
21
|
+
| `type` | Key properties |
|
|
22
|
+
| ----------------- | ---------------------------------------------------------------------------------------------------- |
|
|
23
|
+
| `DROP_SHADOW` | `color: RGBA`, `offset: Vector`, `radius: number`, `spread: number`, `visible: boolean`, `blendMode` |
|
|
24
|
+
| `INNER_SHADOW` | Same as `DROP_SHADOW` |
|
|
25
|
+
| `LAYER_BLUR` | `radius: number`, `visible: boolean` |
|
|
26
|
+
| `BACKGROUND_BLUR` | `radius: number`, `visible: boolean` |
|
|
27
|
+
|
|
28
|
+
All colors are in 0–1 range (`RGBA`), not 0–255.
|
|
29
|
+
|
|
30
|
+
### Variable bindings on effects
|
|
31
|
+
|
|
32
|
+
Effect properties that can be bound to variables (via `setBoundVariableForEffect(effect, field, variable)` on a node, or inline when constructing):
|
|
33
|
+
|
|
34
|
+
`color`, `radius`, `spread`, `offsetX`, `offsetY`
|
|
35
|
+
|
|
36
|
+
Note: `setBoundVariableForEffect` returns a **new** effect object — you must capture it and reassign the `effects` array.
|
|
37
|
+
|
|
38
|
+
### Applying an effect style to a node
|
|
39
|
+
|
|
40
|
+
Assign the style's `id` to the node's `effectStyleId`. The node's `effects` property will then reflect the style's values.
|
|
41
|
+
|
|
42
|
+
## Common gotchas
|
|
43
|
+
|
|
44
|
+
- **`effects` is read-only**: You cannot mutate the array in place. Clone it, modify the clone, then reassign: `style.effects = [...style.effects, newEffect]`.
|
|
45
|
+
- **Effects stack in order**: The order of effects in the array matters visually. Drop shadows render bottom-to-top.
|
|
46
|
+
- **Colors are RGBA 0–1**: `{ r: 0, g: 0, b: 0, a: 0.15 }` — not hex, not 0–255.
|
|
47
|
+
- **`getLocalEffectStyles()` is deprecated**: Always use `getLocalEffectStylesAsync()`.
|
|
48
|
+
- **Styles are not automatically applied**: Creating an `EffectStyle` has no effect on any node until you assign its ID to a node.
|
|
49
|
+
|
|
50
|
+
## Code patterns
|
|
51
|
+
|
|
52
|
+
For runnable code examples (listing, creating, applying effect styles), see [effect-style-patterns.md](../effect-style-patterns.md).
|