designfit

io.github.as9978v0.2.1更新于 Oct 3, 2026

Validate AI-built front-ends against Figma by tokens and geometry, not pixels.

已验证STDIO仅桌面Developer ToolsMedia & Design

概览

AI 生成的概览

用设计令牌和元素几何而非像素比对,校验 AI 构建的前端是否符合 Figma 设计稿。

功能
designfit 提供两个工具。designfit_extract 可通过链接、文件 key 与节点 ID,或粘贴的 nodes JSON 读取 Figma 画板,返回设计、组件映射和视口信息。designfit_validate 将渲染后的实现与该设计比对,返回是否通过、评分、违规项和未映射元素。它按显式容差比较设计令牌和相对屏幕根节点的元素盒子,因此结果是确定性的,而非基于像素。
适用场景
当智能体正在实现某个 Figma 画板,而你希望得到可机器处理的修复清单,而不是永不收敛的截图比对循环时,可以使用它。它适合对真实画板做单视口的保真度检查;响应式多断点和感知类检查不在当前版本内。
运行要求
以 stdio 方式在本地运行,从 npm 包 designfit 安装(或作为 Claude Code 插件安装)。需要 Node.js,并通过 npx playwright install chromium 安装 Chromium 浏览器。抓取画板需要在环境变量 FIGMA_TOKEN 中提供 Figma 个人访问令牌;没有令牌时,extract 可接受粘贴的 nodes JSON。手动安装时,还需将随附的技能文件复制到智能体的技能目录。
安装前请注意
Figma 个人访问令牌 FIGMA_TOKEN 是从服务器环境读取的机密,可访问 Figma 内容。该服务器会驱动浏览器渲染并测量实现,技能流程还要求智能体为元素添加 data-designfit-id 标记并在结束后移除,因此会在循环中修改源文件。在 Windows 上部分客户端无法直接启动该命令,需使用文档给出的 npx 或绝对路径形式。

安装

在 SourceWeft 中

  1. 打开 控制台中的 designfit,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

designfit

Validate AI-built front-ends against their Figma design — without the screenshot-diff thrash.

https://github.com/user-attachments/assets/01df52c9-90eb-4abc-b56c-fe18b31076cd

A real run on a 360-node Figma frame: designfit_extract reads the frame from its link, then designfit_validate scores three build iterations, 87 to 89 to 100 pass. No screenshot diffing anywhere in it.

designfit is an MCP server + Claude Code skill that checks a rendered implementation against its Figma design and hands the coding agent a machine-actionable fix-list. It compares design tokens and geometry (element boxes relative to the screen root) — not raw pixels — so font-rendering noise never makes the agent oscillate. Deterministic in, deterministic out.

[CI]

Why geometry, not pixels

Screenshot-diffing an AI-built UI against a Figma frame thrashes: anti-aliasing and sub-pixel shifts read as "still wrong," so the agent fixes forever. designfit compares what a designer actually catches — wrong colors, wrong sizes, misalignment, missing elements — as deterministic measurements with explicit tolerances. Same input, same output, no oscillation.

Install

Claude Code — as a plugin:

/plugin marketplace add as9978/designfit/plugin install designfit@designfit

Then once, to fetch the browser the measurement engine drives:

bash
npx playwright install chromium

The plugin registers the designfit_extract and designfit_validate MCP tools and the designfit-fidelity-loop skill together, and asks once for a Figma personal access token (optional: without it, extract accepts pasted /nodes JSON).

Any other MCP client — manually:

bash
npm install -g designfitnpx playwright install chromium
json
{ "mcpServers": { "designfit": { "command": "designfit", "env": { "FIGMA_TOKEN": "<token>" } } } }

Windows: some MCP clients can't spawn a bare designfit (it resolves to designfit.cmd). Use { "command": "npx", "args": ["-y", "designfit"] }, or point at the binary directly with { "command": "node", "args": ["<absolute-path>/node_modules/designfit/dist/index.js"] }. The plugin install above already uses the npx form, so it isn't affected.

Use

Ask your agent to implement a Figma frame and give it the frame's link. The designfit-fidelity-loop skill drives: designfit_extract → build → tag elements with data-designfit-id → designfit_validate → fix → repeat until pass → strip the tags.

If you installed the plugin, the skill is already registered. On a manual install it isn't: skills aren't auto-loaded from an npm dependency, so copy the one that ships at skill/SKILL.md into your agent's skills directory (for Claude Code: .claude/skills/designfit-fidelity-loop/SKILL.md) so it can be discovered.

Two tools:

  • designfit_extract takes a Figma link ({ url }), or { fileKey, nodeId }, or a pasted GET /v1/files/:key/nodes body ({ nodes }), plus optional maxDepth, and returns { design, componentMap, viewport }. Fetching needs FIGMA_TOKEN in the MCP server's environment. Hidden nodes are skipped and a frame made only of vectors is one leaf.
  • designfit_validate takes { url, viewport, design, componentMap, tolerances? } and returns { pass, score, violations, unmapped }.

For a full walkthrough on a real Figma frame — the loop, a copy-paste prompt, and troubleshooting — see docs/validating-a-figma-frame.md.

v1 scope

One viewport. Token + geometry + presence checks. Responsive multi-breakpoint and a perceptual VLM fallback are on the roadmap, not in v1.

License

MIT

来源:README.md,提交 5f0992e

工具

0
工具元数据尚未被收录。

版本历史

1
  1. v0.2.1最新Oct 3, 2026