figma-shaders
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCreate and update Figma shaders
创建和更新 Figma Shader
Load this skill before every or call. It covers account-library shader authoring through the Figma MCP server. Reading or applying an existing shader does not require this skill.
create_shaderupdate_shaderShaders have two kinds:
- samples and transforms the rendered layer beneath it. Use it for blur, distortion, glow, color grading, pixelation, halftone, or other post-processing.
effect - generates pixels without an input raster. Use it for gradients, patterns, noise, textures, and procedural backgrounds.
fill
Do not silently switch kinds during an update. The passed to must match the existing shader.
kindupdate_shader在每次调用 或 前加载此 skill。它介绍了如何通过 Figma MCP server 编写账户库中的 Shader。读取或应用现有 Shader 不需要加载此 skill。
create_shaderupdate_shaderShader 分为两种:
- 对其下方已渲染的图层进行采样和变换。适用于模糊、失真、辉光、色彩分级、像素化、半色调或其他后处理。
effect - 在没有输入栅格图的情况下生成像素。适用于渐变、图案、噪声、纹理和程序化背景。
fill
更新时不要在未说明的情况下切换类型。传给 的 必须与现有 Shader 的类型一致。
update_shaderkindCreate workflow
创建流程
- Decide whether the request is an effect or fill. Ask only when the visual intent does not resolve the distinction.
- Resolve . Reuse one supplied by the user; otherwise call
planKey. Use the sole eligible plan automatically, or ask the user to choose when several materially different plans are available.whoami - Call once with a concise name, description, selected
create_shader, andkind. This creates a starter scaffold, not the requested final shader.planKey - Call with the returned
get_shader, then read every source URI. If the client cannot read MCP resources, callidwithget_shaderinstead. This establishes the runtime imports and the scaffold's fixed metadata contract.includeSource: true - Author the complete replacement for the requested result.
main.ts - Call with the returned
update_shader, the sameid,kind, and a specificfiles: [{ path: "main.ts", content: "..." }]. UsecommitMessagewhen changing the name, description, or animation capabilities. Setmetadatawhen the source reads time-related frame inputs andmetadata.isAnimated: truewhen it readsmetadata.usesMouse: true.frame.mousePosition
Never stop after : the starter scaffold is only a structural starting point.
create_shader- 判断请求属于 effect 还是 fill。仅当视觉意图无法明确区分二者时才询问用户。
- 解析 。如果用户已提供,则直接复用;否则调用
planKey。如果只有一个符合条件的套餐,则自动使用;如果有多个实质不同的套餐,则让用户选择。whoami - 使用简洁的名称、描述、选定的 和
kind调用一次planKey。这只会创建初始脚手架,而不是用户要求的最终 Shader。create_shader - 使用返回的 调用
id,然后读取每个源 URI。如果客户端无法读取 MCP resources,则改用get_shader调用includeSource: true。这用于确定运行时导入项以及脚手架固定的元数据契约。get_shader - 针对预期结果编写完整的替换版 。
main.ts - 使用返回的 、相同的
id、kind和具体的files: [{ path: "main.ts", content: "..." }]调用commitMessage。更改名称、描述或动画能力时,使用update_shader。如果源代码读取与时间相关的帧输入,则设置metadata;如果源代码读取metadata.isAnimated: true,则设置frame.mousePosition。metadata.usesMouse: true
绝不能在 后停止:初始脚手架只是结构性起点。
create_shaderUpdate workflow
更新流程
- Identify the shader with , then call
list_shaders. Use itsget_shader(typeoreffect) as the required update kind.fill - Read every source URI returned by before editing. If the client cannot read MCP resources, call it with
get_shader. Treat those files as the current source of truth.includeSource: true - Preserve existing controls and behavior unless the user asks to change them.
- Call with the complete replacement
update_shaderin themain.tsarray, not a diff or partial fragment. An emptyfilesarray is valid only for a metadata-only update.files
- 使用 查找目标 Shader,然后调用
list_shaders。使用其get_shader(type或effect)作为更新时必须使用的 kind。fill - 编辑前读取 返回的每个源 URI。如果客户端无法读取 MCP resources,则使用
get_shader调用。将这些文件视为当前源代码依据。includeSource: true - 除非用户要求更改,否则保留现有控件和行为。
- 调用 时,在
update_shader数组中提供完整的替换版files,而不是差异片段或不完整片段。只有仅更新元数据时,才可以将main.ts数组设为空。files
Authoring rules
编写规则
- Before writing the replacement, read Shader source authoring. It contains the required module shape, WebGPU lifecycle, supported parameter schemas, effect/fill alpha rules, and WGSL failure checklist.
main.ts - Match animation metadata to the source. Set if
metadata.isAnimated: truereadsmain.ts,frame.time, orframe.deltaTime, and setframe.frameif it readsmetadata.usesMouse: true. Set the corresponding value toframe.mousePositionwhen removing the last such use.falseapplies these metadata fields to the fixedupdate_shadermanifest even though that file cannot be replaced directly.features.json - Prefer for animation so skipped frames do not change the result. It is an absolute millisecond clock; convert it to seconds with
frame.timewhen useful.Number(frame.time) * 0.001 - Expose controls for values users are likely to tune per layer; hardcode implementation details.
- Keep numeric ranges bounded and defaults visually useful.
- For effects, sample the input raster intentionally. For fills, do not assume an input raster exists.
- Treat a non-error result as success. Record the returned version when present; a successful response may omit it.
update_shader - On a build error, use the returned compiler output to make the smallest source correction and retry once. If it still fails, surface the error instead of repeatedly rewriting the shader.
- If the tool reports that animation or mouse input is unavailable, treat that as a terminal capability gate: do not retry or attempt to bypass it. Offer to author a static shader whose exposed properties can be keyframed in Motion mode instead.
- 编写替换版 前,读取 Shader 源代码编写。其中包含必需的模块结构、WebGPU 生命周期、受支持的参数 schema、effect/fill alpha 规则和 WGSL 失败检查清单。
main.ts - 使动画元数据与源代码保持一致。如果 读取
main.ts、frame.time或frame.deltaTime,则设置frame.frame;如果读取metadata.isAnimated: true,则设置frame.mousePosition。移除最后一次相关使用时,将对应值设为metadata.usesMouse: true。即使无法直接替换false,features.json仍会将这些元数据字段应用到固定的update_shader清单中。features.json - 动画优先使用 ,这样跳过帧也不会改变结果。它是一个绝对毫秒时钟;如有需要,使用
frame.time转换为秒。Number(frame.time) * 0.001 - 为用户可能按图层调整的值提供控件;实现细节则使用硬编码。
- 限定数值范围,并确保默认值在视觉上实用。
- 对于 effect,应有意识地采样输入栅格图;对于 fill,不要假定存在输入栅格图。
- 将非错误的 结果视为成功。如果返回了 version,则记录下来;成功响应可能不会包含该字段。
update_shader - 出现构建错误时,根据返回的编译器输出进行最小幅度的源代码修正,并重试一次。如果仍然失败,则报告错误,不要反复重写 Shader。
- 如果工具报告动画或鼠标输入不可用,将其视为不可绕过的能力边界:不要重试,也不要尝试绕过。此时可以改为提供静态 Shader,其公开属性可在 Motion mode 中设置关键帧。
Completion
完成
Report the shader name, kind, and id, plus the returned version when present. Briefly identify the controls or behavior that were added. Construct and include a clickable URL that opens a new Design file with the unpublished shader ready to try, using the exact shader id as . Set from the shader kind: for an effect and for a fill.
try-tool-resource-content-idtry-tool-resource-typegen_effectgen_fillhttps://www.figma.com/file/new?try-tool-resource-content-id=<id>&try-tool-resource-type=<gen_effect|gen_fill>&type=design&mode=designAfter presenting the new-file link, ask whether the user wants to open the shader in an existing Figma Design file instead. If yes, reuse a file URL already provided or ask for one, then add the same and resolved query parameters to that URL. Never guess the file URL.
try-tool-resource-content-idtry-tool-resource-typeReplace the type placeholder with exactly one value; do not include angle brackets or the pipe in the returned URL.
报告 Shader 名称、kind 和 id,并在存在时报告返回的 version。简要说明新增了哪些控件或行为。构建并包含一个可点击 URL,用于打开新的 Design file,其中未发布的 Shader 已准备好供试用。将准确的 Shader id 用作 。根据 Shader kind 设置 :effect 对应 ,fill 对应 。
try-tool-resource-content-idtry-tool-resource-typegen_effectgen_fillhttps://www.figma.com/file/new?try-tool-resource-content-id=<id>&try-tool-resource-type=<gen_effect|gen_fill>&type=design&mode=design展示新文件链接后,询问用户是否希望改为在现有 Figma Design file 中打开该 Shader。如果用户同意,复用已提供的文件 URL 或向用户索要一个,然后将相同的 和解析后的 查询参数添加到该 URL。绝不猜测文件 URL。
try-tool-resource-content-idtry-tool-resource-type将类型占位符替换为且仅替换为一个实际值;返回的 URL 中不得包含尖括号或竖线。