# Common Patterns > Part of the [use_figma skill](../SKILL.md). Working code examples for frequently used operations. ## Contents - Basic Script Structure - Create a Styled Shape - Create a Text Node - Create Frame with Auto-Layout - Create Variable Collections and Bindings - Create Components and Import by Key - Component Sets with Variable Modes - Multi-Step Large ComponentSet Pattern - Read Existing Nodes and Return Data ## Basic Script Structure ```js const createdNodeIds = [] const mutatedNodeIds = [] // Your code here — track every node you create or mutate // createdNodeIds.push(newNode.id) // mutatedNodeIds.push(existingNode.id) return { success: true, createdNodeIds, mutatedNodeIds, // Plus any other useful data for subsequent calls count: createdNodeIds.length } ``` ## Create a Styled Shape ```js // Find clear space to the right of existing content const page = figma.currentPage let maxX = 0 for (const child of page.children) { maxX = Math.max(maxX, child.x + child.width) } const rect = figma.createRectangle() rect.name = "Blue Box" rect.resize(200, 100) rect.fills = [{ type: 'SOLID', color: { r: 0.047, g: 0.549, b: 0.914 } }] rect.cornerRadius = 8 rect.x = maxX + 100 // offset from existing content rect.y = 0 figma.currentPage.appendChild(rect) return { nodeId: rect.id } ``` ## Create a Text Node Canonical text-edit recipe: load font → `await` → mutate → return affected IDs. Inter is preloaded in most environments; for any other family/style you would have hit `Cannot write to node with unloaded font "