# `PhiaUiDesign.Mcp.BatchDesign`
[🔗](https://github.com/charlenopires/PhiaUI/blob/v0.1.17/lib/phiaui_design/mcp/batch_design.ex#L1)

Execute multiple design operations atomically with bindings and rollback.

Parses a JSON-based DSL of operations (Insert, Copy, Update, Replace,
Move, Delete) and executes them sequentially against the scene ETS.
If any operation fails, the entire batch is rolled back to the pre-execution
snapshot.

## Operations

| Op  | Action  | Required fields                          |
|-----|---------|------------------------------------------|
| `I` | Insert  | `parent`, `data` (type, component/tag)   |
| `C` | Copy    | `id`, `parent`                           |
| `U` | Update  | `id`, `data` (attrs/slots/classes/layout) |
| `R` | Replace | `id`, `data` (new node definition)        |
| `M` | Move    | `id`, `parent`, optional `index`         |
| `D` | Delete  | `id`                                     |

## Bindings

Operations with `"bind"` store the created/resulting node ID.
Subsequent operations can reference `"$binding_name"` in `id` or `parent` fields.

## Limits

Maximum 25 operations per batch (matching OpenPencil convention).

# `execute`

```elixir
@spec execute(reference(), [map()], map()) ::
  {:ok, [map()], map()} | {:error, String.t(), integer()}
```

Execute a batch of operations against the scene.

Returns `{:ok, results, bindings}` on success or `{:error, message, op_index}` on failure.
On failure, the scene is rolled back to its pre-execution state.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
