# hlix canvas

**`hlix canvas` is how an agent draws a design, a diagram, an architecture or any visual explanation on a project's canvas.** People see the drawing appear at once, marked as hlix's, and can undo it. Hlix Code has the three commands as tools; other agents run them from a terminal.

An agent sees what people marked as **project context** and what hlix drew. People's private work is shown only as empty rectangles, so an agent draws beside it and never reads it. An agent never sets the project context mark.

## Which project

Pass `--project <id>`. Without it, the command uses the project of the current folder. The id can name a project of this device or a cloud project. A project linked to the cloud uses the cloud's canvas, with the same rules and the same attribution as the hosted MCP tools. A project of this device that is not linked has a canvas on this device, and the command reaches it through the open hlix app.

**The app must be open:** For a project of this device that is not linked, the hlix app must be open. With the app closed the command exits `app_closed` and starts nothing. Open the app and run it again.

## `hlix canvas read`

```bash
hlix canvas read [--project <id>] [--json]
```

Answers `revision`, `elements` and `occupied`. `elements` are the shared elements with their ids, kinds, text, positions and sizes. `occupied` are the rectangles of people's private work. Read before you draw.

## `hlix canvas draw`

```bash
hlix canvas draw [--project <id>] (--ops <json> | --ops-file <path>) [--reason <text>] [--json]
```

Draws one batch of ops, applied all or nothing, at most 500. Ops are `create` (an `element`), `update` (an `id` and `set`, only what changes) and `delete` (an `id`).

An element has `id`, `kind` (`frame`, `sticky`, `text`, `shape`, `box`, `arrow`), `x`, `y`, `w`, `h`, `z`, and optionally `text`, `color`, `shape`, `boxType` (`service`, `page`, `component`, `datastore`, `integration`, `actor`), `parentId` (a frame) and, for an arrow, `from`, `to`, `route`.

What you create is placed in free space and marked as hlix's. You may change only what `read` shows you. On a project of this device you may delete only what hlix drew.

In the cloud, a change to what people marked as project context waits as hlix's suggestion until they accept it, unless the project accepts hlix's edits automatically. The answer then says `applied: false`, and `--reason` is the line people read.

Answers `{applied, revision, ops}`. A refused batch exits `canvas_refused` with the reason and changes nothing.

## `hlix canvas undo`

```bash
hlix canvas undo [--project <id>] [--json]
```

Reverses hlix's newest edit that is not undone yet. Run it again to go further back. People's own edits are never undone. Answers `{undone, revision}`; `undone` is `false` when no edit of hlix's is left. When people changed what the edit touched, so it cannot be reversed cleanly, it exits `canvas_refused` and changes nothing.

## Errors

| Code | Raised when |
| --- | --- |
| `app_closed` | The project is on this device and the hlix app is not open |
| `canvas_refused` | The canvas refused the batch; the message names what an agent may not do |
| `conflict` | On this device, the canvas kept changing while the command tried three times |
| `missing_argument` | No project was named and the folder has none |
| `invalid_usage` | The ops are not one JSON array |