xd_infer_layout
Proposes auto-layout frames from an exact XD screen export by clustering layers into cards, rows, and columns, deriving spacing/padding, and returning a drift report to compare with original.
Instructions
Phase 2 of a conversion: from the exact export of a screen, propose frames with AUTO-LAYOUT intent. Clusters layers into cards by containment, detects rows/columns and header-style space-between rows, derives item spacing (median gap) and padding (rounded to a grid), marks equal-width cards and full-width text as FILL, keeps illustrations/photos/masked or rotated groups as fixed leaves, puts overlapping decorations in absoluteChildren, turns centred-label rectangles into buttons, and suggests semantic layer names. Leaves reference the exact layers by ref. Returns a drift report (pixelDeltaEstimate, within3px, within5px, elementsAbsolute, elementsAutoLayout) so you know how far the auto-layout version moves things. A heuristic proposal: rebuild it beside the exact copy and compare with xd_render_artboard.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"file": "<file>",
"artboard": "<artboard>"
},
"name": "xd_infer_layout"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file | Yes | Absolute path to a .xd file | |
| grid | No | Round spacing and padding to this grid (px) | |
| nodeId | No | Analyse only this layer | |
| artboard | Yes | Artboard id or name | |
| maxDrift | No | Frames whose auto-layout would move something more than this many px keep exact positions instead (0 = never fall back) | |
| tolerance | No | Pixels within which items count as the same row or column | |
| mergeLoose | No | Merge loose, overlapping vector pieces that were never grouped in XD into one illustration or icon | |
| iconMaxSize | No | A small group up to this many px (no text) is kept as ONE icon | |
| looseMinParts | No | Minimum number of pieces for that merge | |
| illustrationMinParts | No | A group with more vector parts than this is kept as ONE illustration |