figma-local-dev-loop
Set up a local development workflow for Figma plugin and REST API projects. Use when building Figma plugins, creating design-to-code pipelines, or developing against the Figma API with hot reload. Trigger with phrases like "figma dev setup", "figma plugin development", "figma local development", "develop figma plugin".
- License 许可
- MIT
- 最近更新
- 2026-07-13
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- figma-local-dev-loop
- tags
- [ "saas", "figma" ]
- author
- Jeremy Longshore <jeremy@intentsolutions.io>
- license
- MIT
- version
- 1.0.0
- description
- Set up a local development workflow for Figma plugin and REST API projects. Use when building Figma plugins, creating design-to-code pipelines, or developing against the Figma API with hot reload. Trigger with phrases like "figma dev setup", "figma plugin development", "figma local development", "develop figma plugin".
- allowed-tools
- Read, Write, Edit, Bash(npm:*), Bash(npx:*), Bash(pnpm:*), Grep
- compatible-with
- claude-code
03 SKILL.md 正文
Figma Local Dev Loop
Overview
Set up fast local development for two workflows: building Figma plugins that run inside the Figma editor, and building external apps that consume the Figma REST API.
Prerequisites
- Node.js 18+ with npm/pnpm
FIGMA_PATconfigured (seefigma-install-auth)- Figma desktop app (for plugin development)
Instructions
Step 1: REST API Project Structure
figma-integration/
├── src/
│ ├── figma-client.ts # Shared fetch wrapper
│ ├── extract-tokens.ts # Design token extraction
│ └── export-assets.ts # Asset export pipeline
├── tests/
│ ├── figma-client.test.ts
│ └── fixtures/ # Saved API responses for offline testing
│ └── sample-file.json
├── .env.local # FIGMA_PAT, FIGMA_FILE_KEY (git-ignored)
├── .env.example # Template for team
├── tsconfig.json
└── package.json
Step 2: Figma Plugin Project Structure
my-figma-plugin/
├── manifest.json # Plugin manifest (required by Figma)
├── code.ts # Plugin backend (runs in sandbox)
├── ui.html # Plugin UI (runs in iframe)
├── package.json
└── tsconfig.json
manifest.json (required):
{
"name": "My Plugin",
"id": "1234567890",
"api": "1.0.0",
"main": "dist/code.js",
"ui": "dist/ui.html",
"editorType": ["figma"],
"permissions": ["currentuser"]
}
Step 3: Plugin Development with Watch Mode
{
"scripts": {
"build": "esbuild code.ts --bundle --outfile=dist/code.js --target=es2020",
"watch": "esbuild code.ts --bundle --outfile=dist/code.js --target=es2020 --watch",
"dev": "concurrently \"npm run watch\" \"npm run watch:ui\"",
"watch:ui": "esbuild ui.tsx --bundle --outfile=dist/ui.html --loader:.html=copy --watch"
},
"devDependencies": {
"@figma/plugin-typings": "^1.0.0",
"esbuild": "^0.20.0",
"typescript": "^5.0.0"
}
}
Load the plugin in Figma:
- Figma desktop > Plugins > Development > Import plugin from manifest
- Select your
manifest.json - Run with
npm run watch-- changes auto-reload
Step 4: REST API Dev Loop with Testing
{
"scripts": {
"dev": "tsx watch src/extract-tokens.ts",
"test": "vitest",
"test:watch": "vitest --watch"
}
}
// tests/figma-client.test.ts
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { readFileSync } from 'fs';
// Load a saved API response for offline testing
const sampleFile = JSON.parse(
readFileSync('tests/fixtures/sample-file.json', 'utf-8')
);
describe('Figma token extraction', () => {
beforeEach(() => {
// Mock fetch to return saved fixture
vi.spyOn(global, 'fetch').mockResolvedValue(
new Response(JSON.stringify(sampleFile), { status: 200 })
);
});
it('should extract color styles from file', async () => {
const res = await fetch('https://api.figma.com/v1/files/test-key');
const file = await res.json();
const styles = Object.values(file.styles);
expect(styles.length).toBeGreaterThan(0);
});
});
Step 5: Save API Fixtures for Offline Dev
# Snapshot a Figma file for offline testing
curl -s -H "X-Figma-Token: ${FIGMA_PAT}" \
"https://api.figma.com/v1/files/${FIGMA_FILE_KEY}" \
> tests/fixtures/sample-file.json
# Snapshot specific nodes
curl -s -H "X-Figma-Token: ${FIGMA_PAT}" \
"https://api.figma.com/v1/files/${FIGMA_FILE_KEY}/nodes?ids=0:1,0:2" \
> tests/fixtures/sample-nodes.json
Output
- Working dev environment with hot reload
- Test suite with mocked Figma API responses
- Saved fixtures for offline development
- Plugin manifest configured for Figma desktop loading
Error Handling
| Error | Cause | Solution |
|---|---|---|
| Plugin not appearing in Figma | Wrong manifest path | Re-import from correct manifest.json |
figma global undefined |
Running outside Figma sandbox | Use @figma/plugin-typings for types only |
| Fixture stale | File changed since snapshot | Re-run fixture download script |
| esbuild watch crash | Syntax error in TS | Fix error; watch auto-restarts |
Examples
Quick Plugin Skeleton
// code.ts -- minimal Figma plugin
figma.showUI(__html__, { width: 300, height: 200 });
figma.ui.onmessage = (msg: { type: string; count: number }) => {
if (msg.type === 'create-rectangles') {
for (let i = 0; i < msg.count; i++) {
const rect = figma.createRectangle();
rect.x = i * 150;
rect.fills = [{ type: 'SOLID', color: { r: 1, g: 0.5, b: 0 } }];
figma.currentPage.appendChild(rect);
}
figma.closePlugin();
}
};
Resources
Next Steps
See figma-sdk-patterns for production-ready code patterns.
04 同仓库更多 Skills
zustand-store-creator
Create zustand store creator operations. Auto-activating skill for Frontend Development. Triggers on: zustand store creator, zustand store creator Part of the Frontend Development skill category. Use when working with zustand store creator functionality. Trigger with phrases like "zustand store creator", "zustand creator", "zustand".
zero-trust-config-helper
Configure with zero trust config helper operations. Auto-activating skill for Security Advanced. Triggers on: zero trust config helper, zero trust config helper Part of the Security Advanced skill category. Use when configuring systems or services. Trigger with phrases like "zero trust config helper", "zero helper", "zero".
zapier-integration-helper
Assist with zapier integration helper operations. Auto-activating skill for Business Automation. Triggers on: zapier integration helper, zapier integration helper Part of the Business Automation skill category. Use when working with APIs or building integrations. Trigger with phrases like "zapier integration helper", "zapier helper", "zapier".
yaml-config-validator
Validate yaml config validator operations. Auto-activating skill for DevOps Basics. Triggers on: yaml config validator, yaml config validator Part of the DevOps Basics skill category. Use when configuring systems or services. Trigger with phrases like "yaml config validator", "yaml validator", "yaml".
xvary-stock-research
Thesis-driven equity analysis from public SEC EDGAR and market data; /analyze, /score, /compare workflows with bundled Python tools (Claude Code, Cursor, Codex).
xss-vulnerability-scanner
Scan xss vulnerability scanner operations. Auto-activating skill for Security Fundamentals. Triggers on: xss vulnerability scanner, xss vulnerability scanner Part of the Security Fundamentals skill category. Use when working with xss vulnerability scanner functionality. Trigger with phrases like "xss vulnerability scanner", "xss scanner", "xss".