sketch-implement-design by sketch-hq/skills
npx skills add https://github.com/sketch-hq/skills --skill sketch-implement-design通过 Sketch MCP 查询实时文档数据,以高视觉保真度从 Sketch 实现 UI。使用 run_code 来检查和导出数据,并使用 get_selection_as_image 作为视觉参考依据。
http://localhost:31126/mcp。get_selection_as_image 之前,在 Sketch 中选择要实现的图层或画板。按顺序执行以下步骤。不要跳过任何步骤。
如果 Sketch MCP 调用失败:
按优先级顺序使用以下方法:
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
https://sketch.com/s/<document-share-uuid>/f/<canvas-frame-uuid>:提取 /f/<canvas-frame-uuid> 值,找到该图层并选中它。优先使用此目标,而不是当前选择或基于名称的匹配。run_code 定位匹配的图层并请求确认。当提供分享链接时,使用 run_code 和 find 函数以及此模式:
const sketch = require('sketch')
const frameId = '4A2E31FF-56BD-4C29-92D2-829548D19C1D'
const frame = find(`#${frameId}`)
if (frame) sketch.getSelectedDocument().selectedLayers = [frame]
当存在多个匹配项时,停止并询问要实现哪个图层。
run_code 获取结构化设计上下文运行 run_code 以收集所选根图层(及相关后代)的设计数据:
始终以以下代码开始脚本:
const sketch = require('sketch')
向 run_code 传递一个简短的 title 参数,并保持脚本精简,除非用户另有要求。
如果输出太大:
get_selection_as_image 捕获视觉参考在同一选中的目标上调用 get_selection_as_image。将此图像用作实现和验证的主要视觉参考。
如果选择为空,停止并请用户在 Sketch 中选择预期的图层/画板。
run_code 导出所需资源从 Sketch 导出图标、位图和其他资源,而不是创建占位符。
规则:
sketch.export,始终同时传递 output 和 filename(带扩展名)。示例:
const sketch=require('sketch');const d=sketch.getSelectedDocument()
const l=d.selectedLayers.layers[0]
sketch.export(l,{
output:'/tmp/sketch-assets',
filename:`${l.id}.png`,
formats:['png']
});console.log('ok')
将 Sketch 数据视为设计意图,然后映射到项目标准:
力求与 Sketch 截图和上下文保持视觉一致性:
根据截图和设计上下文清单验证已实现的 UI:
如果仍存在不匹配,请使用 run_code 重新查询受影响的子树并进行迭代。
get_selection_as_image 返回 Empty selection原因:Sketch 中未选择任何内容。解决方法:请用户选择目标图层/画板,然后重试。
No document原因:没有打开的 Sketch 文档或 Sketch 未运行。解决方法:在 Sketch 中打开文档并重试。
run_code 输出太大或被截断原因:选择树太大。解决方法:首先查询浅层树,然后按子树获取详细上下文。
原因:导出选项无效或输出路径为相对路径。解决方法:使用绝对路径并同时传递 output 和 filename。
原因:上下文捕获不完整或令牌不匹配。解决方法:重新捕获截图并通过 run_code 检查确切的节点值。
每周安装次数
130
仓库
GitHub 星标数
43
首次出现
2026年2月16日
安全审计
安装于
codex122
opencode122
gemini-cli121
github-copilot120
kimi-cli119
amp118
Implement UI from Sketch with high visual fidelity by querying live document data through Sketch MCP. Use run_code to inspect and export data, and get_selection_as_image as the visual source of truth.
http://localhost:31126/mcp.get_selection_as_image.Follow these steps in order. Do not skip steps.
If Sketch MCP calls fail:
Use these approaches in priority order:
https://sketch.com/s/<document-share-uuid>/f/<canvas-frame-uuid>: extract the /f/<canvas-frame-uuid> value, find that layer, and select it. Prefer this target over current selection or name-based matching.run_code to locate matching layers and ask for confirmation.Use run_code with the find function and this pattern when a share link is provided:
const sketch = require('sketch')
const frameId = '4A2E31FF-56BD-4C29-92D2-829548D19C1D'
const frame = find(`#${frameId}`)
if (frame) sketch.getSelectedDocument().selectedLayers = [frame]
When multiple matches exist, stop and ask which layer to implement.
run_codeRun run_code to collect design data for the selected root layer (and relevant descendants):
Always start scripts with:
const sketch = require('sketch')
Pass a short title argument to run_code and keep scripts minified unless the user asks otherwise.
If output is too large:
get_selection_as_imageCall get_selection_as_image on the same selected target. Use this image as the primary visual reference for implementation and validation.
If selection is empty, stop and ask the user to select the intended layer/frame in Sketch.
run_codeExport icons, bitmaps, and other assets from Sketch instead of inventing placeholders.
Rules:
sketch.export, always pass both output and filename (with extension).Example:
const sketch=require('sketch');const d=sketch.getSelectedDocument()
const l=d.selectedLayers.layers[0]
sketch.export(l,{
output:'/tmp/sketch-assets',
filename:`${l.id}.png`,
formats:['png']
});console.log('ok')
Treat Sketch data as design intent, then map to project standards:
Aim for visual parity with the Sketch screenshot and context:
Validate implemented UI against the screenshot and design context checklist:
If mismatch remains, re-query with run_code for the affected subtree and iterate.
Empty selection from get_selection_as_imageCause: Nothing selected in Sketch. Fix: Ask the user to select the target layer/frame, then retry.
No document from MCP toolsCause: No open Sketch document or Sketch not running. Fix: Open the document in Sketch and retry.
run_code output is too large or truncatedCause: Selection tree is too large. Fix: Query shallow tree first, then fetch detailed context by subtree.
Cause: Invalid export options or relative output path. Fix: Use absolute paths and pass both output and filename.
Cause: Incomplete context capture or token mismatch. Fix: Re-capture screenshot and inspect exact node values via run_code.
Weekly Installs
130
Repository
GitHub Stars
43
First Seen
Feb 16, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
codex122
opencode122
gemini-cli121
github-copilot120
kimi-cli119
amp118
shadcn/ui 框架:React 组件库与 UI 设计系统,Tailwind CSS 最佳实践
65,300 周安装
Git Flow 分支创建器 - AI 智能分析 Git 变更,自动创建语义化分支
7,900 周安装
Spring Boot Java项目创建指南:一键生成多数据库集成模板(含Docker配置)
7,900 周安装
GitHub Copilot ADR生成器 - 自动创建架构决策记录文档工具
7,900 周安装
图像转视频工具:使用AI模型将静态图片动画化,支持风景、人像、产品等场景
8,000 周安装
VS Code 扩展命令贡献指南:为扩展添加、更新命令与侧边栏集成
7,900 周安装
DevOps上线计划生成器 - 自动化生产环境变更部署与回滚方案
8,000 周安装