figma-policy-guardrails
Enforce security policies and coding standards for Figma API integrations. Use when setting up linting rules for Figma tokens, preventing accidental credential leaks, or enforcing API usage best practices. Trigger with phrases like "figma policy", "figma lint", "figma guardrails", "figma security rules", "figma best practices check".
Best use case
figma-policy-guardrails is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Enforce security policies and coding standards for Figma API integrations. Use when setting up linting rules for Figma tokens, preventing accidental credential leaks, or enforcing API usage best practices. Trigger with phrases like "figma policy", "figma lint", "figma guardrails", "figma security rules", "figma best practices check".
Teams using figma-policy-guardrails should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/figma-policy-guardrails/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How figma-policy-guardrails Compares
| Feature / Agent | figma-policy-guardrails | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Enforce security policies and coding standards for Figma API integrations. Use when setting up linting rules for Figma tokens, preventing accidental credential leaks, or enforcing API usage best practices. Trigger with phrases like "figma policy", "figma lint", "figma guardrails", "figma security rules", "figma best practices check".
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
AI Agents for Coding
Browse AI agent skills for coding, debugging, testing, refactoring, code review, and developer workflows across Claude, Cursor, and Codex.
Best AI Skills for Claude
Explore the best AI skills for Claude and Claude Code across coding, research, workflow automation, documentation, and agent operations.
ChatGPT vs Claude for Agent Skills
Compare ChatGPT and Claude for AI agent skills across coding, writing, research, and reusable workflow execution.
SKILL.md Source
# Figma Policy & Guardrails
## Overview
Automated guardrails for Figma API integrations: prevent token leaks, enforce scope minimization, validate webhook configurations, and catch common anti-patterns in CI.
## Prerequisites
- ESLint or similar linter
- CI/CD pipeline (GitHub Actions)
- Pre-commit hooks infrastructure
## Instructions
### Step 1: Token Leak Prevention
```bash
# .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
```
```yaml
# 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
```
### Step 2: ESLint Rules for Figma
```javascript
// 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.',
});
}
}
},
};
},
};
```
### Step 3: API Usage Policies
```typescript
// 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}`
);
}
}
```
### Step 4: Configuration Validation
```typescript
// 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();
```
### Step 5: Audit Logging
```typescript
// 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 }));
}
```
## Output
- Pre-commit hooks catching token leaks
- CI pipeline scanning for hardcoded credentials
- Runtime policies enforcing performance best practices
- Configuration validation at startup
- Audit logging for compliance
## Error Handling
| 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 |
## Resources
- [Figma API Scopes](https://developers.figma.com/docs/rest-api/scopes/)
- [Pre-commit Framework](https://pre-commit.com/)
- [ESLint Custom Rules](https://eslint.org/docs/latest/extend/custom-rules)
## Next Steps
For architecture blueprints, see `figma-architecture-variants`.Related Skills
windsurf-policy-guardrails
Implement team-wide Windsurf usage policies, code quality gates, and Cascade guardrails. Use when setting up code review policies for AI-generated code, configuring Turbo mode safety controls, or implementing CI gates for Cascade output. Trigger with phrases like "windsurf policy", "windsurf guardrails", "cascade safety rules", "windsurf team rules", "AI code policy".
vercel-policy-guardrails
Implement lint rules, CI policy checks, and automated guardrails for Vercel projects. Use when setting up code quality rules, preventing secret exposure, or enforcing deployment policies for Vercel applications. Trigger with phrases like "vercel policy", "vercel lint", "vercel guardrails", "vercel best practices check", "vercel secret scan".
supabase-policy-guardrails
Enforce organizational governance for Supabase projects: shared RLS policy library with reusable templates, table and column naming conventions, migration review process with CI checks, cost alert thresholds, and security audit scripts scanning for common misconfigurations. Use when establishing Supabase standards across teams, creating RLS policy templates, setting up migration review workflows, or auditing existing projects for security and cost issues. Trigger with phrases like "supabase governance", "supabase policy library", "supabase naming convention", "supabase migration review", "supabase cost alert", "supabase security audit", "supabase RLS template".
snowflake-policy-guardrails
Implement Snowflake governance guardrails with network rules, session policies, authentication policies, and automated compliance checks. Use when enforcing security policies, implementing data governance, or configuring automated compliance for Snowflake. Trigger with phrases like "snowflake policy", "snowflake guardrails", "snowflake governance", "snowflake compliance", "snowflake enforce".
shopify-policy-guardrails
Implement Shopify app policy enforcement with ESLint rules for API key detection, query cost budgets, and App Store compliance checks. Trigger with phrases like "shopify policy", "shopify lint", "shopify guardrails", "shopify compliance", "shopify eslint", "shopify app review".
sentry-policy-guardrails
Enforce organizational governance and policy guardrails for Sentry usage. Use when standardizing Sentry configuration across services, enforcing PII scrubbing, building shared config packages, or auditing drift. Trigger with phrases like "sentry governance", "sentry policy", "sentry standards", "enforce sentry config", "sentry compliance".
salesforce-policy-guardrails
Implement Salesforce lint rules, SOQL injection prevention, and API usage guardrails. Use when enforcing Salesforce integration code quality, preventing SOQL injection, or configuring CI policy checks for Salesforce best practices. Trigger with phrases like "salesforce policy", "salesforce lint", "salesforce guardrails", "SOQL injection", "salesforce eslint", "salesforce code review".
retellai-policy-guardrails
Retell AI policy guardrails — AI voice agent and phone call automation. Use when working with Retell AI for voice agents, phone calls, or telephony. Trigger with phrases like "retell policy guardrails", "retellai-policy-guardrails", "voice agent".
perplexity-policy-guardrails
Implement content moderation, model selection policy, citation quality enforcement, and per-user usage quotas for Perplexity Sonar API. Trigger with phrases like "perplexity policy", "perplexity guardrails", "perplexity content moderation", "perplexity usage limits", "perplexity safety".
notion-policy-guardrails
Governance for Notion integrations: integration naming standards, page sharing policies, property naming conventions, database schema standards, and access audit scripts. Trigger with phrases like "notion governance", "notion policy", "notion naming convention", "notion access audit", "notion schema standard".
klingai-content-policy
Implement content policy compliance for Kling AI prompts and outputs. Use when filtering user prompts or handling moderation. Trigger with phrases like 'klingai content policy', 'kling ai moderation', 'safe video generation', 'klingai content filter'.
hubspot-policy-guardrails
Implement HubSpot lint rules, secret scanning, and CI policy checks. Use when setting up code quality rules for HubSpot integrations, preventing token leaks, or configuring CI guardrails. Trigger with phrases like "hubspot policy", "hubspot lint", "hubspot guardrails", "hubspot security check", "hubspot eslint rules".