使用文档

Agent-Friendly Figma 设计提取 CLI

快速上手

30 秒快速配置

$ npm install -g @nova-infra/d2c-cli
$ # 从 figma.com/developers 获取 Token
$ echo 'export FIGMA_TOKEN=figd_your_token_here' >> ~/.zshrc && source ~/.zshrc
$ nova-d2c doctor

工作流程

典型 D2C 工作流程:

nova-d2c explore
nova-d2c get
nova-d2c get --only
nova-d2c images

命令参考

nova-d2c doctor

开始前检查环境配置。验证 Token、API 连通性和缓存状态。

nova-d2c doctor

nova-d2c explore <figma-url>

分析文件结构并输出推荐节点与后续建议命令。

nova-d2c explore "https://www.figma.com/design/xxx"

nova-d2c get <figma-url> [options]

提取设计数据。不带 --node-id 时列出页面和顶层 Frame。

nova-d2c get "https://www.figma.com/design/xxx" --node-id 1:2
nova-d2c get "https://www.figma.com/design/xxx" --node-id 1:2 --only components
nova-d2c get "https://www.figma.com/design/xxx" --node-id 1:2 --resolved

nova-d2c images <figma-url> [options]

从指定节点导出图片资源。

nova-d2c images "https://www.figma.com/design/xxx" \
  --node-id 1:2,3:4 \
  --output assets/ \
  --image-format png \
  --scale 2

选项参考

选项 说明
--node-id 1:2,3:4 节点 ID,逗号分隔
--only pages|components|variables|styles|tree|resolved 过滤输出类型
--format yaml|json|md|compact 输出格式(默认 yaml)
--resolved 标志 内联解析后的样式值
--no-cache 标志 跳过缓存,强制重新获取