.agents/skills/figma-use/references/validation-and-recovery.md
Part of the use_figma skill. How to debug, validate, and recover from errors.
get_metadata vs get_screenshotuse_figmaget_metadata vs get_screenshotAfter each use_figma call, validate results using the right tool for the job. Do NOT reach for get_screenshot every time — it is expensive and should be reserved for visual checks.
get_metadata — Use for intermediate validation (preferred)get_metadata returns an XML tree of node IDs, types, names, positions, and sizes. Use it to confirm:
property=value conventionExample: After creating a ComponentSet with 120 variants, call get_metadata on the
ComponentSet node to verify all 120 children exist with correct names, sizes, and positions
— without waiting for a full render.
When to use get_metadata:
get_screenshot — Use after each major creation milestoneget_screenshot renders a pixel-accurate image. It is the only way to verify visual correctness (colors, typography rendering, effects, variable mode resolution). It is slower and produces large responses, so don't call it after every single use_figma — but do call it after each major milestone to catch visual problems early.
When to use get_screenshot:
What to look for in screenshots — these are the most commonly missed issues:
use_figmause_figma is atomic — failed scripts do not execute. If a script errors, no changes are made to the file. The file remains in exactly the same state as before the call. There are no partial nodes, no orphaned elements, and retrying after a fix is safe.
Recovery steps when use_figma returns an error:
get_metadata or get_screenshot to understand the current file state and confirm nothing has changed.1. use_figma → Create/modify nodes
2. get_metadata → Verify structure, counts, names, positions (fast, cheap)
3. use_figma → Fix any structural issues found
4. get_metadata → Re-verify fixes
5. ... repeat as needed ...
6. get_screenshot → Visual check after each major milestone
⚠️ ON ERROR at any step:
a. Read the error message carefully
b. get_metadata / get_screenshot → If the error is unclear, inspect file state
c. Fix the script based on the error
d. Retry the corrected script (safe — failed scripts don't modify the file)