# The .nibs format

Rules agents must respect when editing through `batch_edit` (from the Nib MCP guide).

## batch_edit

Applies all operations atomically and saves the document. If any operation is invalid, none are applied.

```json
{
  "ops": [
    {
      "op": "insert",
      "parentId": null,
      "node": {
        "id": "hero1",
        "type": "frame",
        "name": "Launch Hero",
        "x": 0,
        "y": 0,
        "width": 1440,
        "height": 900,
        "layout": "column",
        "padding": 80,
        "gap": 24,
        "fill": "$surface",
        "children": []
      }
    },
    {
      "op": "insert",
      "parentId": "hero1",
      "node": {
        "id": "title",
        "type": "text",
        "content": "Designed with intent.",
        "font": "Newsreader",
        "size": 88,
        "weight": 600,
        "color": "$text"
      }
    }
  ]
}
```

Supported operations:

- `insert`: `{ op, parentId, index?, node }`. Use `parentId: null` for a top-level node.
- `update`: `{ op, id, props }`. Properties are shallow-merged and revalidated.
- `delete`: `{ op, id }`. Deletes the node and its subtree.
- `move`: `{ op, id, parentId, index? }`. Use `parentId: null` to move to the document root.
- `set_variable`: `{ op, name, value }`.

Important schema rules:

- Every node ID is exactly five characters using letters, digits, `_`, or `-`.
- Top-level nodes require `x` and `y`.
- Nested nodes must not have `x` or `y`; they use their parent frame’s row/column layout.
- Node types are `frame`, `text`, `rect`, `ellipse`, `image`, and `svg`.
- Width and height accept numbers, `fill`, or `hug` where applicable.
- Variables are referenced as `$name` and may contain light/dark values.
- Fills support colors, variables, solid fills, linear/radial gradients, and images.

## Document model (summary)

- Every node `id` is exactly five characters: letters, digits, `_`, or `-`.
- Top-level nodes require `x` and `y`.
- Nested nodes must not have `x` or `y`; they follow the parent frame row/column layout.
- Types: `frame`, `text`, `rect`, `ellipse`, `image`, `svg`.
- Width and height: numbers, `fill`, or `hug` where applicable.
- Variables: `$name`, optional light/dark values.
- Fills: solid, linear/radial gradients, images.

Do not edit `.nibs` on disk while Nib has the file open — use MCP tools.
