Build interfaces with AI

How an AI assistant builds UI screens in Arc-Tech over MCP, with layers, auto layout, components, tokens, and checking by picture.

Read as Markdown

The steps

  1. create_design with kind ui, or get_ui_design to read what's there: its screens first, then a screen's layers.
  2. edit_ui_design with the screens and layers. Everything in one call is saved together or not at all.
  3. render_screen, look, fix, and look again.

A working example

This makes a device screen with auto layout, a colour token and a text style. add_layers is applied before operations.

{
  "design_id": "<design id>",
  "add_layers": [
    { "id": "device", "type": "artboard", "name": "Device", "x": 0, "y": 0, "w": 393, "h": 852, "fill": "#FFFFFF" },
    { "id": "form", "type": "group", "name": "Form", "parentId": "device", "x": 24, "y": 240, "w": 345, "h": 200,
      "layout": { "direction": "column", "gap": 16, "align": "stretch", "hug": "height" } },
    { "id": "title", "type": "text", "name": "Title", "parentId": "form", "x": 24, "y": 240, "w": 345, "h": 36,
      "text": "node-0412", "fontSize": 28, "fontWeight": 700, "lineHeight": 1.3, "color": "#111827" },
    { "id": "button", "type": "group", "name": "Restart button", "parentId": "form", "x": 24, "y": 292, "w": 345, "h": 48,
      "fill": "#2563EB", "radius": 8,
      "layout": { "direction": "row", "align": "center", "justify": "center", "padding": [14, 16, 14, 16], "hug": "height" } },
    { "id": "button-label", "type": "text", "name": "Label", "parentId": "button", "x": 24, "y": 306, "w": 120, "h": 20,
      "text": "Restart device", "fontSize": 15, "fontWeight": 600, "lineHeight": 1.3, "color": "#FFFFFF", "align": "center" }
  ],
  "operations": [
    { "op": "set_color", "id": "primary", "name": "Primary", "value": "#2563EB" },
    { "op": "update", "id": "button", "fillToken": "primary" },
    { "op": "set_text_style", "id": "heading", "name": "Heading", "fontFamily": "Inter", "fontSize": 28,
      "fontWeight": 700, "lineHeight": 1.3, "letterSpacing": 0 },
    { "op": "apply_text_style", "ids": ["title"], "style_id": "heading" }
  ],
  "reason": "Added the device screen"
}

Then call render_screen with screen_id set to device.

apply_color works on shapes, text and icons. For a group with its own fill, set fillToken on the group with update, as above.

The quality standard

Build UI cleanly, with precise placement; that is the standard here, not a nice-to-have.

  1. Structure: use auto layout ("layout" on groups) for every card, list, row, button, chip, form and toolbar; place only the top-level blocks of a screen by hand.
  2. Spacing: only steps of 4/8 (4, 8, 12, 16, 24, 32, 48, 64), one gap per group, the same padding in cards of the same kind; consistent page margins (16-24 on phones, 32-64 on desktop).
  3. Alignment: blocks share edges on a grid (columns line up; cards in a row have the same width and top); siblings that should line up have exactly the same x or y; centre with align or justify, never by eye; whole pixels only.
  4. Sizing: icons 16, 20 or 24; tap targets at least 44 on phones; text boxes fit their text (nothing clipped, single-line labels never wrap, long text wraps inside its column); one radius per kind of thing (e.g. 8 for controls, 12-16 for cards) and one border colour. Pills, badges, chips, tags and buttons: an auto layout group (align center, justify center) with the same padding left and right, its label set to align "center", so the text sits exactly in the middle on every device; never a label off to one side with more space after it than before.
  5. Consistency: colours from the colour tokens and text from the text styles, no one-off values; real content and real icon layers, never typed symbols.
  6. Contrast and depth: foreground always stands clearly off its background. Body text at least 4.5:1 against what is behind it, large text and icons at least 3:1; muted text is still readable, never faint. Separate surfaces (page, card, raised card, popover) with a slightly different fill plus a light 1px border (on dark UI a few steps lighter than the surface, e.g. #FFFFFF at 6-10% or a token like border-subtle; on light UI a pale grey) and a soft, slight shadow (e.g. y 1-4, blur 8-24, black at 4-12% on light, 20-40% on dark); no heavy borders, no hard dark shadows, and the same border and shadow for every surface of the same level.
  7. Nothing overlaps unless it is meant to (a badge or overlay, with layoutIgnore), and everything stays inside its screen and its card.
  8. Check: after each change, look with render_screen (region for tall pages) and fix anything misaligned, uneven, overlapping, clipped or hard to read before you finish.

Layers, in full

A UI design is layers in paint order (later draws on top; a layer’s children come after it). Layer: {"id", "type": "artboard|rect|ellipse|polygon|line|path|text|image|group|instance|icon", "name", "parentId" (its artboard or group), "x", "y", "w", "h" (absolute canvas pixels), "rotation" (degrees), "opacity" (0-1), "visible", "locked", "fill" (colour or null), "stroke": {"color", "width"} or null, "radius", "shadow": {"x", "y", "blur", "color"} or null, "fillToken" (a colour token id for its fill, or a text’s colour), "strokeToken" (one for its border or line)}. Artboards are screens: "clip"; phone 393x852, 80px apart. Text: "text", "fontSize", "fontWeight" (100-900), "fontFamily" (Inter by default; any Google Fonts family works), "color", "align": left|center|right, "lineHeight", "letterSpacing", "textStyleId"; its h is about fontSize x lineHeight x lines. Image: "src" (the project’s uploads only; leave it out for a placeholder), "fit": cover|contain|fill. Line: drawn corner to corner of its box, "flip" for the other diagonal. Polygon: "sides" (3-24), "star". Path: "points" [{x, y}] as fractions (0-1) of its box, "closed"; or "d", SVG path data (curves and arcs) in the box’s own coordinates (or drawn at "viewBox" [w, h] and scaled to the box). Icon: "icon", a Lucide name (heart, star, map-pin, search, camera…; find_icons searches them), drawn in its box with "stroke" {color, width} (2 by default) and an optional "fill"; colour it with apply_color (it follows the token). Group: "mask" (its topmost layer becomes the visible area), "clip". Auto layout, on a group or artboard: "layout" {direction: row|column, gap, padding: n or [top, right, bottom, left], align: start|center|end|stretch, justify: start|center|end|space-between, hug: true|false|"width"|"height"}: its children are placed in order (their x/y are worked out), text re-fits its width, and with hug the container fits its content; a child with "layoutIgnore": true keeps its own place. Prefer layouts for lists, cards, buttons and stacks: no positions to compute, nothing overlaps. Prototype: an artboard’s "viewport" is its visible height (a taller page scrolls in the preview); a screen’s layer with "fixed": top|bottom stays pinned while it scrolls (a tab bar); "link": a screen id that a tap on the layer opens. Instance: "componentId" of a main component (a group with "component": true), drawn scaled to its box. An instance’s "overrides" {main’s layer id: {text, color, fill, src, visible, opacity}} change what that copy shows (one card component, many venues). Colours: #RGB, #RRGGBB, #RRGGBBAA, rgb()/rgba(), hsl()/hsla() or "transparent". Unknown keys are refused.

Operations, in full

Operations run in order, each {"op": ...}: add {layers, parent_id?, relative?, above_mask?} (relative: x/y from the parent’s top-left; placed above the parent’s other layers, but in a mask group just under its mask, the topmost layer, unless above_mask); update {id, ...fields, relative?}; remove {ids} (what’s inside goes too); move {ids, dx, dy} or {ids, x?, y?, relative?} (what’s inside follows); resize {id, w?, h?, scale_children?}; reorder {ids, to: front|back|forward|backward} or {ids, before|after: layer id} (with what’s inside, among their siblings); duplicate {ids, dx?, dy?, id_prefix?} (a screen goes beside itself by default; answers the new ids); reparent {ids, parent_id or null, above_mask?} (keeps their place on the canvas); align {ids, edge: left|center|right|top|middle|bottom, to?: "selection"|"parent"|layer id}; distribute {ids, axis: horizontal|vertical, gap?} (with gap: stacked that far apart, in their order; without: evenly between the outer two); group {ids, id?, name?, mask?}; ungroup {ids}; make_component {id}; detach {ids} (instances become editable groups, keeping their overrides); override {id, layer, text?, color?, fill?, src?, visible?, opacity?, reset?} (one instance shows different text, colour, image or visibility on a layer of its component; null goes back to the component’s); set_color {id?, name, value} (a token: layers linked to it change with it); remove_color {id}; apply_color {ids, color_id, target?: fill|stroke} (stroke: borders, lines and outlines follow the token; an open path or line is coloured by its stroke); set_text_style {id?, name, fontFamily, fontSize, fontWeight, lineHeight, letterSpacing, color?} (color optional, null removes it; a text linked to a colour token keeps its colour); remove_text_style {id}; apply_text_style {ids, style_id} (re-wraps the text at the new size); settings {background}.