Skip to main content
Glama
README.md
# drawloop

A live Excalidraw board your coding agent draws on, with a chat beside it.

You edit the drawing by hand and write what you want. The agent receives your message, the shapes it points at, and a list of every edit you made.

![The drawloop board: an architecture diagram on an Excalidraw canvas with a chat panel on the right](docs/board.png)

## How it works

1. The agent calls `draw`. The shapes appear on your board as it draws.
2. You change the board. Drag a box, sketch over it, delete an arrow, or select a shape and press "Note to agent" to write about it.
3. You press Send. The agent's `poll` returns your notes and your edits as plain sentences.
4. The agent updates the same shapes in place and replies in the chat.

Your edits are applied to the board the moment you make them. The agent does not redraw the diagram to pick them up. It reads what changed and continues from there.

This is what the agent gets from one Send:

```json
{
  "status": "feedback",
  "messages": [
    { "text": "Add a read replica next to this", "about": ["ellipse \"Postgres\" (db) at (620, 350)"] }
  ],
  "canvas_edits": [
    "Moved diamond \"Queue\" (queue) by (+10, +50) to (350, 390)",
    "Added rectangle \"Cache\" (k3f9) at (441, 607) 267x167",
    "Deleted arrow (a7)"
  ],
  "next_step": "Apply this feedback with draw and erase. Then call poll again with reply ..."
}
```

## The panel

The panel on the right has three tabs and collapses to a narrow strip with Ctrl+I (Cmd+I on a Mac). The strip still shows new replies, unsent notes and issue counts.

- **Chat.** Notes attach to the shapes you have selected. Queue several, then send them together. Paste or drop an image and the agent receives it as a file. When the agent asks a question it can offer answers as buttons.
- **Issues.** The board checks every change for labels that do not fit, overlapping shapes and arrows that cross a shape. Pick the ones you care about and they become a note. Nothing here reaches the agent until you send it.
- **History.** The board keeps the version from before each round of agent work. Restore one and the agent is told what you undid.

"End the session" in the panel menu makes the agent's `poll` return with an instruction to stop waiting.

## Install

drawloop needs Node 20 or newer.

```sh
git clone https://github.com/amrtawfik160/drawloop
cd drawloop
npm install      # also builds the web app
npm link         # puts `drawloop` on your PATH
```

To run it without cloning, replace `drawloop` with `npx -y github:amrtawfik160/drawloop` in any command below. The first run takes about half a minute while it builds.

## Connect your agent

Use either way. Both drive the same board with the same operations.

### MCP

Claude Code:

```sh
claude mcp add drawloop -- drawloop mcp
```

Any other MCP client:

```json
{
  "mcpServers": {
    "drawloop": { "command": "drawloop", "args": ["mcp"] }
  }
}
```

### CLI and skill

```sh
drawloop install-skill            # copies the skill to .claude/skills/drawloop
drawloop install-skill ~/.codex/skills
```

The skill tells the agent to run `drawloop guide`, which prints the workflow.

Then ask your agent for a diagram: "Draw the architecture of this service on the drawloop board." The board opens at `http://127.0.0.1:4747`.

## Commands

The MCP tools and the CLI commands have the same names and arguments.

| Command | What it does |
| --- | --- |
| `guide` | Prints the workflow and the element format |
| `open [board]` | Opens a board and returns its URL. The board is that `.excalidraw` file |
| `draw` | Adds elements, or changes existing ones by id. `layout` places them automatically |
| `library` | Searches and installs icon libraries from the Excalidraw collection |
| `erase` | Deletes elements by id, or the whole board |
| `look` | Returns the board as text, and as a PNG with `image` (`--out board.png` in the CLI) |
| `mermaid` | Converts Mermaid text into editable shapes |
| `focus` | Scrolls your view to elements |
| `poll` | Waits for your next Send and returns your notes, images and edits |
| `reply` | Posts a message from the agent in the chat. `options` adds answer buttons |
| `export` | Writes the board to a file: a standalone HTML page, SVG or PNG |
| `share` | Creates a link on another service: an Excalidraw link or a public page |
| `checkpoint` | Saves, restores or lists named copies of the board |
| `save` | Writes the board to a `.excalidraw` file |

```sh
drawloop open docs/architecture.excalidraw
drawloop draw '[{"id":"api","type":"rectangle","x":100,"y":100,"label":"API"},
                {"id":"db","type":"ellipse","x":420,"y":100,"label":"Postgres"},
                {"type":"arrow","from":"api","to":"db","label":"SQL"}]'
drawloop poll --reply "Drew the API and its database."
```

## Layout is done for you

An agent placing 50 shapes by coordinates produces clipped labels and arrows through boxes. With `layout`, the agent lists shapes, frames and arrows, and drawloop places them with the ELK layout engine.

```sh
drawloop draw --layout right '[
  {"id":"region","type":"frame","name":"us-east-1"},
  {"id":"clients","type":"rectangle","label":"Clients"},
  {"id":"api","type":"rectangle","label":"API","frameId":"region"},
  {"id":"db","type":"ellipse","label":"PostgreSQL","frameId":"region"},
  {"type":"arrow","from":"clients","to":"api","label":"HTTPS"},
  {"type":"arrow","from":"api","to":"db","label":"SQL"}]'
```

Frames wrap their members, shapes grow to fit their labels, and arrows take right-angle routes. Excalidraw reroutes those arrows when you drag a shape. After every draw the agent also gets warnings for anything that still overlaps or hides a label.

## Icon libraries

The public [Excalidraw library collection](https://libraries.excalidraw.com) has more than 200 libraries: AWS, Azure, Google Cloud, Kubernetes, UML, network gear, people, devices and more. An agent can search it, install a library and draw its icons by name.

```sh
drawloop library top                    # recommended libraries by topic
drawloop library install --topic aws    # every recommended library for a topic
drawloop library search "lambda"
drawloop draw --layout right '[
  {"id":"api","type":"icon","icon":"childishgirl/aws-architecture-icons/API Gateway","label":"Public API"},
  {"id":"fn","type":"icon","icon":"Lambda","label":"Resize images"},
  {"type":"arrow","from":"api","to":"fn","label":"invoke"}]'
```

- `library top` lists 13 topics: aws, google-cloud, azure, kubernetes, system-design, patterns, logos, people, icons, wireframes, charts, uml and data-structures. Every library in it was checked to have named items, so an agent can pick an icon by name.
- `drawloop guide icons` tells the agent when an icon beats a plain shape and how to pick one.
- An icon behaves like a shape. Arrows attach to it, layout places it, and it moves as one piece.
- An installed library also appears in your own Library panel, so you can drag the same icons onto the board.
- Libraries are downloaded from libraries.excalidraw.com on `install` and kept in `~/.drawloop/libraries`. drawloop ships none of them. Each belongs to its author, named in the result of `install`.

## Share and export

Open "Share or export" in the panel menu, or let the agent do it.

| What | Command | Where the drawing goes |
| --- | --- | --- |
| A standalone HTML page with pan and zoom | `drawloop export html` | A file on your machine. It works offline and can be hosted anywhere |
| SVG or PNG | `drawloop export svg` | A file on your machine |
| A link that opens in Excalidraw | `drawloop share excalidraw` | An encrypted copy on excalidraw.com. Anyone with the link can open it and edit their own copy. It cannot be deleted |
| A public view-only page | `drawloop share page` | [ht-ml.app](https://ht-ml.app), a separate hosting service. Anyone with the link can see it |

- `drawloop share page --password <word>` puts the page behind a password.
- Publishing again updates the same address. `drawloop share unpublish` takes the page down.
- The HTML page keeps HTML cards live. A PNG, an SVG and an Excalidraw link show them as empty boxes.
- The agent's guide tells it to run `share` only when you ask for a link.

## Boards are files, and there can be many

`drawloop open docs/architecture.excalidraw` makes that file a board. Every change by you or the agent is saved to it, so the diagram lives in your repo and opens in Excalidraw or the Excalidraw plugin for Obsidian or VS Code.

One server holds any number of boards. Each file has its own URL, its own chat and its own waiting agent, so two agents in two projects never see each other's board.

- An agent's calls go to the board it opened last. `--board <file>` (or `board` over MCP) sends one call to another board.
- The panel menu lists the other open boards.
- `drawloop status` lists every board with its URL.

The chat stays out of the repo, in `~/.drawloop/state`.

## HTML on the canvas

An element of type `html` puts a live web page on the board. Use it for a table, a chart or a UI mockup next to the diagram.

```sh
drawloop draw '[{"type":"html","x":640,"y":100,"width":420,"height":300,
                 "html":"<h2>p95 latency</h2><p>212 ms</p>"}]'
```

The page runs in a sandboxed frame. You can move, resize and annotate it like any shape. Click it once to interact with it.

## Settings

| Variable | Default | Meaning |
| --- | --- | --- |
| `DRAWLOOP_PORT` | `4747` | Port of the board server |
| `DRAWLOOP_HOME` | `~/.drawloop` | Where the default board, the chat and the server log are kept |
| `DRAWLOOP_ALLOWED_HOSTS` | none | Extra hostnames the server answers to, comma separated. Needed behind a reverse proxy or tunnel |
| `DRAWLOOP_URL` | none | The base URL to give the user when it differs from the local one |
| `DRAWLOOP_BOARD` | none | The board an agent uses when it has not opened one |
| `DRAWLOOP_NO_OPEN` | unset | Set to `1` to stop `open` from launching a browser |
| `DRAWLOOP_NO_AUTOSTART` | unset | Set to `1` to stop tools from starting the server |

## Open the board from another device

The server listens on your machine only. To reach it from a phone or another computer on your Tailscale network, proxy it and tell drawloop its outside name:

```sh
tailscale serve --bg --https=4747 http://127.0.0.1:4747
DRAWLOOP_ALLOWED_HOSTS=my-machine.my-tailnet.ts.net \
DRAWLOOP_URL=https://my-machine.my-tailnet.ts.net:4747/ drawloop serve
```

Any reverse proxy works the same way. A request under a hostname that is not in `DRAWLOOP_ALLOWED_HOSTS` is refused.

## Limits

- `look` with an image and `mermaid` need the board open in a browser tab, because Excalidraw does the rendering. `look` as text works with no tab.
- An HTML card shows as a placeholder box in a PNG.
- The server listens on your machine only. It has no accounts and no sharing.
- The network is used only by `library` (libraries.excalidraw.com) and `share` (excalidraw.com or ht-ml.app), and only when one of them is run.
- `export` to HTML, SVG or PNG and `share page` need the board open in a browser tab.

## Credits

drawloop combines two ideas and is built on Excalidraw. See [NOTICE.md](NOTICE.md).

- [lavish-axi](https://github.com/kunchenguid/lavish-axi) for the review loop: a chat beside the work, notes attached to what they are about, and a long poll that hands them to the agent.
- [mcp_excalidraw](https://github.com/yctimlin/mcp_excalidraw) for the live canvas an agent edits element by element.

How the parts fit together is in [docs/architecture.md](docs/architecture.md).

## License

MIT