sync-figma-token
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesesync-figma-token
sync-figma-token
Use this skill for token parity workflows (code tokens vs Figma variables).
MANDATORY prerequisite: load before every call.
figma-useuse_figma该Skill用于实现令牌一致性工作流(代码令牌与Figma变量同步)。
强制前置条件:每次调用前必须先加载。
use_figmafigma-useNon-negotiable safety rule
不可违反的安全规则
After producing dry-run output, you MUST STOP and ask for approval.
- Do NOT run any write calls in the same turn as dry-run output.
use_figma - Ask a normal confirmation question (example: "Apply these changes? (yes/no)").
- Only proceed on explicit affirmative approval.
- If the response is unclear or negative, do not apply writes.
生成dry-run输出后,必须停止操作并请求审批。
- 不得在生成dry-run输出的同一轮次中执行任何写入型调用。
use_figma - 提出常规确认问题(示例:"是否应用这些更改?(是/否)")。
- 仅在收到明确的肯定答复后才可继续操作。
- 若答复不明确或为否定,不得执行写入操作。
Standard source formats (required)
标准源格式(必填)
Prefer real token sources in this order:
- Design Tokens JSON (,
tokens.json, DTCG-style)tokens/*.json - Style Dictionary input JSON
- Platform theme sources (Compose/Kotlin/TS) only when JSON source is unavailable
If source format is non-standard, explicitly state assumptions in dry-run output.
优先按以下顺序使用真实令牌源:
- 设计令牌JSON(、
tokens.json,DTCG规范)tokens/*.json - Style Dictionary输入JSON
- 仅当JSON源不可用时,才使用平台主题源(Compose/Kotlin/TS)
若源格式非标准,需在dry-run输出中明确说明假设前提。
Required policies before writes
写入前必填策略
- :
direction(default),code_to_figma,figma_to_codebidirectional - : default
deletePolicy(NOT delete)archive_only - :
conflictPolicy,prefer_code,prefer_figmamanual_review - : token key normalization strategy
namingPolicy - : code mode <-> Figma mode mapping
modePolicy
Never delete by default. Deletion requires explicit user instruction.
- :
direction(默认)、code_to_figma、figma_to_codebidirectional - :默认
deletePolicy(仅归档,不删除)archive_only - :
conflictPolicy、prefer_code、prefer_figmamanual_review - :令牌键标准化策略
namingPolicy - :代码模式与Figma模式的映射规则
modePolicy
默认禁止删除操作,删除需用户明确指令。
Normalization rules
标准化规则
Normalize both sides to canonical rows:
- (canonical token name)
key - (
type,COLOR,FLOAT,STRING)BOOLEAN - (light/dark/etc.)
modeValues aliasTargetscopescodeSyntax
Name normalization examples:
- <->
color.bg.primarycolor/bg/primary - <->
Neutral10only if explicitly mapped by naming policyNeutral/10
将两端数据标准化为规范条目:
- (规范令牌名称)
key - (
type、COLOR、FLOAT、STRING)BOOLEAN - (亮色/暗色等模式值)
modeValues - (别名目标)
aliasTarget - (作用域)
scopes - (代码语法)
codeSyntax
名称标准化示例:
- <->
color.bg.primarycolor/bg/primary - <->
Neutral10(仅当命名策略明确映射时生效)Neutral/10
Value validation (required)
值验证(必填)
Dry-run must validate values, not only presence/type.
- COLOR: compare RGBA with tolerance
epsilon = 0.0001 - FLOAT: strict numeric comparison unless tolerance is configured
- STRING/BOOLEAN: strict equality
- Aliases: compare canonical alias targets
Dry-run必须验证值的准确性,而非仅检查存在性或类型。
- 颜色:对比RGBA值,容差为
epsilon = 0.0001 - 浮点数:除非配置了容差,否则严格数值对比
- 字符串/布尔值:严格相等对比
- 别名:对比规范别名目标
Drift categories
差异类别
Each drift item must include one of:
missing_in_figmamissing_in_codevalue_mismatchalias_mismatchtype_mismatchmode_mismatchscope_mismatchcode_syntax_mismatchbroken_alias
每个差异项必须归为以下类别之一:
- (Figma中缺失)
missing_in_figma - (代码中缺失)
missing_in_code - (值不匹配)
value_mismatch - (别名不匹配)
alias_mismatch - (类型不匹配)
type_mismatch - (模式不匹配)
mode_mismatch - (作用域不匹配)
scope_mismatch - (代码语法不匹配)
code_syntax_mismatch - (别名失效)
broken_alias
Dry-run output format
Dry-run输出格式
Always return:
- Headline summary:
json
{
"create": 0,
"update": 0,
"aliasFix": 0,
"scopeFix": 0,
"syntaxFix": 0,
"archive": 0,
"delete": 0
}- Detailed drift list with token keys and before/after values.
Then ask:
Dry-run complete. Apply these changes? (yes/no)必须返回以下内容:
- 摘要信息:
json
{
"create": 0,
"update": 0,
"aliasFix": 0,
"scopeFix": 0,
"syntaxFix": 0,
"archive": 0,
"delete": 0
}- 包含令牌键及前后值的详细差异列表。
随后询问:
Dry-run完成。是否应用这些更改?(是/否)Report persistence (required)
报告持久化(必填)
Persist report JSON every run:
/tmp/sync-figma-token-dry-run-{runId}.json/tmp/sync-figma-token-final-{runId}.json
If file persistence fails, mention that explicitly in output.
每次运行需持久化报告JSON:
/tmp/sync-figma-token-dry-run-{runId}.json/tmp/sync-figma-token-final-{runId}.json
若文件持久化失败,需在输出中明确提及。
Conflict handling
冲突处理
When conflicting data is found (type/mode/alias ambiguity):
- If , list conflicts and STOP.
conflictPolicy=manual_review - If , update Figma to source values/types.
conflictPolicy=prefer_code - If , keep Figma and emit drift as informational.
conflictPolicy=prefer_figma
当发现冲突数据(类型/模式/别名不明确)时:
- 若,列出冲突并停止操作。
conflictPolicy=manual_review - 若,更新Figma以匹配源值/类型。
conflictPolicy=prefer_code - 若,保留Figma的值,并将差异作为信息输出。
conflictPolicy=prefer_figma
Apply order
应用顺序
Apply deltas in this order:
- Ensure collections/modes
- Create missing primitives
- Create/update semantic aliases
- Apply value updates
- Apply scopes and code syntax
- Archive stale tokens per
deletePolicy
Never parallelize write calls.
use_figma按以下顺序应用增量更改:
- 确保集合/模式存在
- 创建缺失的基础令牌
- 创建/更新语义别名
- 应用值更新
- 应用作用域与代码语法
- 根据归档过期令牌
deletePolicy
不得并行执行写入型调用。
use_figmaSuccess condition
成功条件
After apply, run a fresh diff.
Success = unresolved drift is zero, or only explicitly approved exceptions remain.
应用更改后,重新执行差异对比。
成功 = 未解决的差异为零,或仅剩余明确批准的例外项。