
designfit
io.github.as9978v0.2.1更新於 Oct 3, 2026
Validate AI-built front-ends against Figma by tokens and geometry, not pixels.
概覽
以設計權杖與元素幾何、而非像素比對,驗證 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。手動安裝時,還需把隨附的技能檔案複製到代理的技能目錄。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 designfit,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
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.
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:
Then once, to fetch the browser the measurement engine drives:
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:
Windows: some MCP clients can't spawn a bare
designfit(it resolves todesignfit.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 thenpxform, 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_extracttakes a Figma link ({ url }), or{ fileKey, nodeId }, or a pastedGET /v1/files/:key/nodesbody ({ nodes }), plus optionalmaxDepth, and returns{ design, componentMap, viewport }. Fetching needsFIGMA_TOKENin the MCP server's environment. Hidden nodes are skipped and a frame made only of vectors is one leaf.designfit_validatetakes{ 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- v0.2.1最新Oct 3, 2026


