BumpyClock/agent-templates / skills_archive/figma/figma-generate-library
figma-generate-library
VerifiedBuild/update Figma design systems: variables, tokens, components, theming.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 17.6 KB |
| references/code-connect-setup.md | markdown | 11.8 KB |
| references/component-creation.md | markdown | 38.4 KB |
| references/discovery-phase.md | markdown | 18.7 KB |
| references/documentation-creation.md | markdown | 27.4 KB |
| references/error-recovery.md | markdown | 21.3 KB |
| references/naming-conventions.md | markdown | 18.6 KB |
| references/token-creation.md | markdown | 34.3 KB |
| scripts/bindVariablesToComponent.js | script | 3.6 KB |
| scripts/cleanupOrphans.js | script | 3.6 KB |
| scripts/createComponentWithVariants.js | script | 4.8 KB |
| scripts/createDocumentationPage.js | script | 5.1 KB |
| scripts/createSemanticTokens.js | script | 3.8 KB |
| scripts/createVariableCollection.js | script | 1.7 KB |
| scripts/inspectFileStructure.js | script | 3.6 KB |
| scripts/rehydrateState.js | script | 2.9 KB |
| scripts/validateCreation.js | script | 2.7 KB |
scripts/createVariableCollection.js
View on GitHub/**
* createVariableCollection
*
* Creates a new Figma variable collection with the specified name and modes.
* If `modeNames` has more than one entry, the first mode is renamed from
* Figma's default "Mode 1" to the first name, and additional modes are added.
*
* Every created collection is tagged with `dsb_key` plugin data so it can be
* found and cleaned up idempotently by `cleanupOrphans`.
*
* @param {string} name - The display name of the collection (e.g. "Color", "Spacing").
* @param {string[]} modeNames - Ordered list of mode names (e.g. ["Light", "Dark"] or ["Value"]).
* @param {string} [runId] - Optional dsb_run_id to tag for cleanup.
* @returns {Promise<{
* collection: VariableCollection,
* modeIds: Record<string, string>
* }>}
* `modeIds` maps each mode name to its modeId string.
*/
async function createVariableCollection(name, modeNames, runId) {
if (!modeNames || modeNames.length === 0) {
throw new Error('createVariableCollection: modeNames must have at least one entry.')
}
// Create the collection — Figma always creates it with one mode named "Mode 1".
const collection = figma.variables.createVariableCollection(name)
// Tag for idempotent cleanup
collection.setPluginData('dsb_key', `collection/${name}`)
if (runId) {
collection.setPluginData('dsb_run_id', runId)
}
// modeIds accumulator
const modeIds = {}
// Rename the default first mode
const defaultMode = collection.modes[0]
collection.renameMode(defaultMode.modeId, modeNames[0])
modeIds[modeNames[0]] = defaultMode.modeId
// Add additional modes
for (let i = 1; i < modeNames.length; i++) {
const newModeId = collection.addMode(modeNames[i])
modeIds[modeNames[i]] = newModeId
}
return { collection, modeIds }
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation). | Stars: 319k | Updated | Claude CodeCodex | Verified | Install |
| brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK). | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |