qt-figma-token-extraction

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Figma Token Extraction Skill

Figma令牌提取技能

This skill extracts design tokens from a Figma file, maps them to QML types, and generates a ready-to-use QML design system with a unified
Theme
singleton.
本技能从Figma文件中提取设计令牌,将其映射为QML类型,并生成带有统一
Theme
单例的可直接使用的QML设计系统。

Skill Structure

技能结构

Supporting files are loaded alongside this SKILL.md:
qt-figma-token-extraction/
├── SKILL.md                        # this file — entry point
├── references/
│   └── token-mapping.md            # Figma variable type → QML type mapping rules
└── examples/
    ├── Primitives.qml      # primitive color palette template
    ├── Theme.qml           # semantic token template (references Primitives)
    ├── FontInterface.qml   # font loaders + icon index template
    ├── Spacing.qml         # spacing and radii template
    └── Typography.qml      # typography scale template
When reaching Step 4 (type mapping), read
references/token-mapping.md
before generating any QML. When generating QML files in Step 6, use the files in
examples/
as structural templates — they reflect the real Qt Design Studio naming and organisation patterns.

支持文件与本SKILL.md一同加载:
qt-figma-token-extraction/
├── SKILL.md                        # 本文件——入口点
├── references/
│   └── token-mapping.md            # Figma变量类型 → QML类型映射规则
└── examples/
    ├── Primitives.qml      # 基础调色板模板
    ├── Theme.qml           # 语义令牌模板(引用Primitives)
    ├── FontInterface.qml   # 字体加载器+图标索引模板
    ├── Spacing.qml         # 间距与圆角模板
    └── Typography.qml      # 排版比例模板
在执行第4步(类型映射)之前,请先阅读
references/token-mapping.md
,再生成任何QML文件。 在第6步生成QML文件时,请使用
examples/
中的文件作为结构模板——它们反映了Qt Design Studio的实际命名和组织模式。

Step 0 — Check Qt Project Setup

步骤0 — 检查Qt项目设置

Always call the AskUserQuestion tool — even if a project appears to be open. Never assume the currently open project is the intended target.
Before calling, read the context to personalise the question:
  • If a project is already open (files visible,
    CMakeLists.txt
    present), name it in the first option so the user can confirm or redirect.
  • If the user's request is an update ("update my colors", "re-extract tokens", "sync the design system"), omit the "create new project" option — updates always target an existing project.
For an update request — two options, no "create new":
tool: AskUserQuestion
question: "Which project should I update the design tokens in?"
options:
  - "This project — <detected project name or path> (currently open)"
  - "A different existing project — I'll give you the path"
For an initial setup request — all three options:
tool: AskUserQuestion
question: "Which Qt project should I set up the design system in?"
options:
  - "This project — <detected project name or path> (currently open)"
  - "A different existing project — I'll give you the path"
  - "Create a new project"
If no project is open yet, replace the first option with just
"An existing project — I'll give you the path"
.
If the project exists (confirmed or path provided): Note the project path. Continue to Step 1 — do not ask for Figma files yet.
If a new project is needed: Scaffold the folder structure and create
main.cpp
and
main.qml
now, then continue to Step 1:
my-project/
├── CMakeLists.txt      ← set up in Step 7
├── main.cpp            ← create now (template below)
├── main.qml            ← create now (template below)
└── design-system/      ← generated files go here
Create
main.cpp
with this exact content — use
QGuiApplication
, not
QApplication
(Widgets is not needed for Qt Quick):
cpp
#include <QGuiApplication>
#include <QQmlApplicationEngine>

int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);
    QQmlApplicationEngine engine;

    engine.loadFromModule("<ProjectName>", "Main");

    if (engine.rootObjects().isEmpty())
        return -1;

    return app.exec();
}
Replace
<ProjectName>
with the URI used in
qt_add_qml_module()
— they must match exactly.
Do not use the old
QUrl url(u"qrc:/..."_qs)
pattern.
In Qt 6,
qt_add_qml_module
places files under
qrc:/qt/qml/<URI>/
— not
qrc:/<URI>/
as in Qt 5. Using the old path causes a silent load failure.
loadFromModule()
avoids this entirely and is the correct approach for Qt 6.5+.
Create
Main.qml
as a placeholder — capital M, not lowercase.
loadFromModule()
is case-sensitive and looks for a type named
Main
, which maps to
Main.qml
:
qml
import QtQuick

Window {
    width:   640
    height:  480
    visible: true
    title:   "My Qt App"
}
CMake setup: The full CMakeLists.txt — including singleton registration — is written in Step 7 once all QML files are known. Do not write it now. If the user encounters any build configuration issues, suggest the user check Qt's CMake documentation at https://doc.qt.io/qt-6/cmake-get-started.html rather than troubleshooting inline.

务必调用AskUserQuestion工具——即使项目看似已打开。永远不要假设当前打开的项目就是目标项目。
调用工具前,请阅读上下文以个性化问题:
  • 如果项目已打开(可见文件、存在
    CMakeLists.txt
    ),请在第一个选项中命名该项目,以便用户确认或重定向。
  • 如果用户的请求是更新(如“更新我的颜色”“重新提取令牌”“同步设计系统”),则省略“创建新项目”选项——更新始终针对现有项目。
对于更新请求——两个选项,无“创建新项目”:
tool: AskUserQuestion
question: "我应该在哪个项目中更新设计令牌?"
options:
  - "当前项目 — <检测到的项目名称或路径>(已打开)"
  - "其他现有项目 — 我将提供路径"
对于初始设置请求——三个选项:
tool: AskUserQuestion
question: "我应该在哪个Qt项目中搭建设计系统?"
options:
  - "当前项目 — <检测到的项目名称或路径>(已打开)"
  - "其他现有项目 — 我将提供路径"
  - "创建新项目"
如果尚未打开任何项目,请将第一个选项替换为
"现有项目 — 我将提供路径"
**如果项目已存在(已确认或提供路径):**记录项目路径。继续执行步骤1——暂不要询问Figma文件。
**如果需要创建新项目:**现在就搭建文件夹结构并创建
main.cpp
main.qml
,然后继续执行步骤1:
my-project/
├── CMakeLists.txt      ← 在步骤7中设置
├── main.cpp            ← 现在创建(模板如下)
├── main.qml            ← 现在创建(模板如下)
└── design-system/      ← 生成文件存放于此
创建
main.cpp
,内容如下——使用
QGuiApplication
不要使用
QApplication
(Qt Quick不需要Widgets):
cpp
#include <QGuiApplication>
#include <QQmlApplicationEngine>

int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);
    QQmlApplicationEngine engine;

    engine.loadFromModule("<ProjectName>", "Main");

    if (engine.rootObjects().isEmpty())
        return -1;

    return app.exec();
}
<ProjectName>
替换为
qt_add_qml_module()
中使用的URI——两者必须完全匹配。
**请勿使用旧的
QUrl url(u"qrc:/..."_qs)
模式。**在Qt 6中,
qt_add_qml_module
将文件放置在
qrc:/qt/qml/<URI>/
下——而非Qt 5中的
qrc:/<URI>/
。使用旧路径会导致静默加载失败。
loadFromModule()
可完全避免此问题,是Qt 6.5+的正确用法。
创建
Main.qml
作为占位符——首字母大写M,而非小写
loadFromModule()
区分大小写,会查找名为
Main
的类型,对应
Main.qml
文件:
qml
import QtQuick

Window {
    width:   640
    height:  480
    visible: true
    title:   "My Qt App"
}
**CMake设置:**完整的CMakeLists.txt——包括单例注册——将在步骤7中所有QML文件确定后编写。现在请勿编写。如果用户遇到任何构建配置问题,请建议用户查看Qt的CMake文档:https://doc.qt.io/qt-6/cmake-get-started.html,而非在线排查问题。

Step 1 — Routing Questions

步骤1 — 路由问题

Call the AskUserQuestion tool for each question below — one at a time. If the AskUserQuestion tool is not available in the current interface, ask the same question as plain text and wait for the answer before continuing. Do not ask for any Figma links yet.
Call 1 — Modes:
tool: AskUserQuestion
question: "Does your Figma design system use multiple variable modes?"
options:
  - "Yes — for example Light and Dark themes"
  - "No — single mode only"
  - "I'm not sure"
Wait for the answer, then ask:
Call 2 — Terminal:
tool: AskUserQuestion
question: "Are you comfortable running a short command in a terminal on your own computer?"
options:
  - "Yes, I can use a terminal"
  - "No, I prefer not to use a terminal"
Answer combinationWhich method to use (internal)
Single mode / Not sure + any terminal answerMCP method — check for modes during extraction and adapt if needed
Multiple modes + comfortable with terminalcurl method — fetches all modes in one command
Multiple modes + not comfortable with terminalMCP method with manual mode switching
If the user answered "I'm not sure" on modes, proceed with MCP and check for modes during extraction. Explain what you find then, not upfront.
Do not ask whether the file uses Variables or Styles. Auto-detect this after receiving the Figma file URL in Step 2 — call
get_variable_defs
or inspect the file and report what you find. Use Variables extraction if variables exist, Styles extraction if only styles exist, both if both are present.

为以下每个问题调用AskUserQuestion工具——一次一个。如果当前界面中没有AskUserQuestion工具,请以纯文本形式提出相同问题,等待用户回答后再继续。暂不要询问任何Figma链接。
调用1 — 模式:
tool: AskUserQuestion
question: "您的Figma设计系统是否使用多种变量模式?"
options:
  - "是 — 例如浅色和深色主题"
  - "否 — 仅单一模式"
  - "不确定"
等待回答后,继续提问:
调用2 — 终端:
tool: AskUserQuestion
question: "您是否愿意在自己的电脑上运行简短的终端命令?"
options:
  - "是,我会使用终端"
  - "否,我不想使用终端"
回答组合使用方法(内部)
单一模式/不确定 + 任意终端回答MCP方法——提取过程中检查模式并按需调整
多种模式 + 会使用终端curl方法——一次命令获取所有模式
多种模式 + 不想使用终端MCP方法搭配手动切换模式
如果用户对模式回答“不确定”,请使用MCP方法并在提取过程中检查模式。届时解释发现的情况,而非提前说明。
**请勿询问文件使用Variables还是Styles。**在步骤2中收到Figma文件URL后自动检测——调用
get_variable_defs
或检查文件并报告发现的内容。如果存在变量则使用变量提取,如果仅存在样式则使用样式提取,两者都存在则都提取。

Step 2 — Collect All Figma File Links

步骤2 — 收集所有Figma文件链接

Now that you know the extraction approach, ask for all Figma file URLs in one go — before starting any extraction. This avoids interrupting the workflow later.
Ask the user:
"Please share the URL(s) for all Figma files that contain your design tokens. If your tokens are spread across multiple files or pages (e.g. colours in one file, typography in another), share all of them now and tell me what each file contains."
Wait for all URLs before proceeding. Extract the file key from each URL — the alphanumeric string between
/design/
and the next
/
. Note what token types each file/page contains.
Community files note: If any URL is from a Figma community file the user has not duplicated to their account, warn them now: the extraction tools cannot access community files directly. Ask them to duplicate the file to their drafts in Figma first (open the file → Duplicate to your drafts), then share the new URL.

现在您已了解提取方法,请一次性请求所有Figma文件URL——然后再开始提取。这样可避免后续中断工作流。
询问用户:
"请分享包含您设计令牌的所有Figma文件URL。如果您的令牌分散在多个文件或页面中(例如颜色在一个文件中,排版在另一个文件中),请现在分享所有URL并说明每个文件包含的内容。"
等待用户提供所有URL后再继续。从每个URL中提取文件密钥——即
/design/
和下一个
/
之间的字母数字字符串。记录每个文件/页面包含的令牌类型。
**社区文件注意事项:**如果任何URL来自用户尚未复制到自己账户的Figma社区文件,请立即警告用户:提取工具无法直接访问社区文件。请用户先将文件复制到自己的Figma草稿中(打开文件 → 复制到草稿),然后分享新的URL。

MCP Method — Extraction via Figma MCP

MCP方法 — 通过Figma MCP提取

(Use when: single-mode system, or user is not comfortable with a terminal)
Requires: Figma MCP connected. No personal access token or local setup needed.
Note: This method reads only the currently active variable mode in Figma. If the design system has multiple modes (e.g. Light/Dark) the user will need to switch modes in Figma between reads — workable but more steps. Don't mention this limitation upfront; only explain it if multiple modes are discovered during extraction.
(适用场景:单模式系统,或用户不熟悉终端)
**要求:**已连接Figma MCP。无需个人访问令牌或本地设置。
**注意:**此方法仅读取Figma中当前激活的变量模式。如果设计系统有多种模式(如浅色/深色),用户需要在读取之间切换Figma中的模式——可行但步骤更多。不要提前提及此限制;仅当提取过程中发现多种模式时再解释。

Step 1a — Verify Figma MCP is connected

步骤1a — 验证Figma MCP已连接

Before doing anything else, confirm that Figma MCP tools are available. Look for tools whose names suggest variable extraction, design context reading, or file metadata — different Figma MCP servers may use different exact names (e.g.
get_variable_defs
,
getVariableDefinitions
,
figma_get_variables
). Treat the tool names in this skill as examples, not fixed contracts — match by purpose, not exact string.
If no Figma tools are available at all, tell the user:
"The Figma MCP connector isn't connected yet. Connect it in your Claude interface (Settings → Connectors or MCP configuration), then come back and we can start."
Do not proceed until the connection is confirmed.
在执行任何操作之前,请确认Figma MCP工具可用。查找名称暗示变量提取、设计上下文读取或文件元数据的工具——不同的Figma MCP服务器可能使用不同的确切名称(例如
get_variable_defs
getVariableDefinitions
figma_get_variables
)。将本技能中的工具名称视为示例,而非固定约定——按用途匹配,而非精确字符串。
如果完全没有Figma工具可用,请告知用户:
"Figma MCP连接器尚未连接。请在您的Claude界面中连接(设置 → 连接器或MCP配置),然后返回继续。"
在确认连接之前请勿继续。

Step 1b — Check for modes

步骤1b — 检查模式

Call
get_variable_defs
with the file node ID to see what collections and modes exist:
Tool: get_variable_defs
Input: { "nodeId": "<root node id or specific variable group node id>" }
If the response shows multiple modes and the user wants all of them, explain that you'll need them to switch modes in Figma between reads, and proceed.
调用
get_variable_defs
并传入文件节点ID,查看存在哪些集合和模式:
Tool: get_variable_defs
Input: { "nodeId": "<根节点ID或特定变量组节点ID>" }
如果响应显示多种模式且用户需要所有模式,请解释需要用户在读取之间切换Figma中的模式,然后继续。

Step 1c — Extract variables

步骤1c — 提取变量

Call
get_variable_defs
on the relevant nodes. Work through token categories one collection at a time — colors, typography, spacing, radii, shadows. For each collection, read the active mode's values.
If multiple modes need to be captured:
  • Extract and record all values for the current mode
  • Ask the user to switch the active mode in Figma (View menu → Variable Modes, or the mode switcher on the canvas)
  • Call
    get_variable_defs
    again and record values for the new mode
  • Repeat for each mode
  • Merge into a single token file with mode keys (see output format in Step 5)
在相关节点上调用
get_variable_defs
。逐个处理令牌类别——颜色、排版、间距、圆角、阴影。对于每个集合,读取激活模式的值。
如果需要捕获多种模式:
  • 提取并记录当前模式的所有值
  • 请用户在Figma中切换激活模式(视图菜单 → 变量模式,或画布上的模式切换器)
  • 再次调用
    get_variable_defs
    并记录新模式的值
  • 重复上述步骤直到所有模式处理完成
  • 合并到带有模式键的单个令牌文件中(见步骤5中的输出格式)

Step 1d — Resolve aliases

步骤1d — 解析别名

If any variable value references another variable (an alias), resolve it to its final value. Do not write unresolved alias references into the output file — flag any that cannot be resolved and ask the user.

如果任何变量值引用另一个变量(别名),请将其解析为最终值。不要将未解析的别名引用写入输出文件——标记任何无法解析的别名并询问用户。

curl Method — Extraction from the user's local machine

curl方法 — 从用户本地机器提取

(Use when: multiple variable modes, and user is comfortable with a terminal)
Requires: Terminal access (curl is built into macOS and Linux; available on Windows 10+), and a Figma Personal Access Token (viewer scope is enough).
Important: Complete all steps in this section — especially PAT setup and verification — before running any curl commands. Running curl with an invalid token will create broken output files.
Community files are not supported. The curl commands only work on Figma files that are in your own account (files you own or have been invited to). Community files you are viewing but have not duplicated will return a 403 error. If the user is working from a community file, ask them to duplicate it to their account first: in Figma, open the community file → click Duplicate to your drafts → use the duplicated file's URL instead.
(适用场景:多种变量模式,且用户熟悉终端)
**要求:**终端访问权限(curl已内置在macOS和Linux中;Windows 10+也可用),以及Figma个人访问令牌(Viewer权限足够)。
**重要提示:**在运行任何curl命令之前,请完成本节中的所有步骤——尤其是PAT设置和验证。使用无效令牌运行curl会创建损坏的输出文件。
不支持社区文件。curl命令仅适用于用户自己账户中的Figma文件(用户拥有或被邀请访问的文件)。用户正在查看但尚未复制的社区文件将返回403错误。如果用户使用的是社区文件,请先要求用户将其复制到自己的账户中:在Figma中,打开社区文件 → 点击复制到草稿 → 使用复制后的文件URL。

Step 1a — Set up a Figma Personal Access Token

步骤1a — 设置Figma个人访问令牌

Do this before anything else. Ask the user:
"Before we run the extraction command, you'll need a Figma Personal Access Token. Do you already have one?"
If yes: proceed to verification (Step 1b).
If no, guide them through creating one:
  1. Open Figma in your browser or desktop app
  2. Click your avatar (top-left) → Settings
  3. Go to the Security tab
  4. Scroll to Personal access tokens → click Generate new token
  5. Give it any name (e.g. "Claude token export"), set scope to Viewer
  6. Copy the token immediately — Figma only shows it once
请先完成此步骤。询问用户:
"在运行提取命令之前,您需要一个Figma个人访问令牌。您已经拥有了吗?"
如果是:继续验证(步骤1b)。
如果否,引导用户创建:
  1. 在浏览器或桌面应用中打开Figma
  2. 点击您的头像(左上角)→ 设置
  3. 转到安全标签页
  4. 滚动到个人访问令牌 → 点击生成新令牌
  5. 为令牌命名(例如“Claude令牌导出”),设置权限为Viewer
  6. 立即复制令牌——Figma仅显示一次

Step 1b — Verify the PAT works before proceeding

步骤1b — 验证PAT可用后再继续

If the PAT was recently verified (within the last 90 days), the user can skip this step. Otherwise, ask the user to run this verification command in their terminal:
bash
curl -H "X-Figma-Token: YOUR_TOKEN" "https://api.figma.com/v1/me"
Expected result: a JSON response containing their Figma account email (e.g.
"email": "name@example.com"
).
If the response contains
"status": 403
or
"Invalid token"
: the token is wrong or expired. Ask the user to generate a new one and try again. Do not proceed to extraction until the verification succeeds.
如果PAT最近已验证(过去90天内),用户可跳过此步骤。否则,请用户在终端中运行以下验证命令:
bash
curl -H "X-Figma-Token: YOUR_TOKEN" "https://api.figma.com/v1/me"
预期结果:包含用户Figma账户邮箱的JSON响应(例如
"email": "name@example.com"
)。
如果响应包含
"status": 403
"Invalid token"
:令牌错误或已过期。请用户生成新令牌并重试。验证成功之前请勿继续提取。

Step 1c — Run the variables extraction

步骤1c — 运行变量提取

Ask the user to run in their terminal:
bash
curl -H "X-Figma-Token: YOUR_TOKEN" "https://api.figma.com/v1/files/FILE_KEY/variables/local" -o design-tokens-raw.json
This saves the complete raw variable export — all collections, all modes, all values — to
design-tokens-raw.json
.
请用户在终端中运行:
bash
curl -H "X-Figma-Token: YOUR_TOKEN" "https://api.figma.com/v1/files/FILE_KEY/variables/local" -o design-tokens-raw.json
这会将完整的原始变量导出——所有集合、所有模式、所有值——保存到
design-tokens-raw.json

Step 1d — Share the result

步骤1d — 分享结果

Once the command completes, ask the user to either:
  • Upload
    design-tokens-raw.json
    to the conversation, or
  • Paste its contents into the conversation
Then continue to Step 2 (Text Styles) below.

命令完成后,请用户:
  • design-tokens-raw.json
    上传到对话中,或
  • 将其内容粘贴到对话中
然后继续执行下文的步骤2(文本样式)。

Extract Styles

提取样式

Note: Figma Styles (text, color, effect) live separately from Variables and need their own extraction step. If the user's design system uses Styles as the primary token source (not Variables), this step becomes the main extraction — not a secondary one. If the design system uses both Variables and Styles, complete Step 1 first then do this step.
Page-by-page approach: Figma files often spread token types across multiple pages (e.g. Colors on one page, Typography on another). Do not try to extract everything at once. Ask the user which page contains which token type, then extract one page at a time. Confirm what was found after each page before moving to the next.
**注意:**Figma样式(文本、颜色、效果)与Variables分开存在,需要单独的提取步骤。如果用户的设计系统主要使用Styles作为令牌源(而非Variables),此步骤将成为主要提取步骤——而非次要步骤。如果设计系统同时使用Variables和Styles,请先完成步骤1再执行此步骤。
**逐页处理:**Figma文件通常将令牌类型分散在多个页面中(例如颜色在一个页面,排版在另一个页面)。不要尝试一次性提取所有内容。请用户说明哪个页面包含哪种令牌类型,然后逐页提取。每处理完一个页面后确认发现的内容,再继续下一页。

MCP method — Text Styles

MCP方法 — 文本样式

Use
get_design_context
on a text frame or component that uses the design system's text styles. Ask the user to select a frame in Figma that contains representative text elements — headings, body text, labels — and read it:
Tool: get_design_context
Input: { "fileKey": "<key>", "nodeId": "<selected text frame node id>" }
From the response, extract for each text style: the style name, font family, font size, font weight, line height, and letter spacing. Work through all text roles (H1–H6, body, label, caption, code). If not all are visible in one frame, ask the user to select additional frames.
对使用设计系统文本样式的文本框架或组件调用
get_design_context
。请用户在Figma中选择包含代表性文本元素的框架——标题、正文、标签——然后读取:
Tool: get_design_context
Input: { "fileKey": "<密钥>", "nodeId": "<选中的文本框架节点ID>" }
从响应中提取每个文本样式的:样式名称、字体族、字体大小、字体粗细、行高和字间距。处理所有文本角色(H1–H6、正文、标签、说明、代码)。如果一个框架中未显示所有角色,请用户选择其他框架。

curl method — Text Styles

curl方法 — 文本样式

Text styles require two curl calls — one to get the style list with node IDs, then one to fetch the actual property values for those nodes. The PAT from Step 1a is already verified, so proceed directly:
bash
curl -H "X-Figma-Token: YOUR_TOKEN" "https://api.figma.com/v1/files/FILE_KEY/styles" -o text-styles-list.json
Then extract the
node_id
values from
text-styles-list.json
, join them with commas, and run:
bash
curl -H "X-Figma-Token: YOUR_TOKEN" "https://api.figma.com/v1/files/FILE_KEY/nodes?ids=NODE_IDS" -o text-styles-nodes.json
From
text-styles-nodes.json
, extract for each text style: font family, font size, font weight, line height, letter spacing, and any text decoration or text transform applied.
Ask the user to upload or paste both files into the conversation once the commands complete.
文本样式需要两次curl调用——一次获取带有节点ID的样式列表,一次获取这些节点的实际属性值。步骤1a中的PAT已验证,可直接继续:
bash
curl -H "X-Figma-Token: YOUR_TOKEN" "https://api.figma.com/v1/files/FILE_KEY/styles" -o text-styles-list.json
然后从
text-styles-list.json
中提取
node_id
值,用逗号分隔,再运行:
bash
curl -H "X-Figma-Token: YOUR_TOKEN" "https://api.figma.com/v1/files/FILE_KEY/nodes?ids=NODE_IDS" -o text-styles-nodes.json
text-styles-nodes.json
中提取每个文本样式的:字体族、字体大小、字体粗细、行高、字间距,以及应用的任何文本装饰或文本转换。
命令完成后,请用户将两个文件上传或粘贴到对话中。

Merging text styles into the token file

将文本样式合并到令牌文件中

Text styles merge into the
typography
section of
design-tokens.json
. Mark them with
"source": "textStyle"
to distinguish from variable-based typography tokens:
json
"typography": {
  "fontFamilyHeading": { "value": "Titillium Web", "figmaName": "Font/Heading", "type": "STRING", "source": "variable" },
  "h1Size":            { "value": 36,  "unit": "px", "figmaName": "H1/Size",    "type": "FLOAT",  "source": "variable" },
  "h1":  {
    "figmaName": "Heading/H1",
    "source": "textStyle",
    "fontFamily":    "Titillium Web",
    "fontSize":      36,
    "fontWeight":    600,
    "lineHeight":    54,
    "letterSpacing": 0
  },
  "bodyDefault": {
    "figmaName": "Body/Default",
    "source": "textStyle",
    "fontFamily":    "Inter",
    "fontSize":      14,
    "fontWeight":    400,
    "lineHeight":    22,
    "letterSpacing": 0
  }
}
If the design system defines typography entirely through text styles (and has no typography variables), the
source: "variable"
entries won't exist — that's fine, text styles alone are sufficient.

文本样式合并到
design-tokens.json
typography
部分。标记
"source": "textStyle"
以区分基于变量的排版令牌:
json
"typography": {
  "fontFamilyHeading": { "value": "Titillium Web", "figmaName": "Font/Heading", "type": "STRING", "source": "variable" },
  "h1Size":            { "value": 36,  "unit": "px", "figmaName": "H1/Size",    "type": "FLOAT",  "source": "variable" },
  "h1":  {
    "figmaName": "Heading/H1",
    "source": "textStyle",
    "fontFamily":    "Titillium Web",
    "fontSize":      36,
    "fontWeight":    600,
    "lineHeight":    54,
    "letterSpacing": 0
  },
  "bodyDefault": {
    "figmaName": "Body/Default",
    "source": "textStyle",
    "fontFamily":    "Inter",
    "fontSize":      14,
    "fontWeight":    400,
    "lineHeight":    22,
    "letterSpacing": 0
  }
}
如果设计系统完全通过文本样式定义排版(没有排版变量),则
source: "variable"
条目不会存在——这没问题,仅文本样式就足够了。

Step 3 — Review the Raw Output

步骤3 — 审查原始输出

Whichever method was used, review the raw token data with the user before applying naming conventions:
  • All files extracted: Confirm every file the user mentioned has been extracted. Do not proceed if any are missing.
  • Collections present: Do the collection names match what the user expects from each file?
  • Modes captured: If multi-mode, confirm all modes appear with correct values.
  • Color values: Spot-check a few hex values against the Figma file.
  • Alias resolution: Semantic tokens that reference primitives should have resolved values. If an alias could not be resolved, it almost certainly means the referenced primitive lives in a file that hasn't been extracted yet — go back and extract that file before continuing.
  • Missing collections: If something expected is absent, ask the user which Figma file it lives in and add it to the inventory.

无论使用哪种方法,在应用命名约定之前,请与用户一起审查原始令牌数据:
  • **所有文件已提取:**确认用户提及的每个文件都已提取。如果有缺失,请不要继续。
  • **集合存在:**集合名称是否与用户对每个文件的预期一致?
  • **模式已捕获:**如果是多模式,请确认所有模式都显示正确的值。
  • **颜色值:**抽查几个十六进制值与Figma文件是否一致。
  • **别名解析:**引用基础令牌的语义令牌应具有解析后的值。如果别名无法解析,几乎可以肯定意味着引用的基础令牌存在于尚未提取的文件中——返回并提取该文件后再继续。
  • **缺失的集合:**如果预期内容缺失,请用户说明它存在于哪个Figma文件中,并添加到清单中。

Step 4 — Map Token Types and Apply Naming Conventions

步骤4 — 映射令牌类型并应用命名约定

Before generating any QML, read
references/token-mapping.md
to determine the correct QML type for each Figma variable type (COLOR →
color
, FLOAT →
int
or
real
, STRING →
string
, etc.). Apply this mapping consistently across all generated files.
Ask the user if they have an existing naming convention. If not, use the Qt Design Studio convention below and confirm:
Token typeConventionExample
Primitive colors
{family}_{scale}
neutral_900
,
neon_500
Primitive groupsnested
QtObject
per family
Primitives.neutrals.neutral_900
Semantic colors
{role}_{variant}
background_default
,
text_muted
Semantic groupsflat on Theme singleton
Theme.background_default
Semantic variants
_default
/
_muted
/
_subtle
stroke_strong
,
stroke_muted
,
stroke_subtle
Notification tokens
notification_{type}_{variant}
notification_alert_default
,
notification_danger_muted
Spacing steps
x{multiplier}
x4
(= 8 px),
x8
(= 16 px)
Corner radii
radius_{size}
radius_s
,
radius_m
,
radius_full
Font loadersdescriptive component name
interFont
,
titilliumSemiBold
,
inconsolata
Icon names
{icon_name}_{size}
close_16
,
settings_fill_16
All names use
snake_case
. The original Figma name is always preserved in a
figmaName
field in
design-tokens.json
.
JSON vs QML naming: These conventions apply to the generated QML output.
design-tokens.json
stores token keys in camelCase (e.g.
backgroundPrimary
,
cornerRadiusM
) for JSON compatibility — the conversion to snake_case happens when generating QML in Step 6.

在生成任何QML之前,请先阅读
references/token-mapping.md
,以确定每个Figma变量类型对应的正确QML类型(COLOR →
color
,FLOAT →
int
real
,STRING →
string
等)。在所有生成的文件中一致应用此映射。
询问用户是否有现有的命名约定。如果没有,请使用以下Qt Design Studio约定并确认:
令牌类型约定示例
基础颜色
{family}_{scale}
neutral_900
,
neon_500
基础组每个族嵌套
QtObject
Primitives.neutrals.neutral_900
语义颜色
{role}_{variant}
background_default
,
text_muted
语义组平级在Theme单例上
Theme.background_default
语义变体
_default
/
_muted
/
_subtle
stroke_strong
,
stroke_muted
,
stroke_subtle
通知令牌
notification_{type}_{variant}
notification_alert_default
,
notification_danger_muted
间距步长
x{multiplier}
x4
(= 8 px),
x8
(= 16 px)
圆角
radius_{size}
radius_s
,
radius_m
,
radius_full
字体加载器描述性组件名称
interFont
,
titilliumSemiBold
,
inconsolata
图标名称
{icon_name}_{size}
close_16
,
settings_fill_16
所有名称使用
snake_case
。原始Figma名称始终保留在
design-tokens.json
figmaName
字段中。
**JSON与QML命名:**这些约定适用于生成的QML输出。
design-tokens.json
使用camelCase存储令牌键(例如
backgroundPrimary
,
cornerRadiusM
)以兼容JSON——在步骤6生成QML时转换为snake_case。

Step 5 — Write design-tokens.json

步骤5 — 编写design-tokens.json

Write a single merged
design-tokens.json
combining all extracted files. Primitive tokens and semantic tokens from separate Figma files are kept in distinct sections — this preserves the two-tier structure and makes it clear which layer each token belongs to. Single-mode tokens use a flat
value
field; multi-mode tokens nest values under
modes
:
json
{
  "meta": {
    "extractedAt": "<ISO 8601 timestamp>",
    "namingConvention": "camelCase (JSON) / snake_case (QML)",
    "extractionMethod": "MCP | curl",
    "sources": [
      { "figmaFileName": "Global Tokens", "url": "<Figma URL>", "tier": "primitive" },
      { "figmaFileName": "Design Tokens", "url": "<Figma URL>", "tier": "semantic"  }
    ]
  },

  "_comment_primitives": "Raw values from the Global Tokens file — the building blocks",
  "colors": {
    "neutral000": { "value": "#ffffff", "figmaName": "Neutral/000", "type": "COLOR" },
    "neon600":    { "value": "#1f9b5d", "figmaName": "Neon/600",    "type": "COLOR" }
  },

  "_comment_semantic": "Semantic values from the Design Tokens file — reference primitives via resolvedFrom",
  "semanticColors": {
    "backgroundPrimary": {
      "figmaName": "Background/Primary", "type": "COLOR",
      "resolvedFrom": "neutral000",
      "modes": {
        "Light": { "value": "#ffffff" },
        "Dark":  { "value": "#181818" }
      }
    }
  },
  "typography": {
    "fontFamilyHeading": { "value": "Titillium Web", "figmaName": "Font/Heading", "type": "STRING" },
    "h1Size":            { "value": 36, "unit": "px", "figmaName": "H1/Size",      "type": "FLOAT" },
    "h1Weight":          { "value": 600,               "figmaName": "H1/Weight",    "type": "FLOAT" },
    "h1LineHeight":      { "value": 54, "unit": "px", "figmaName": "H1/LineHeight", "type": "FLOAT" }
  },
  "spacing": {
    "x4": { "value": 8,  "unit": "px", "figmaName": "Spacing/X4", "type": "FLOAT" },
    "x8": { "value": 16, "unit": "px", "figmaName": "Spacing/X8", "type": "FLOAT" }
  },
  "radii": {
    "cornerRadiusS":    { "value": 4,    "unit": "px", "figmaName": "Radius/Small", "type": "FLOAT" },
    "cornerRadiusFull": { "value": 9999, "unit": "px", "figmaName": "Radius/Full",  "type": "FLOAT" }
  },
  "shadows": {
    "shadowLow": {
      "offsetX": 0, "offsetY": 1, "blur": 3, "spread": 0,
      "color": "rgba(0,0,0,0.12)", "figmaName": "Shadow/Low"
    }
  }
}
Save to the root of the design system project folder. Confirm the path with the user.

编写单个合并的
design-tokens.json
,整合所有提取的文件。来自不同Figma文件的基础令牌和语义令牌保存在不同的部分——这样保留了两层结构,并明确每个令牌所属的层级。单模式令牌使用扁平的
value
字段;多模式令牌在
modes
下嵌套值:
json
{
  "meta": {
    "extractedAt": "<ISO 8601时间戳>",
    "namingConvention": "camelCase (JSON) / snake_case (QML)",
    "extractionMethod": "MCP | curl",
    "sources": [
      { "figmaFileName": "Global Tokens", "url": "<Figma URL>", "tier": "primitive" },
      { "figmaFileName": "Design Tokens", "url": "<Figma URL>", "tier": "semantic"  }
    ]
  },

  "_comment_primitives": "来自Global Tokens文件的原始值——构建块",
  "colors": {
    "neutral000": { "value": "#ffffff", "figmaName": "Neutral/000", "type": "COLOR" },
    "neon600":    { "value": "#1f9b5d", "figmaName": "Neon/600",    "type": "COLOR" }
  },

  "_comment_semantic": "来自Design Tokens文件的语义值——通过resolvedFrom引用基础令牌",
  "semanticColors": {
    "backgroundPrimary": {
      "figmaName": "Background/Primary", "type": "COLOR",
      "resolvedFrom": "neutral000",
      "modes": {
        "Light": { "value": "#ffffff" },
        "Dark":  { "value": "#181818" }
      }
    }
  },
  "typography": {
    "fontFamilyHeading": { "value": "Titillium Web", "figmaName": "Font/Heading", "type": "STRING" },
    "h1Size":            { "value": 36, "unit": "px", "figmaName": "H1/Size",      "type": "FLOAT" },
    "h1Weight":          { "value": 600,               "figmaName": "H1/Weight",    "type": "FLOAT" },
    "h1LineHeight":      { "value": 54, "unit": "px", "figmaName": "H1/LineHeight", "type": "FLOAT" }
  },
  "spacing": {
    "x4": { "value": 8,  "unit": "px", "figmaName": "Spacing/X4", "type": "FLOAT" },
    "x8": { "value": 16, "unit": "px", "figmaName": "Spacing/X8", "type": "FLOAT" }
  },
  "radii": {
    "cornerRadiusS":    { "value": 4,    "unit": "px", "figmaName": "Radius/Small", "type": "FLOAT" },
    "cornerRadiusFull": { "value": 9999, "unit": "px", "figmaName": "Radius/Full",  "type": "FLOAT" }
  },
  "shadows": {
    "shadowLow": {
      "offsetX": 0, "offsetY": 1, "blur": 3, "spread": 0,
      "color": "rgba(0,0,0,0.12)", "figmaName": "Shadow/Low"
    }
  }
}
保存到设计系统项目文件夹的根目录。与用户确认路径。

Step 6 — Generate QML Files

步骤6 — 生成QML文件

Using the completed
design-tokens.json
as the source of truth, generate QML singleton files. Place all files in a
design-system/
folder at the root of the Qt project.
以完成的
design-tokens.json
为数据源,生成QML单例文件。将所有文件放置在Qt项目根目录的
design-system/
文件夹中。

Read the asset templates first

先读取资产模板

Before writing any QML, read the asset file that matches each output file. These are the authoritative templates — they define the exact structure, naming, grouping, and section order to follow:
Output fileExample to readWhat it shows
Primitives.qml
examples/Primitives.qml
Nested
QtObject
per color family,
{family}_{scale}
naming
Theme.qml
examples/Theme.qml
Flat semantic tokens referencing Primitives, grouped by role
Spacing.qml
examples/Spacing.qml
x{n}
spacing steps,
radius_{size}
corner radii
FontInterface.qml
examples/FontInterface.qml
Inline
component
font loaders,
Icons
QtObject with unicode mappings
Typography.qml
examples/Typography.qml
Font weight constants and type scale size/weight pairs
Read each asset file immediately before generating that file — do not rely on memory of a previously read asset.
在编写任何QML之前,请读取与每个输出文件匹配的资产文件。这些是权威模板——它们定义了要遵循的确切结构、命名、分组和章节顺序:
输出文件参考示例说明
Primitives.qml
examples/Primitives.qml
按族嵌套
QtObject
{family}_{scale}
命名
Theme.qml
examples/Theme.qml
平级语义令牌引用Primitives,按角色分组
Spacing.qml
examples/Spacing.qml
x{n}
间距步长,
radius_{size}
圆角
FontInterface.qml
examples/FontInterface.qml
内联
component
字体加载器,带Unicode映射的
Icons
QtObject
Typography.qml
examples/Typography.qml
字体粗细常量和类型比例大小/粗细对
在生成每个文件之前立即读取对应的资产文件——不要依赖之前读取的记忆。

Folder structure

文件夹结构

design-system/
├── Primitives.qml      ← raw color palette (nested by family: neutrals, accents)
├── Theme.qml           ← semantic color tokens (references Primitives)
├── Spacing.qml         ← spacing steps and corner radii
└── FontInterface.qml   ← font loaders + icon unicode index
Generate in this order: Primitives first (it has no dependencies), then Spacing and FontInterface (independent), then Theme last (it references Primitives).
No hand-written qmldir. Module registration is handled by
qt_add_qml_module()
in CMakeLists.txt. Singleton registration uses
set_source_files_properties
— updated in Step 7.
design-system/
├── Primitives.qml      ← 原始调色板(按族嵌套:中性色、强调色)
├── Theme.qml           ← 语义颜色令牌(引用Primitives)
├── Spacing.qml         ← 间距步长和圆角
└── FontInterface.qml   ← 字体加载器+图标Unicode索引
按以下顺序生成:先Primitives(无依赖),然后Spacing和FontInterface(独立),最后Theme(引用Primitives)。
**无需手动编写qmldir。**模块注册由CMakeLists.txt中的
qt_add_qml_module()
处理。单例注册使用
set_source_files_properties
——在步骤7中更新。

Generation rules

生成规则

  • Every value comes from
    design-tokens.json
    — never hardcode values not in the token file
  • Use
    snake_case
    throughout —
    background_default
    ,
    neutral_900
    ,
    x4
    ,
    radius_m
  • Primitives.qml
    holds raw values only — no semantic meaning.
    Theme.qml
    holds semantic tokens only — always referencing
    Primitives
    , never raw hex values
  • Apply type mapping from
    references/token-mapping.md
    readonly property color
    for colors,
    readonly property int
    for sizes,
    readonly property string
    for font names
  • Include the source comment and CMake note at the top of every file
  • Group related properties with section comments (
    // ── Section name ─────
    )
  • If a token is missing from the JSON, leave a
    // TODO: <figmaName>
    placeholder rather than guessing a value
  • Imports: Use
    import QtQuick
    import QtQuick.Window
    is redundant in Qt 6 (Window is already included) but not an error if added
  • Effects and gradients: Use
    MultiEffect
    from
    import QtQuick.Effects
    (available from Qt 6.5). Never use
    Qt5Compat.GraphicalEffects
    — it requires an extra compatibility module and is not available in all Qt 6 configurations
  • QML coding skill: If the
    qt-development-skills:qt-qml
    skill is available, use it when generating QML files to ensure correct Qt 6 patterns are applied

  • 所有值均来自
    design-tokens.json
    ——切勿硬编码令牌文件中没有的值
  • 全程使用
    snake_case
    ——
    background_default
    ,
    neutral_900
    ,
    x4
    ,
    radius_m
  • Primitives.qml
    仅保存原始值——无语义含义。
    Theme.qml
    仅保存语义令牌——始终引用
    Primitives
    ,而非原始十六进制值
  • 应用
    references/token-mapping.md
    中的类型映射——颜色使用
    readonly property color
    ,尺寸使用
    readonly property int
    ,字体名称使用
    readonly property string
  • 在每个文件顶部包含源注释和CMake说明
  • 使用章节注释对相关属性分组(
    // ── 章节名称 ─────
  • 如果JSON中缺少令牌,请留下
    // TODO: <figmaName>
    占位符,而非猜测值
  • **导入:**使用
    import QtQuick
    ——在Qt 6中
    import QtQuick.Window
    是多余的(Window已包含在QtQuick中),但添加也不会出错
  • **效果和渐变:**使用
    import QtQuick.Effects
    中的
    MultiEffect
    (Qt 6.5起可用)。切勿使用
    Qt5Compat.GraphicalEffects
    ——它需要额外的兼容模块,并非在所有Qt 6配置中都可用
  • **QML编码技能:**如果
    qt-development-skills:qt-qml
    技能可用,生成QML文件时请使用它,以确保应用正确的Qt 6模式

Step 7 — Review, Fix QML, and Update CMakeLists.txt

步骤7 — 审查、修复QML并更新CMakeLists.txt

After generating all QML files, run a validation pass — do not skip any of these checks:
QML validation:
  • Check for any
    // TODO:
    placeholders — flag these to the user and ask how to resolve them
  • Verify every property type matches the
    references/token-mapping.md
    rules
  • Confirm
    pragma Singleton
    and
    import QtQuick
    are present in every file
  • Check that no values are hardcoded that should come from the token file
CMakeLists.txt — mandatory update:
Always update
CMakeLists.txt
as part of this step — do not leave it to the user. Open the file, find the
qt_add_qml_module()
block, and ensure all generated design-system files are listed under
QML_FILES
and registered with
set_source_files_properties
. This is the most common cause of singletons not being accessible in QML.
Naming rule: The target name, URI, and
loadFromModule()
call in
main.cpp
must all use the same project name string. Use the actual project name from the
project()
CMake call — do not substitute
MyProject
literally.
cmake
cmake_minimum_required(VERSION 3.16)
project(<ProjectName> VERSION 0.1 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
生成所有QML文件后,运行验证检查——请勿跳过任何一项:
QML验证:
  • 检查所有
    // TODO:
    占位符——向用户标记这些并询问如何解决
  • 验证每个属性类型是否符合
    references/token-mapping.md
    规则
  • 确认每个文件中都存在
    pragma Singleton
    import QtQuick
  • 检查不应来自令牌文件的值是否被硬编码
CMakeLists.txt — 强制更新:
务必在此步骤中更新
CMakeLists.txt
——不要留给用户处理。打开文件,找到
qt_add_qml_module()
块,确保所有生成的design-system文件都列在
QML_FILES
下,并使用
set_source_files_properties
注册。这是单例在QML中无法访问的最常见原因。
命名规则:目标名称、URI和
main.cpp
中的
loadFromModule()
调用必须使用
相同
的项目名字符串。使用
project()
CMake调用中的实际项目名称——不要字面替换
MyProject
cmake
cmake_minimum_required(VERSION 3.16)
project(<ProjectName> VERSION 0.1 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

Version pin must match qt_standard_project_setup REQUIRES below

版本固定必须与下面的qt_standard_project_setup REQUIRES匹配

find_package(Qt6 6.5 REQUIRED COMPONENTS Quick) qt_standard_project_setup(REQUIRES 6.5)
find_package(Qt6 6.5 REQUIRED COMPONENTS Quick) qt_standard_project_setup(REQUIRES 6.5)

MACOSX_BUNDLE is required on macOS — without it, qt_add_qml_module creates

macOS上必须使用MACOSX_BUNDLE——否则qt_add_qml_module会创建名为<ProjectName>/的目录,与链接器输出文件冲突(EISDIR错误)。MACOSX_BUNDLE会生成MyQtApp.app,无冲突。

a directory named <ProjectName>/ which collides with the linker output file

(EISDIR error). MACOSX_BUNDLE makes the output MyQtApp.app, no collision.

qt_add_executable(<ProjectName> MACOSX_BUNDLE main.cpp )
set_source_files_properties( design-system/Primitives.qml design-system/Theme.qml design-system/Spacing.qml design-system/FontInterface.qml PROPERTIES QT_QML_SINGLETON_TYPE TRUE )
qt_add_qml_module(<ProjectName> URI <ProjectName> VERSION 1.0 QML_FILES Main.qml # capital M — must match loadFromModule("<ProjectName>", "Main") design-system/Primitives.qml design-system/Theme.qml design-system/Spacing.qml design-system/FontInterface.qml # NOTE: do NOT add main.cpp here — it belongs only in qt_add_executable() )
target_link_libraries(<ProjectName> PRIVATE Qt6::Quick)

Replace every `<ProjectName>` with the same string — e.g. `MyQtApp` — matching the `project()` call and the `loadFromModule("<ProjectName>", "Main")` call in `main.cpp`.

After updating CMakeLists.txt, confirm with the user that the file has been saved and show them how to use the singletons in `Main.qml`:

```qml
import QtQuick         // Window is part of QtQuick in Qt 6 — do NOT add import QtQuick.Window
import <ProjectName>   // imports all singletons from the module

Window {
    visible: true
    width: 640
    height: 480
    color: Theme.background_default
}
CMake issues: If the user has build errors after updating CMakeLists.txt, suggest the user check Qt's CMake documentation at https://doc.qt.io/qt-6/cmake-get-started.html rather than troubleshooting inline.

qt_add_executable(<ProjectName> MACOSX_BUNDLE main.cpp )
set_source_files_properties( design-system/Primitives.qml design-system/Theme.qml design-system/Spacing.qml design-system/FontInterface.qml PROPERTIES QT_QML_SINGLETON_TYPE TRUE )
qt_add_qml_module(<ProjectName> URI <ProjectName> VERSION 1.0 QML_FILES Main.qml # 首字母大写M — 必须与loadFromModule("<ProjectName>", "Main")匹配 design-system/Primitives.qml design-system/Theme.qml design-system/Spacing.qml design-system/FontInterface.qml # 注意:不要在此处添加main.cpp — 它仅属于qt_add_executable() )
target_link_libraries(<ProjectName> PRIVATE Qt6::Quick)

将所有`<ProjectName>`替换为相同的字符串——例如`MyQtApp`——与`project()`调用和`main.cpp`中的`loadFromModule("<ProjectName>", "Main")`调用匹配。

更新CMakeLists.txt后,请与用户确认文件已保存,并向他们展示如何在`Main.qml`中使用单例:

```qml
import QtQuick         // 在Qt 6中Window属于QtQuick — 请勿添加import QtQuick.Window
import <ProjectName>   // 导入模块中的所有单例

Window {
    visible: true
    width: 640
    height: 480
    color: Theme.background_default
}
**CMake问题:**如果用户更新CMakeLists.txt后出现构建错误,请建议用户查看Qt的CMake文档:https://doc.qt.io/qt-6/cmake-get-started.html,而非在线排查问题。

Step 8 — Summary

步骤8 — 总结

Give the user a brief summary and ask them to review the output:
  • Total tokens extracted per category (colors, spacing, typography, radii)
  • Modes and themes captured
  • Any unresolved aliases or
    // TODO:
    placeholders that need attention
  • Files produced:
    design-tokens.json
    ,
    Primitives.qml
    ,
    Theme.qml
    ,
    Spacing.qml
    ,
    FontInterface.qml
  • Reminder that
    set_source_files_properties(... QT_QML_SINGLETON_TYPE TRUE)
    must be set in CMakeLists.txt for each singleton file
  • Use the Token Categories Checklist at the end of this file to verify nothing was missed
  • Confirmation that the design system foundation is ready — the component generation skill can now begin

向用户提供简要总结并请他们审查输出:
  • 每个类别提取的令牌总数(颜色、间距、排版、圆角)
  • 捕获的模式和主题
  • 任何未解析的别名或需要处理的
    // TODO:
    占位符
  • 生成的文件:
    design-tokens.json
    ,
    Primitives.qml
    ,
    Theme.qml
    ,
    Spacing.qml
    ,
    FontInterface.qml
  • 提醒每个单例文件必须在CMakeLists.txt中设置
    set_source_files_properties(... QT_QML_SINGLETON_TYPE TRUE)
  • 使用本文末尾的令牌类别检查表验证是否有遗漏
  • 确认设计系统基础已准备就绪——现在可以开始组件生成技能

Token Categories Checklist

令牌类别检查表

  • Primitive color palette (all color families and scales)
  • Semantic color tokens with all modes (if present)
  • Font families (heading, body, mono)
  • Font weights (numeric: 400/500/600/700)
  • Type scale from variables (size + weight + line height per role, if defined as variables)
  • Text styles (H1–H6, body, label, caption, code — font family, size, weight, line height, letter spacing)
  • Spacing scale (base unit + all named steps)
  • Corner radii (S, M, L, Full)
  • Shadows / elevation levels (if present)
  • Icon size tokens (if present)
  • Animation / duration tokens (if present)
  • 基础调色板(所有颜色族和刻度)
  • 带所有模式的语义颜色令牌(如果存在)
  • 字体族(标题、正文等)
  • 字体粗细(数值:400/500/600/700)
  • 来自变量的类型比例(每个角色的大小+粗细+行高,如果定义为变量)
  • 文本样式(H1–H6、正文、标签、说明、代码——字体族、大小、粗细、行高、字间距)
  • 间距比例(基础单位+所有命名步长)
  • 圆角(S、M、L、全圆角)
  • 阴影/海拔级别(如果存在)
  • 图标大小令牌(如果存在)
  • 动画/持续时间令牌(如果存在)