Production-ready patterns for the Figma REST API and Plugin API.

MITAuto-check passedBackend & APIs

Install Figma SDK Patterns

skills CLI
$ npx skills add jeremylongshore/tons-of-skills-marketplace --skill figma-sdk-patterns -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install jeremylongshore/tons-of-skills-marketplace figma-sdk-patterns --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/jeremylongshore/tons-of-skills-marketplace.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/.curated/figma-sdk-patterns .claude/skills/figma-sdk-patterns && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
figma-sdk-patterns
GitHub stars
2.8k
Token cost
~2.2k tokens
SKILL.md length
219 words
Files
7 (incl. references)
Skills in repo
3,342
Repo updated
First seen
Licence
MIT

At a glance

Production-ready patterns for the Figma REST API and Plugin API.

  • Works in 5 steps: Typed REST API Client → Custom Error Classes → Type Definitions → …
  • Building reusable Figma client wrappers
  • SKILL.md covers Overview, Prerequisites, Instructions and Output, plus 4 more sections
  • Reaches api.figma.com; needs FIGMA_FILE_KEY

What it does

Figma SDK Patterns is an agent skill from jeremylongshore/tons-of-skills-marketplace. Production-ready patterns for the Figma REST API and Plugin API. Use when building reusable Figma client wrappers, extracting design tokens, traversing node trees, or creating typed API helpers. Trigger with phrases like "figma patterns", "figma best practices", "figma client wrapper", "figma typed API".

Its SKILL.md is about 2.2k tokens, which your agent loads only when the skill is triggered. The skill folder holds 7 other files, including reference files (for example `references/custom-error-classes.md`, `references/errors.md` and `references/node-tree-walker.md`). Compatibility notes: Designed for Claude Code

It sits in Backend & APIs, covering REST APIs and Design tokens. It works with Figma. The repository describes itself as: Model-agnostic agent-skills platform with a harness-free canonical layer, verified adapters, and the ccpi package manager. Explore at tonsofskills.com. The licence is MIT.

When your agent uses it

  • Building reusable Figma client wrappers
  • Extracting design tokens
  • Traversing node trees
  • Creating typed API helpers

Example prompts

  • “figma patterns”
  • “figma best practices”
  • “figma client wrapper”
  • “/figma-sdk-patterns”

Requirements

  • Node.js
  • A credential in FIGMA_FILE_KEY
  • Compatibility (from SKILL.md): Designed for Claude Code
  • Pre-approved tools (allowed-tools): Read, Write, Edit

Workflow steps

5 steps, taken from the step headings in SKILL.md.

  1. Typed REST API Client
  2. Custom Error Classes
  3. Type Definitions
  4. Node Tree Walker
  5. Singleton with Retry

What it can do on your machine

Read from SKILL.md and the folder at commit cfae287. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • Read
    • Write
    • Edit

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are typescript).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Hosts in commands or code, which the agent is likely to contact:

    • api.figma.com

    Also links to:

    • developers.figma.com
    • github.com
    • npmjs.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names these keys or tokens, usually read from environment variables:

    • FIGMA_FILE_KEY

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

  • Compatibility

    Designed for Claude Code

    From compatibility in the SKILL.md frontmatter.

Context cost

Figma SDK Patterns loads about 2.2k tokens when it runs, and up to ~4.2k if it reads all its reference files. Until then it costs about 81 tokens; SKILL.md has 219 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~81
When it runs · the whole SKILL.md, loaded when a task matches
~2.2k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~4.2k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from jeremylongshore/tons-of-skills-marketplace at commit cfae287, republished under its MIT licence (© jeremylongshore). 219 words, ~2,217 tokens.

Download SKILL.mdSave it as .claude/skills/figma-sdk-patterns/SKILL.md (or your agent's skills folder). This skill also uses 6 other files; get the full folder from GitHub.
name
figma-sdk-patterns
description
Production-ready patterns for the Figma REST API and Plugin API. Use when building reusable Figma client wrappers, extracting design tokens, traversing node trees, or creating typed API helpers. Trigger with phrases like "figma patterns", "figma best practices", "figma client wrapper", "figma typed API".
allowed-tools
Read, Write, Edit
compatibility
Designed for Claude Code
version
1.6.0
license
MIT
author
Jeremy Longshore <jeremy@intentsolutions.io>
tags
saas, figma

Figma SDK Patterns

Overview

Production patterns for the Figma REST API (external tools) and Plugin API (in-editor plugins). Figma has no official Node.js SDK -- you call https://api.figma.com directly with fetch. These patterns give you type safety, error handling, and reusable abstractions.

Prerequisites

  • FIGMA_PAT environment variable set
  • TypeScript 5+ project
  • Understanding of Figma node types

Instructions

Step 1: Typed REST API Client
typescript
// src/figma-client.ts
export class FigmaClient {
  private baseUrl = 'https://api.figma.com';

  constructor(private token: string) {
    if (!token) throw new Error('Figma token is required');
  }

  private async request<T>(path: string, init?: RequestInit): Promise<T> {
    const res = await fetch(`${this.baseUrl}${path}`, {
      ...init,
      headers: {
        'X-Figma-Token': this.token,
        'Content-Type': 'application/json',
        ...init?.headers,
      },
    });

    if (res.status === 429) {
      const retryAfter = parseInt(res.headers.get('Retry-After') || '60');
      throw new FigmaRateLimitError(retryAfter);
    }
    if (res.status === 403) throw new FigmaAuthError('Invalid or expired token');
    if (res.status === 404) throw new FigmaNotFoundError(path);
    if (!res.ok) throw new FigmaApiError(res.status, await res.text());

    return res.json();
  }

  async getFile(fileKey: string) {
    return this.request<FigmaFileResponse>(`/v1/files/${fileKey}`);
  }

  async getFileNodes(fileKey: string, nodeIds: string[]) {
    const ids = encodeURIComponent(nodeIds.join(','));
    return this.request<FigmaNodesResponse>(`/v1/files/${fileKey}/nodes?ids=${ids}`);
  }

  async getImages(fileKey: string, nodeIds: string[], opts?: ImageOptions) {
    const params = new URLSearchParams({
      ids: nodeIds.join(','),
      format: opts?.format ?? 'png',
      scale: String(opts?.scale ?? 2),
    });
    return this.request<FigmaImagesResponse>(`/v1/images/${fileKey}?${params}`);
  }

  async getComments(fileKey: string) {
    return this.request<FigmaCommentsResponse>(`/v1/files/${fileKey}/comments`);
  }

  async postComment(fileKey: string, message: string, nodeId?: string) {
    return this.request(`/v1/files/${fileKey}/comments`, {
      method: 'POST',
      body: JSON.stringify({
        message,
        ...(nodeId && { client_meta: { node_id: nodeId } }),
      }),
    });
  }

  async getLocalVariables(fileKey: string) {
    return this.request<FigmaVariablesResponse>(
      `/v1/files/${fileKey}/variables/local`
    );
  }
}
Step 2: Custom Error Classes
typescript
// src/figma-errors.ts
export class FigmaApiError extends Error {
  constructor(public status: number, public body: string) {
    super(`Figma API error ${status}: ${body}`);
    this.name = 'FigmaApiError';
  }
}

export class FigmaRateLimitError extends FigmaApiError {
  constructor(public retryAfterSeconds: number) {
    super(429, `Rate limited. Retry after ${retryAfterSeconds}s`);
    this.name = 'FigmaRateLimitError';
  }
}

export class FigmaAuthError extends FigmaApiError {
  constructor(message: string) {
    super(403, message);
    this.name = 'FigmaAuthError';
  }
}

export class FigmaNotFoundError extends FigmaApiError {
  constructor(path: string) {
    super(404, `Resource not found: ${path}`);
    this.name = 'FigmaNotFoundError';
  }
}
Step 3: Type Definitions
typescript
// src/figma-types.ts
export interface FigmaNode {
  id: string;
  name: string;
  type: string;
  children?: FigmaNode[];
  fills?: Paint[];
  strokes?: Paint[];
  absoluteBoundingBox?: { x: number; y: number; width: number; height: number };
  characters?: string;         // TEXT nodes
  style?: TypeStyle;           // TEXT nodes
  componentId?: string;        // INSTANCE nodes
  backgroundColor?: Color;     // CANVAS nodes
}

export interface FigmaFileResponse {
  name: string;
  lastModified: string;
  version: string;
  thumbnailUrl: string;
  document: FigmaNode;
  components: Record<string, ComponentMeta>;
  styles: Record<string, StyleMeta>;
}

export interface FigmaNodesResponse {
  nodes: Record<string, { document: FigmaNode; components: Record<string, ComponentMeta> }>;
}

export interface FigmaImagesResponse {
  images: Record<string, string | null>;  // nodeId -> URL (null = render failed)
}

export interface ImageOptions {
  format?: 'png' | 'svg' | 'jpg' | 'pdf';
  scale?: number;  // 0.01 to 4. SVG always exports at 1x.
}

interface Paint { type: string; color?: Color; opacity?: number }
interface Color { r: number; g: number; b: number; a?: number }
interface TypeStyle { fontFamily: string; fontSize: number; fontWeight: number }
interface ComponentMeta { key: string; name: string; description: string }
interface StyleMeta { key: string; name: string; style_type: 'FILL' | 'TEXT' | 'EFFECT' | 'GRID' }
Step 4: Node Tree Walker
typescript
// Walk the Figma document tree with a visitor pattern
function walkNodes(node: FigmaNode, visitor: (n: FigmaNode) => void) {
  visitor(node);
  if (node.children) {
    for (const child of node.children) {
      walkNodes(child, visitor);
    }
  }
}

// Example: find all TEXT nodes
function findTextNodes(root: FigmaNode): FigmaNode[] {
  const results: FigmaNode[] = [];
  walkNodes(root, (n) => {
    if (n.type === 'TEXT') results.push(n);
  });
  return results;
}

// Example: find all COMPONENT nodes
function findComponents(root: FigmaNode): FigmaNode[] {
  const results: FigmaNode[] = [];
  walkNodes(root, (n) => {
    if (n.type === 'COMPONENT') results.push(n);
  });
  return results;
}
Step 5: Singleton with Retry
typescript
// Singleton instance with automatic retry on transient errors
let client: FigmaClient | null = null;

export function getFigmaClient(): FigmaClient {
  if (!client) {
    client = new FigmaClient(process.env.FIGMA_PAT!);
  }
  return client;
}

export async function withRetry<T>(
  fn: () => Promise<T>,
  maxRetries = 3
): Promise<T> {
  for (let attempt = 0; attempt <= maxRetries; attempt++) {
    try {
      return await fn();
    } catch (err) {
      if (err instanceof FigmaRateLimitError) {
        await new Promise(r => setTimeout(r, err.retryAfterSeconds * 1000));
        continue;
      }
      if (attempt === maxRetries) throw err;
      await new Promise(r => setTimeout(r, 1000 * Math.pow(2, attempt)));
    }
  }
  throw new Error('Unreachable');
}

Output

  • Typed Figma REST API client with full error handling
  • Custom error hierarchy for rate limits, auth, not found
  • Node tree walker for extracting design data
  • Singleton pattern with retry logic

Error Handling

PatternUse CaseBenefit
Typed errorscatch (e) { if (e instanceof FigmaRateLimitError) }Targeted recovery
Node walkerTraversing arbitrarily deep treesHandles any file structure
Retry wrapperTransient 429/5xx errorsAutomatic recovery
SingletonShared client across modulesConsistent config, one token

Examples

Use the typed client (Step 1) with the custom error classes (Step 2) — call sites stay clean:

typescript
import { FigmaClient, FigmaRateLimitError, FigmaAuthError } from './figma';

const figma = new FigmaClient(process.env.FIGMA_PAT!);

try {
  const file = await figma.getFile(process.env.FIGMA_FILE_KEY!, { depth: 1 });
  console.log(`${file.name} — ${file.document.children.length} pages`);
} catch (err) {
  if (err instanceof FigmaRateLimitError) scheduleRetry(err.retryAfterSeconds);
  else if (err instanceof FigmaAuthError) alertOps('figma token invalid');
  else throw err;
}

Count every TEXT node with the tree walker (Step 4) instead of hand-rolled recursion:

typescript
const textCount = walkNodes(file.document, (n) => n.type === 'TEXT').length;

Full type definitions and the retry-wrapped singleton: references/type-definitions.md, references/singleton-with-retry.md.

Resources

Next Steps

Apply patterns in figma-core-workflow-a for real-world file inspection.

© jeremylongshore, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 6 other files (references) in skills/.curated/figma-sdk-patterns of jeremylongshore/tons-of-skills-marketplace.

  • SKILL.md
  • references/custom-error-classes.md
  • references/errors.md
  • references/node-tree-walker.md
  • references/singleton-with-retry.md
  • references/type-definitions.md
  • references/typed-rest-api-client.md

Open the folder on GitHubat commit cfae287

Compare with similar skills

Figma SDK Patterns next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Figma SDK Patterns compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Figma SDK Patterns this skilljeremylongshore/tons-of-skills-marketplace2.8k—~2.2kAutomated safety check: PassMIT
Ingest Figmabluzir/claude-code-design106—~745Automated safety check: PassNone
Tokens Bruecketokens-bruecke/figma-plugin102—~3.2kAutomated safety check: PassMIT
Pp Figmamvanhorn/printing-press-library2.1k—~4.3kAutomated safety check: NotesApache-2.0
Figma To StaticLeoYeAI/openclaw-master-skills2.2k—~7.1kAutomated safety check: PassMIT
Figma Design System Builderwarpdotdev/warp65k2 repos~4.4kAutomated safety check: PassAGPL-3.0

Similar skills

  • Ingest Figma

    bluzir/claude-code-design

    Pull design tokens + frame structure from a Figma URL via the Figma REST API.

    106 GitHub stars~745 tokensUpdated 5 mo ago
    Frontend & DesignAuto-check passed
  • Tokens Bruecke

    tokens-bruecke/figma-plugin

    Export Figma variables and styles as DTCG design tokens JSON via the tokens-bruecke CLI, either from the Figma REST API or from a local snapshot of Plugin API data.

    102 GitHub stars~3.2k tokensUpdated yesterday
    Frontend & DesignAuto-check passed
  • Pp Figma

    mvanhorn/printing-press-library

    Every Figma endpoint, plus codegen-ready frame extracts, comments audit, orphans finder, tokens diff Trigger phrases: extract a figma frame for codegen, compact figma file context for AI, find…

    2.1k GitHub stars~4.3k tokensUpdated today
    Backend & APIsAuto-check: notes
  • Figma To Static

    LeoYeAI/openclaw-master-skills

    Convert Figma design files to pixel-level mobile-first static HTML/CSS pages.

    2.2k GitHub stars~7.1k tokensUpdated 2 mo ago
    Frontend & DesignAuto-check passed
  • Builds or updates a design system in Figma from a codebase in ordered phases: discovery, variables and tokens, components, theming and documentation, with checkpoints.

    65k GitHub starsUsed in 2 repos~4.4k tokens
    Frontend & DesignAuto-check passed
  • Required groundwork before any use_figma call: the rules and reference files for running JavaScript in a Figma file through the Plugin API without common failures.

    65k GitHub starsUsed in 4 repos~4.4k tokens
    Frontend & DesignAuto-check passed

More from jeremylongshore/tons-of-skills-marketplace

All 3,342 skills in this repo
  • Performing Security Code Review

    jeremylongshore/tons-of-skills-marketplace

    Execute this skill enables AI assistant to conduct a security-focused code review using the security-agent plugin.

    2.8k GitHub starsUsed in 2 repos~1.3k tokens
    Auto-check: notes
  • Adapting Transfer Learning Models

    jeremylongshore/tons-of-skills-marketplace

    Build this skill automates the adaptation of pre-trained machine learning models using transfer learning techniques.

    2.8k GitHub stars~1.1k tokensUpdated today
    Auto-check passed
  • Agent Context Loader

    jeremylongshore/tons-of-skills-marketplace

    Execute proactive auto-loading: automatically detects and loads agents.md files.

    2.8k GitHub stars~1.1k tokensUpdated today
    Auto-check passed
  • Aggregating Performance Metrics

    jeremylongshore/tons-of-skills-marketplace

    Aggregate and centralize performance metrics from applications, systems, databases, caches, and services.

    2.8k GitHub stars~1.2k tokensUpdated today
    Auto-check passed
  • Analyzing Capacity Planning

    jeremylongshore/tons-of-skills-marketplace

    Execute this skill enables AI assistant to analyze capacity requirements and plan for future growth.

    2.8k GitHub stars~947 tokensUpdated today
    Auto-check passed
  • Analyzing Database Indexes

    jeremylongshore/tons-of-skills-marketplace

    Process use when you need to work with database indexing. An agent skill from jeremylongshore/tons-of-skills-marketplace.

    2.8k GitHub stars~2k tokensUpdated today
    Auto-check passed

Works with

Questions about Figma SDK Patterns

What does Figma SDK Patterns do?

Production-ready patterns for the Figma REST API and Plugin API. Figma SDK Patterns is an agent skill from jeremylongshore/tons-of-skills-marketplace. Production-ready patterns for the Figma REST API and Plugin API.

When should I use Figma SDK Patterns?

Figma SDK Patterns fits situations like: building reusable Figma client wrappers; extracting design tokens; traversing node trees; creating typed API helpers.

How do I install Figma SDK Patterns in Claude Code?

Run `npx skills add jeremylongshore/tons-of-skills-marketplace --skill figma-sdk-patterns -a claude-code`. Or copy the skill folder (skills/.curated/figma-sdk-patterns in jeremylongshore/tons-of-skills-marketplace) into .claude/skills/figma-sdk-patterns in your project. Claude Code loads it when a task matches its description.

How do I install Figma SDK Patterns in Codex?

Run `npx skills add jeremylongshore/tons-of-skills-marketplace --skill figma-sdk-patterns -a codex`. Or copy the skill folder (skills/.curated/figma-sdk-patterns in jeremylongshore/tons-of-skills-marketplace) into .agents/skills/figma-sdk-patterns in your project. Codex loads it when a task matches its description.

Can I use Figma SDK Patterns in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add jeremylongshore/tons-of-skills-marketplace --skill figma-sdk-patterns -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/figma-sdk-patterns, .gemini/skills/figma-sdk-patterns, .github/skills/figma-sdk-patterns and .opencode/skills/figma-sdk-patterns in your project.

What does Figma SDK Patterns need to run?

Going by SKILL.md and its folder, Figma SDK Patterns needs credentials named FIGMA_FILE_KEY. Our summary lists: Node.js; A credential in FIGMA_FILE_KEY. Its frontmatter pre-approves these tools: Read, Write, Edit. Compatibility (from SKILL.md): Designed for Claude Code.

Does Figma SDK Patterns access the network?

SKILL.md names 4 domains. In commands or code: api.figma.com; the agent is likely to contact it when it follows the instructions. As links in the text: developers.figma.com, github.com and npmjs.com. This is read from the text; nothing was executed.

Is Figma SDK Patterns safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Figma SDK Patterns use?

Figma SDK Patterns is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Figma SDK Patterns use?

About 2.2k tokens (SKILL.md is roughly 8.9k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 2k tokens, read only when the agent opens those files.

What are the alternatives to Figma SDK Patterns?

Skills that share tags, products or a category with Figma SDK Patterns: Ingest Figma (bluzir/claude-code-design, 106 stars), Tokens Bruecke (tokens-bruecke/figma-plugin, 102 stars), Pp Figma (mvanhorn/printing-press-library, 2.1k stars) and Figma To Static (LeoYeAI/openclaw-master-skills, 2.2k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Figma SDK Patterns?

jeremylongshore (a GitHub user) maintains it in jeremylongshore/tons-of-skills-marketplace, which has 2,827 GitHub stars. The repository holds 3,342 skills in this directory. The repository was last updated on October 10, 2026.

Source: jeremylongshore/tons-of-skills-marketplace on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.