Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Reference architecture for production Figma API integrations. Use when designing a new Figma integration, planning project structure, or establishing patterns for design-to-code pipelines. Trigger with phrases like "figma architecture", "figma project structure", "figma integration design", "figma best practices layout".
.claude/skills/jeremylongshore-figma-reference-architecture/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-03 | ✗→✓ | ▲ Improved | 10% | 0% |
| case-07 | ✗→✓ | ▲ Improved | 101% | 0% |
| case-08 | ✗→✓ | ▲ Improved | 114% | 0% |
| case-09 | ✗→✓ | ▲ Improved | 128% | 0% |
| case-11 | ✗→✓ | ▲ Improved | 221% | 0% |
Production-ready architecture for Figma REST API integrations. Covers the three most common use cases: design token pipelines, asset export systems, and webhook-driven automation.
figma-integration/
├── src/
│ ├── figma/
│ │ ├── client.ts # Typed REST API wrapper
│ │ ├── types.ts # Figma API response types
│ │ ├── errors.ts # FigmaApiError, FigmaRateLimitError
│ │ ├── cache.ts # LRU cache for API responses
│ │ └── walker.ts # Node tree traversal utilities
│ ├── services/
│ │ ├── token-extractor.ts # Design token extraction
│ │ ├── asset-exporter.ts # Image/icon export pipeline
│ │ ├── comment-syncer.ts # Comment sync to Slack/Jira
│ │ └── variable-syncer.ts # Variables API sync (Enterprise)
│ ├── webhooks/
│ │ ├── handler.ts # Webhook event router
│ │ ├── verify.ts # Passcode verification
│ │ └── processors/
│ │ ├── file-update.ts # FILE_UPDATE handler
│ │ ├── comment.ts # FILE_COMMENT handler
│ │ └── library.ts # LIBRARY_PUBLISH handler
│ ├── api/
│ │ ├── health.ts # Health check endpoint
│ │ ├── tokens.ts # Token API endpoint
│ │ └── assets.ts # Asset download endpoint
│ └── index.ts
├── scripts/
│ ├── extract-tokens.mjs # CLI: extract tokens from Figma
│ ├── export-icons.mjs # CLI: export icons from Figma
│ └── setup-webhooks.mjs # CLI: create/manage webhooks
├── output/
│ ├── tokens.css # Generated CSS custom properties
│ ├── tokens.json # Generated JSON tokens
│ └── icons/ # Exported SVG/PNG icons
├── tests/
│ ├── fixtures/ # Saved Figma API responses
│ └── *.test.ts
├── .env.example
└── package.json┌────────────────────────────────────────────────┐
│ Figma Cloud │
│ ┌──────────┐ ┌──────────┐ ┌──────────────┐ │
│ │ Files API │ │Images API│ │ Webhooks V2 │ │
│ │ /v1/files │ │/v1/images│ │ /v2/webhooks │ │
│ └─────┬─────┘ └────┬─────┘ └──────┬───────┘ │
└────────┼──────────────┼───────────────┼─────────┘
│ │ │
┌────▼────┐ ┌────▼────┐ ┌─────▼────┐
│ Token │ │ Asset │ │ Webhook │
│Extractor│ │Exporter │ │ Handler │
└────┬────┘ └────┬────┘ └─────┬────┘
│ │ │
┌────▼────┐ ┌────▼────┐ ┌─────▼────┐
│ Cache │ │ Cache │ │ Event │
│ (LRU) │ │ (URLs) │ │ Queue │
└────┬────┘ └────┬────┘ └─────┬────┘
│ │ │
┌────▼──────────────▼───────────────▼────┐
│ Output Layer │
│ tokens.css │ icons/ │ Slack/Jira │
└─────────────────────────────────────────┘Figma Client (see figma-sdk-patterns):
typescript// Singleton with retry, rate limit handling, and caching const client = new FigmaClient(process.env.FIGMA_PAT!); // All API calls go through the client const file = await client.getFile(fileKey); // GET /v1/files/:key const nodes = await client.getFileNodes(fileKey, ids); // GET /v1/files/:key/nodes const images = await client.getImages(fileKey, ids); // GET /v1/images/:key const comments = await client.getComments(fileKey); // GET /v1/files/:key/comments const vars = await client.getLocalVariables(fileKey); // GET /v1/files/:key/variables/local
Token Extraction Pipeline (see figma-core-workflow-a):
typescript// file → styles → nodes → CSS/JSON tokens export async function extractTokens(fileKey: string): Promise<DesignToken[]> { const file = await client.getFile(fileKey); const styleNodes = await client.getFileNodes(fileKey, Object.keys(file.styles)); return parseTokensFromNodes(file.styles, styleNodes); }
Asset Export Pipeline (see figma-core-workflow-b):
typescript// file → find components → render images → download export async function exportIcons(fileKey: string, frameId: string) { const frame = await client.getFileNodes(fileKey, [frameId]); const componentIds = findComponents(frame).map(n => n.id); const imageUrls = await client.getImages(fileKey, componentIds, { format: 'svg' }); return downloadAll(imageUrls); }
Webhook Handler (see figma-webhooks-events):
typescript// Verify passcode → route event → process async export function webhookRouter(event: FigmaWebhookEvent) { switch (event.event_type) { case 'FILE_UPDATE': return handleFileUpdate(event); case 'LIBRARY_PUBLISH': return handleLibraryPublish(event); case 'FILE_COMMENT': return handleComment(event); } }
typescript// src/config.ts export const config = { figma: { token: process.env.FIGMA_PAT!, fileKey: process.env.FIGMA_FILE_KEY!, webhookPasscode: process.env.FIGMA_WEBHOOK_PASSCODE, }, cache: { fileTTL: 5 * 60 * 1000, // 5 minutes for file metadata imageTTL: 24 * 60 * 60 * 1000, // 24 hours for image URLs maxEntries: 500, }, api: { maxConcurrent: 3, retryAttempts: 3, requestTimeout: 30_000, }, };
| Layer | Error | Recovery | |-------|-------|----------| | Client | 429 Rate Limited | Retry with Retry-After header | | Client | 403 Forbidden | Alert on token expiry; fail gracefully | | Cache | Cache miss storm | Stale-while-revalidate pattern | | Webhook | Duplicate events | Idempotency via event timestamp | | Export | Image render null | Skip node, log warning |
Scaffold the Step 1 project structure and trace one request through the layers (Step 2 data flow):
textsrc/ ├── client/figma-client.ts # typed REST client (retry + rate-limit aware) ├── services/token-sync.ts # orchestration: fetch → transform → emit ├── webhooks/receiver.ts # V2 webhook endpoint (passcode-verified) ├── cache/file-cache.ts # version-keyed response cache └── config/index.ts # env-validated configuration
A LIBRARY_PUBLISH webhook arriving becomes, in order:
textreceiver.ts verify passcode → enqueue {file_key} token-sync.ts fetch /v1/files/{key}/styles → resolve nodes → transform file-cache.ts invalidate stale entry (keyed by file version) emit write tokens.json → open PR via CI
Component contracts and the config schema: references/key-components.md, references/configuration.md.
For multi-environment setup, see figma-multi-env-setup.
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→fail | 31,032 | 32,179 | +4% | 1 | 1 | 0% | 5,370 | 7,984 | +49% | 0 | 0 | — |
case-02 | pass→pass | 26,286 | 30,271 | +15% | 1 | 1 | 0% | 4,626 | 7,142 | +54% | 0 | 0 | — |
case-03 | fail→pass | 44,536 | 38,911 | -13% | 1 | 1 | 0% | 8,252 | 9,041 | +10% | 0 | 0 | — |
case-04 | fail→fail | 23,453 | 18,347 | -22% | 1 | 1 | 0% | 2,985 | 5,319 | +78% | 0 | 0 | — |
case-05 | pass→pass | 21,673 | 20,012 | -8% | 1 | 1 | 0% | 2,679 | 5,607 | +109% | 0 | 0 | — |
case-06 | pass→pass | 17,586 | 20,487 | +16% | 1 | 1 | 0% | 3,054 | 5,359 | +75% | 0 | 0 | — |
case-07 | fail→pass | 19,398 | 16,385 | -16% | 1 | 1 | 0% | 2,624 | 5,285 | +101% | 0 | 0 | — |
case-08 | fail→pass | 16,188 | 25,836 | +60% | 1 | 1 | 0% | 2,640 | 5,645 | +114% | 0 | 0 | — |
case-09 | fail→pass | 19,485 | 21,959 | +13% | 1 | 1 | 0% | 2,279 | 5,204 | +128% | 0 | 0 | — |
case-10 | pass→pass | 17,606 | 6,793 | -61% | 1 | 1 | 0% | 2,275 | 3,442 | +51% | 0 | 0 | — |
case-11 | fail→pass | 30,267 | 16,560 | -45% | 1 | 1 | 0% | 1,307 | 4,201 | +221% | 0 | 0 | — |
case-12 | pass→pass | 8,622 | 7,135 | -17% | 1 | 1 | 0% | 1,730 | 3,454 | +100% | 0 | 0 | — |
case-13 | fail→pass | 16,796 | 16,841 | +0% | 1 | 1 | 0% | 2,132 | 4,139 | +94% | 0 | 0 | — |
case-14 | fail→pass | 13,552 | 5,851 | -57% | 1 | 1 | 0% | 2,382 | 3,304 | +39% | 0 | 0 | — |
case-15 | pass→pass | 10,542 | 9,335 | -11% | 1 | 1 | 0% | 1,892 | 3,896 | +106% | 0 | 0 | — |
case-16 | fail→fail | 18,516 | 15,081 | -19% | 1 | 1 | 0% | 2,396 | 3,992 | +67% | 0 | 0 | — |
case-17 | fail→pass | 16,774 | 14,880 | -11% | 1 | 1 | 0% | 2,080 | 3,809 | +83% | 0 | 0 | — |
case-18 | fail→fail | 18,192 | 13,798 | -24% | 1 | 1 | 0% | 2,452 | 3,812 | +55% | 0 | 0 | — |
case-19 | pass→pass | 16,437 | 7,844 | -52% | 1 | 1 | 0% | 2,291 | 3,691 | +61% | 0 | 0 | — |
case-20 | pass→pass | 20,970 | 26,662 | +27% | 1 | 1 | 0% | 3,279 | 6,463 | +97% | 0 | 0 | — |
case-21 | pass→pass | 17,040 | 22,857 | +34% | 1 | 1 | 0% | 2,377 | 5,968 | +151% | 0 | 0 | — |
case-22 | pass→pass | 18,863 | 22,624 | +20% | 1 | 1 | 0% | 2,959 | 6,336 | +114% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted, and 21 counted toward the lift figure. The other 1 produced results that are not comparable between the two arms, so they are excluded from the headline rather than averaged into it. The headline lift of +36 percentage points is the difference between those two pass rates over the 21 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.