/figma-pack:figma-policy-guardrailsfrom figma-pack
Enforces security policies and coding standards for Figma API integrations. Prevents token leaks, validates webhook configs, and catches anti-patterns via ESLint rules and CI/CD scanning.
Ships in figma-pack. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Automated guardrails for Figma API integrations: prevent token leaks, enforce scope minimization, validate webhook configurations, and catch common anti-patterns in CI.
# .pre-commit-config.yaml -- catch Figma tokens before commit
repos:
- repo: local
hooks:
- id: no-figma-tokens
name: Check for Figma PAT leaks
entry: bash -c '
if git diff --cached --diff-filter=ACM -z -- . |
xargs -0 grep -lP "figd_[a-zA-Z0-9_-]{20,}" 2>/dev/null; then
echo "ERROR: Figma PAT found in staged files"
echo "Store tokens in .env files (which should be in .gitignore)"
exit 1
fi
'
language: system
pass_filenames: false
# GitHub Actions secret scanning
# .github/workflows/figma-security.yml
name: Figma Security Check
on: [push, pull_request]
jobs:
security:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Scan for Figma tokens
run: |
if grep -rP "figd_[a-zA-Z0-9_-]{20,}" \
--include="*.ts" --include="*.js" --include="*.json" \
--exclude-dir=node_modules .; then
echo "::error::Figma PAT found in source code"
exit 1
fi
- name: Check .env files not committed
run: |
if git ls-files --cached | grep -E '^\.(env|env\.local|env\.production)$'; then
echo "::error::.env file committed to repository"
exit 1
fi
// eslint-rules/no-figma-token-literal.js
module.exports = {
meta: {
type: 'problem',
docs: { description: 'Disallow hardcoded Figma PATs' },
},
create(context) {
return {
Literal(node) {
if (typeof node.value === 'string' && /^figd_[a-zA-Z0-9_-]{20,}/.test(node.value)) {
context.report({
node,
message: 'Hardcoded Figma PAT detected. Use process.env.FIGMA_PAT instead.',
});
}
},
TemplateLiteral(node) {
for (const quasi of node.quasis) {
if (/figd_[a-zA-Z0-9_-]{20,}/.test(quasi.value.raw)) {
context.report({
node,
message: 'Hardcoded Figma PAT in template literal.',
});
}
}
},
};
},
};
// Runtime guardrails for Figma API usage
// Policy 1: No full-file fetches without justification
function validateFigmaRequest(path: string) {
// Block unoptimized full file fetches
if (path.match(/\/v1\/files\/[^/]+$/) && !path.includes('depth=')) {
console.warn(
'[figma-policy] Full file fetch without depth parameter. ' +
'Use ?depth=1 or /nodes endpoint for better performance.'
);
}
// Block deprecated scope indicator
if (path.includes('files:read')) {
throw new Error(
'[figma-policy] files:read scope is deprecated. ' +
'Use file_content:read instead.'
);
}
}
// Policy 2: Enforce timeout on all Figma calls
function validateTimeout(options: RequestInit) {
if (!options.signal) {
console.warn(
'[figma-policy] Figma request without AbortSignal. ' +
'Use AbortSignal.timeout() to prevent hung requests.'
);
}
}
// Policy 3: Rate limit safety margin
const MAX_REQUESTS_PER_MINUTE = 25; // Conservative limit
let requestsThisMinute = 0;
let minuteStart = Date.now();
function enforceRatePolicy() {
if (Date.now() - minuteStart > 60_000) {
requestsThisMinute = 0;
minuteStart = Date.now();
}
requestsThisMinute++;
if (requestsThisMinute > MAX_REQUESTS_PER_MINUTE) {
throw new Error(
`[figma-policy] Rate limit safety: ${requestsThisMinute} requests/min ` +
`exceeds policy limit of ${MAX_REQUESTS_PER_MINUTE}`
);
}
}
// Validate Figma config at startup, fail fast if misconfigured
function validateFigmaConfig() {
const errors: string[] = [];
// Token format
const pat = process.env.FIGMA_PAT;
if (!pat) {
errors.push('FIGMA_PAT is not set');
} else if (!pat.startsWith('figd_')) {
errors.push('FIGMA_PAT does not have expected figd_ prefix');
}
// File key format
const fileKey = process.env.FIGMA_FILE_KEY;
if (!fileKey) {
errors.push('FIGMA_FILE_KEY is not set');
} else if (fileKey.length < 10) {
errors.push('FIGMA_FILE_KEY seems too short');
}
// Webhook passcode (if webhooks are configured)
if (process.env.FIGMA_WEBHOOK_ENABLED === 'true') {
if (!process.env.FIGMA_WEBHOOK_PASSCODE) {
errors.push('FIGMA_WEBHOOK_PASSCODE required when webhooks are enabled');
} else if (process.env.FIGMA_WEBHOOK_PASSCODE.length < 16) {
errors.push('FIGMA_WEBHOOK_PASSCODE should be at least 16 characters');
}
}
if (errors.length > 0) {
console.error('[figma-policy] Configuration errors:');
errors.forEach(e => console.error(` - ${e}`));
throw new Error(`Figma configuration invalid: ${errors.length} errors`);
}
console.log('[figma-policy] Configuration validated');
}
// Call at startup
validateFigmaConfig();
// Log all Figma API operations for compliance
interface FigmaAuditEntry {
timestamp: string;
action: string;
endpoint: string;
fileKey?: string;
status: number;
userId?: string;
}
function auditFigmaCall(entry: Omit<FigmaAuditEntry, 'timestamp'>) {
const log: FigmaAuditEntry = {
...entry,
timestamp: new Date().toISOString(),
};
// Structured log for aggregation
console.log(JSON.stringify({ type: 'figma_audit', ...log }));
}
| Issue | Cause | Solution |
|---|---|---|
| False positive on token scan | Test fixture contains figd_ | Exclude test fixtures directory |
| Policy blocks legitimate request | Too restrictive | Add exception list for specific paths |
| Startup validation fails | Missing env vars | Check deployment config |
| Audit log noise | Too many entries | Filter to write operations only |
For architecture blueprints, see figma-architecture-variants.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
30 skills in this plugin
/figma-advanced-troubleshootingDeep debugging for Figma API issues: network analysis, response inspection, and support escalation.
Use when standard troubleshooting fails, diagnosing intermittent failures,
or preparing detailed evidence for Figma support.
Trigger with phrases like "figma hard bug", "figma mystery error",
"figma deep debug", "figma intermittent failure", "figma support ticket".
/figma-architecture-variantsChoose between Figma integration architectures: CLI script, webhook service, or plugin.
Use when deciding how to integrate with Figma, comparing REST API vs Plugin API,
or planning a Figma-connected application.
Trigger with phrases like "figma architecture", "figma blueprint",
"how to integrate figma", "figma plugin vs api", "figma project type".
/figma-ci-integrationAutomate Figma design token sync and asset export in CI/CD pipelines.
Use when setting up GitHub Actions for Figma, automating icon exports,
or validating design token changes in pull requests.
Trigger with phrases like "figma CI", "figma GitHub Actions",
"automate figma export", "figma CI pipeline".
/figma-common-errorsDiagnose and fix common Figma REST API and Plugin API errors.
Use when encountering HTTP errors, plugin sandbox crashes,
or unexpected API responses from Figma.
Trigger with phrases like "figma error", "fix figma",
"figma not working", "figma 403", "figma 429".
/figma-core-workflow-aExtract design tokens, colors, typography, and spacing from Figma files via REST API.
Use when building a design-to-code pipeline, syncing design tokens,
or extracting styles from a Figma design system file.
Trigger with phrases like "figma design tokens", "extract figma styles",
"figma to CSS", "sync figma colors", "figma typography".
/figma-core-workflow-bExport images, icons, and assets from Figma files via the REST API.
Use when building an asset pipeline, exporting icons as SVG/PNG,
or rendering frames to images for documentation or previews.
Trigger with phrases like "figma export", "figma images",
"export figma icons", "figma assets", "figma render".
npx claudepluginhub flight505/skill-forge --plugin figma-packOther plugins' skills for the same job