---
name: koi-figcraft-screen
description: Designs or redesigns a product screen in FigCraft through the figcraft MCP, then measures it instead of eyeballing it. Reads the current file and an existing section pattern, draws in batch steps (one undo each), dumps the layer tree, runs scripts/measure.mjs for grid, keylines, sibling gaps, near-miss edges, padding and text contrast, fixes every violation, screenshots light and dark, and checks koi-design-laws before calling it done. Never saves the file without asking. Use for "desenha no FigCraft", "redesign this screen in FigCraft", "mede o grid desse frame", "check alignment of this frame".
---

# koi-figcraft-screen

Draw in FigCraft, then prove the result with numbers. This skill owns the *how* in FigCraft; `koi-design-laws` owns *whether it is correct*.

## Before drawing

1. Read `koi-design-laws/SKILL.md` and, for a redesign, run its `reference/checklist.md` on the current frame first (baseline).
2. `mcp__figcraft__inspect_document` on the file. Find:
   - the target frame (or where the new one goes, next to its siblings on the same page);
   - one **existing section pattern** to copy (same product, same kind of screen, e.g. "Suppliers · list · light"). Record from it: frame width, content keylines (left/right x of the content column, e.g. `240,1200`), header height, section gaps, card radius, text styles, fills;
   - local styles, variables and components (`list_commands` with filter `style`, `variable`, `component`). Use them; never invent a hex or size that a style/variable already covers.
3. Write a short layout plan in chat: regions top to bottom, grid (columns, gutter, keylines), primary action, states to draw (default, loading, empty, error, plus stale when data syncs). Name which design laws drive each choice (ids like `L1`, `G10`, `T7`).

## Drawing

- Coordinates: x right, y **down**, page units = px. `create_node` / `set_properties` take x/y relative to the parent; `absoluteBounds` from `inspect_document` are page coordinates.
- Prefer auto layout frames (`layout`, `gap`, `padding`, `mainAlign`, `crossAlign`, `sizingH`/`sizingV`) for anything that stacks; children of auto layout are positioned by it, so set spacing there, never by x/y.
- Every x, y, width, height, gap and padding is a multiple of 4 (R1). Section gap > group gap >= 1.5x item gap (G10).
- One logical step per `mcp__figcraft__batch` call (header, filters bar, table, side panel...), so each step is one undo.
- Name layers by role (`Header`, `Filters`, `Table/Row/Cell-Price`), not `Frame 12`. The measurement uses names to skip chrome (`sidebar`, `nav`, `overlay`, `bg`).
- Numbers: tabular figures, right-aligned columns, locale format (`R$ 1.234,56`) per T7/T12.
- Draw each required state as its own frame: `<Screen> · <state> · <light|dark>`.

## Measuring (mandatory after every drawing step that changes layout)

1. Dump the frame: `mcp__figcraft__get_node` (or `inspect_document`) for the frame id. Save the JSON to a scratch file. The script accepts the raw node JSON or the MCP envelope.
2. Run, from this skill's folder:

   ```
   node scripts/measure.mjs <dump.json> --frame <id> --content <left,right> [--grid 4]
   ```

   Options: `--allow <regex>` layers allowed outside keylines (default covers sidebar/nav/topbar/overlay/bg), `--skip <regex>` layers to ignore, `--ignore-text-height` when text boxes use auto height, `--json` for machine output. Exit `0` clean, `1` violations, `2` bad input.
3. Checks it runs: `grid` (off-grid position/size), `keyline` (outside content column), `gaps` (unequal sibling gaps), `nearMiss` (left edges 1-3px apart), `contrast` (text vs composited backdrop, WCAG 4.5/3:1), `padding` (asymmetric container padding).
4. Fix every violation with `set_properties` or a new `batch`, then re-dump and re-run until it prints `PASS`. A deliberate exception (optical nudge, intentional bleed) is logged in the report with its reason, never silently left.
5. What the script cannot see, check by hand from the dump and the checklist: hierarchy and focal point (L1/L17, squint test on the screenshot), color roles (C5/C6), type scale (T1/T2), states (I4), copy (B6).

## Verifying visually

- `mcp__figcraft__screenshot` of each frame. Look for focal point, grouping and anything the numbers missed.
- Dark mode: duplicate or switch variable mode, re-run the contrast check and screenshot again (C11). Dark is not inverted light.

## Delivering

- Report with the template in `koi-design-laws/reference/checklist.md`: hard floor, violations `[SEV] RULE-ID | element | measured | expected | fix`, totals, verdict. Include the final `measure.mjs` output.
- List the frames created/changed with their ids.
- **Never call `save_file` without asking.** Ask once at the end: save now, or leave unsaved for review.
- Use `undo` to back out a step that went wrong instead of piling corrections on top.

## Tests

`node --test scripts/__tests__/measure.test.mjs` (Node >= 20, no dependencies).
