figma-api
FigmaのREST APIを活用し、デザインファイルの読み込み、素材の書き出し、コンポーネントの抽出、デザイン トークンの取得などを自動化することで、デザインと開発の連携を効率化するSkill。
📜 元の英語説明(参考)
Interact with the Figma REST API to read design files, export assets, extract components, and pull design tokens programmatically. Use when tasks involve automating design handoff, syncing design tokens to code, exporting icons/images from Figma, or building integrations between Figma and development pipelines.
🇯🇵 日本人クリエイター向け解説
FigmaのREST APIを活用し、デザインファイルの読み込み、素材の書き出し、コンポーネントの抽出、デザイン トークンの取得などを自動化することで、デザインと開発の連携を効率化するSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o figma-api.zip https://jpskill.com/download/14898.zip && unzip -o figma-api.zip && rm figma-api.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/14898.zip -OutFile "$d\figma-api.zip"; Expand-Archive "$d\figma-api.zip" -DestinationPath $d -Force; ri "$d\figma-api.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
figma-api.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
figma-apiフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
Figma API
Figma REST API は、デザインファイルを構造化された JSON として公開します。すべてのフレーム、コンポーネント、テキストノード、およびスタイルはアドレス指定可能です。認証には、個人アクセストークンまたは OAuth2 を使用します。
認証
# .env — アカウント設定からの Figma 個人アクセストークン。
FIGMA_TOKEN=figd_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
FIGMA_FILE_KEY=abc123DEFghiJKL
ファイルの読み込み
// src/figma/get-file.ts — Figma ファイルツリー全体をフェッチします。
// ページ、フレーム、およびノードを持つネストされたドキュメント構造を返します。
const FIGMA_BASE = "https://api.figma.com/v1";
export async function getFigmaFile(fileKey: string, token: string) {
const res = await fetch(`${FIGMA_BASE}/files/${fileKey}`, {
headers: { "X-Figma-Token": token },
});
if (!res.ok) throw new Error(`Figma API ${res.status}: ${res.statusText}`);
return res.json();
}
アセットのエクスポート
// src/figma/export-assets.ts — 特定のノードを PNG/SVG/PDF としてエクスポートします。
// ノード ID (ファイルツリーから) と目的のフォーマットを渡します。
export async function exportNodes(
fileKey: string,
nodeIds: string[],
format: "png" | "svg" | "pdf",
token: string
) {
const ids = nodeIds.join(",");
const res = await fetch(
`${FIGMA_BASE}/images/${fileKey}?ids=${ids}&format=${format}&scale=2`,
{ headers: { "X-Figma-Token": token } }
);
const data = await res.json();
return data.images; // { nodeId: downloadUrl }
}
デザイン トークンの抽出
// src/figma/extract-tokens.ts — Figma ファイルツリーをたどり、
// カラースタイル、テキストスタイル、およびスペーシングの値をトークンオブジェクトに抽出します。
interface DesignTokens {
colors: Record<string, string>;
typography: Record<string, { fontFamily: string; fontSize: number; fontWeight: number }>;
spacing: Record<string, number>;
}
export function extractTokens(figmaFile: any): DesignTokens {
const tokens: DesignTokens = { colors: {}, typography: {}, spacing: {} };
const styles = figmaFile.styles || {};
function walkNode(node: any) {
// スタイルを参照するノードから塗りつぶしの色を抽出します
if (node.styles?.fill && node.fills?.[0]?.color) {
const c = node.fills[0].color;
const hex = rgbaToHex(c.r, c.g, c.b, c.a);
const styleName = styles[node.styles.fill]?.name || node.name;
tokens.colors[styleName] = hex;
}
// テキストスタイルを抽出します
if (node.type === "TEXT" && node.style) {
const s = node.style;
const styleName = styles[node.styles?.text]?.name || node.name;
tokens.typography[styleName] = {
fontFamily: s.fontFamily,
fontSize: s.fontSize,
fontWeight: s.fontWeight,
};
}
if (node.children) node.children.forEach(walkNode);
}
walkNode(figmaFile.document);
return tokens;
}
function rgbaToHex(r: number, g: number, b: number, a: number): string {
const toHex = (v: number) =>
Math.round(v * 255)
.toString(16)
.padStart(2, "0");
return `#${toHex(r)}${toHex(g)}${toHex(b)}${a < 1 ? toHex(a) : ""}`;
}
コンポーネントの一覧表示
// src/figma/list-components.ts — ファイル内の公開されているすべてのコンポーネントを取得します。
// コンポーネントインベントリまたはアイコンライブラリの構築に役立ちます。
export async function getComponents(fileKey: string, token: string) {
const res = await fetch(`${FIGMA_BASE}/files/${fileKey}/components`, {
headers: { "X-Figma-Token": token },
});
const data = await res.json();
return data.meta.components.map((c: any) => ({
key: c.key,
name: c.name,
description: c.description,
containingFrame: c.containing_frame?.name,
}));
}
Webhook
// src/figma/webhook.ts — ファイルの変更時に通知を受け取るための webhook を登録します。
// Figma は、ファイルが更新されたり、コメントが追加されたりすると、POST リクエストを送信します。
export async function createWebhook(
teamId: string,
endpoint: string,
token: string
) {
const res = await fetch(`${FIGMA_BASE}/v2/webhooks`, {
method: "POST",
headers: {
"X-Figma-Token": token,
"Content-Type": "application/json",
},
body: JSON.stringify({
event_type: "FILE_UPDATE",
team_id: teamId,
endpoint,
passcode: "my-secret-passcode",
}),
});
return res.json();
} 📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Figma API
The Figma REST API exposes design files as structured JSON. Every frame, component, text node, and style is addressable. Authentication uses personal access tokens or OAuth2.
Authentication
# .env — Figma personal access token from account settings.
FIGMA_TOKEN=figd_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
FIGMA_FILE_KEY=abc123DEFghiJKL
Reading a File
// src/figma/get-file.ts — Fetch the full Figma file tree.
// Returns a nested document structure with pages, frames, and nodes.
const FIGMA_BASE = "https://api.figma.com/v1";
export async function getFigmaFile(fileKey: string, token: string) {
const res = await fetch(`${FIGMA_BASE}/files/${fileKey}`, {
headers: { "X-Figma-Token": token },
});
if (!res.ok) throw new Error(`Figma API ${res.status}: ${res.statusText}`);
return res.json();
}
Exporting Assets
// src/figma/export-assets.ts — Export specific nodes as PNG/SVG/PDF.
// Pass node IDs (from the file tree) and desired format.
export async function exportNodes(
fileKey: string,
nodeIds: string[],
format: "png" | "svg" | "pdf",
token: string
) {
const ids = nodeIds.join(",");
const res = await fetch(
`${FIGMA_BASE}/images/${fileKey}?ids=${ids}&format=${format}&scale=2`,
{ headers: { "X-Figma-Token": token } }
);
const data = await res.json();
return data.images; // { nodeId: downloadUrl }
}
Extracting Design Tokens
// src/figma/extract-tokens.ts — Walk the Figma file tree and pull
// color styles, text styles, and spacing values into a tokens object.
interface DesignTokens {
colors: Record<string, string>;
typography: Record<string, { fontFamily: string; fontSize: number; fontWeight: number }>;
spacing: Record<string, number>;
}
export function extractTokens(figmaFile: any): DesignTokens {
const tokens: DesignTokens = { colors: {}, typography: {}, spacing: {} };
const styles = figmaFile.styles || {};
function walkNode(node: any) {
// Extract fill colors from nodes that reference a style
if (node.styles?.fill && node.fills?.[0]?.color) {
const c = node.fills[0].color;
const hex = rgbaToHex(c.r, c.g, c.b, c.a);
const styleName = styles[node.styles.fill]?.name || node.name;
tokens.colors[styleName] = hex;
}
// Extract text styles
if (node.type === "TEXT" && node.style) {
const s = node.style;
const styleName = styles[node.styles?.text]?.name || node.name;
tokens.typography[styleName] = {
fontFamily: s.fontFamily,
fontSize: s.fontSize,
fontWeight: s.fontWeight,
};
}
if (node.children) node.children.forEach(walkNode);
}
walkNode(figmaFile.document);
return tokens;
}
function rgbaToHex(r: number, g: number, b: number, a: number): string {
const toHex = (v: number) =>
Math.round(v * 255)
.toString(16)
.padStart(2, "0");
return `#${toHex(r)}${toHex(g)}${toHex(b)}${a < 1 ? toHex(a) : ""}`;
}
Listing Components
// src/figma/list-components.ts — Get all published components in a file.
// Useful for building component inventories or icon libraries.
export async function getComponents(fileKey: string, token: string) {
const res = await fetch(`${FIGMA_BASE}/files/${fileKey}/components`, {
headers: { "X-Figma-Token": token },
});
const data = await res.json();
return data.meta.components.map((c: any) => ({
key: c.key,
name: c.name,
description: c.description,
containingFrame: c.containing_frame?.name,
}));
}
Webhooks
// src/figma/webhook.ts — Register a webhook to get notified on file changes.
// Figma sends POST requests when files are updated, comments are added, etc.
export async function createWebhook(
teamId: string,
endpoint: string,
token: string
) {
const res = await fetch(`${FIGMA_BASE}/v2/webhooks`, {
method: "POST",
headers: {
"X-Figma-Token": token,
"Content-Type": "application/json",
},
body: JSON.stringify({
event_type: "FILE_UPDATE",
team_id: teamId,
endpoint,
passcode: "my-secret-passcode",
}),
});
return res.json();
}