# The doop CLI

> Design on a Doop canvas from a shell: frames and components as local files, screenshots and exports on disk, for coding agents, scripts and CI.

Source: https://doop.design/docs/cli

Doop from a shell, for coding agents, scripts and CI.

`doop` lets an agent that has a shell (Claude Code, Codex, Cursor) work on a canvas without MCP. Frames and components become local files it edits with its own tools, and screenshots and exports are written to disk, so none of it passes through the agent's context. It works against doop.design and any [self-hosted](https://doop.design/docs/self-hosting) server.

It sits beside [MCP](https://doop.design/docs/get-started) and does not replace it. MCP is the way in for chat clients such as Claude and ChatGPT and for agents without a shell; the CLI is for work that happens inside a repository.

## Install

```sh
$ npm install -g @doop-design/cli
$ doop --version
```

`bun add -g @doop-design/cli` and `pnpm add -g @doop-design/cli` work the same. To run it without installing, which suits CI, use `npx @doop-design/cli` or `bunx @doop-design/cli`. It needs Node 20 or newer and has no dependencies.

Every Doop server also serves the CLI it was built with, as one file. Use that for a [self-hosted](https://doop.design/docs/self-hosting) server (from your own origin), or where no registry is reachable:

```sh
$ curl -fsSL https://doop.design/cli/doop.mjs -o doop && chmod +x doop
$ sudo mv doop /usr/local/bin/
```

## Sign in

The CLI signs in with an **agent key**. Make one under **Settings → Agent keys**, then save it or pass it in the environment:

```sh
$ doop login --key dpk_…
# or, for CI, with nothing written to disk:
$ export DOOP_API_KEY=dpk_…
```

For a self-hosted server, name it: `doop login --server https://your-doop --key dpk_…`, or set `DOOP_SERVER`. A key from the environment is only ever sent to the server you named this way (or to doop.design), never to one that a repository's files point at, so a cloned repository cannot collect it.

## The loop

```sh
$ doop link "Onboarding v2"           # or a canvas id or URL; --create "Name" makes one
$ doop pull                            # frames -> designs/*.html
$ doop push                            # changed files -> the canvas, live
$ doop screenshot designs/hero.html    # prints the path of a PNG
$ doop wait                            # blocks until a person leaves feedback
```

Between `pull` and `push`, the agent edits the HTML files like any other file in the repository. Everyone with the canvas open watches a push land. A new design is a new file:

```sh
$ doop push designs/pricing.html --width 1440 --height 900
```

`doop link` writes `.doop/config.json`, which is meant to be committed so everyone on the repository works on the same canvas.

### Tell your agent about it

Run `doop init` once in a repository. It adds a short block to `AGENTS.md` and, in a repository set up for Claude, a Claude Code skill. Both point the agent at `doop guide`, which explains the loop and Doop's design conventions. After that you can simply ask for a design.

## Conflicts

People edit the same canvas while an agent works. A push carries the version of the frame its file came from, and Doop refuses it if somebody changed the frame's HTML since. The command exits with code 3 and says what to do:

```sh
$ doop diff designs/hero.html            # what differs
$ doop pull designs/hero.html --force    # take the canvas
$ doop push designs/hero.html --force    # take the file
```

A [comment](https://doop.design/docs/collaborate#comments) on an element counts as a change, because it adds an id to the markup that an older file would strip. A frame that was only renamed, moved or approved is not a conflict.

## Components

Each component on the canvas is three files in `designs/components/`: `button.html` is the template, `button.css` its rules and `button.json` its name, description and props. Edit them and push, and every instance on the canvas follows. A new component is a new `.html` there, pushed by path.

In a frame, an instance is a short tag such as `<doop-use component="Button" label="Save">`, so a frame file opened in a browser does not show its components. To see the real page:

```sh
$ doop screenshot designs/hero.html    # a PNG of the frame as it renders
$ doop expand designs/hero.html        # components and tokens written out, in .doop/expanded/
```

The expanded file is for reading and for turning a design into code. To fetch the frames a person marked [ready for dev](https://doop.design/docs/handoff#ready-for-dev) together with their expanded form:

```sh
$ doop pull --ready --expand
```

## Tokens and assets

```sh
$ doop tokens pull --format css -o src/tokens.css
$ doop tokens push tokens.json
$ doop asset upload ./logo.svg          # prints the URL to reference
```

`tokens push` sends only what differs from the canvas, so the same file can be pushed on every merge. See [Design tokens](https://doop.design/docs/tokens) for the formats.

## Waiting for people

`doop wait` blocks until someone leaves feedback or a comment on the canvas, prints it and exits. An agent runs it in the background and is woken when it returns, so it can hand work over for review and pick up the answer without being asked again. It gives up after 30 minutes unless told otherwise with `--timeout`.

## Commands

| Command                  | What it does                                                              |
| ------------------------ | ------------------------------------------------------------------------- |
| login, logout, whoami    | The saved key, and the account and canvas in use                          |
| canvases, link           | List canvases; link this directory to one                                 |
| init                     | Tell the repository's coding agents about Doop                            |
| guide \[topic\]          | How to design in Doop, written for an agent                               |
| frames \[--ready\]       | The frames on the canvas                                                  |
| pull, push, diff         | Frames and components to and from local files                             |
| screenshot, inspect      | A PNG of a frame or component; layout problems as data                    |
| expand                   | A frame as it renders, in a file a browser opens                          |
| export                   | Frames as PNG, JPG or one PDF                                             |
| wait                     | Block until a person leaves feedback or a comment                         |
| status "…"               | Show people what the agent is working on                                  |
| tokens pull, tokens push | Design tokens as JSON, CSS, Tailwind or markdown; push sends only changes |
| asset upload             | Upload images and print their URLs                                        |
| tools, call              | List the MCP tools; run any of them                                       |

`doop <command> --help` shows a command's options, and every command takes `--json` for one JSON document on stdout.

`doop call` reaches every [MCP tool](https://doop.design/docs/get-started#tool-reference) that has no command of its own. Arguments are `key=text`, `key:=json` for a number, boolean or list, and `key@=file` for a file's contents:

```sh
$ doop call search_icons query=arrow
$ doop call reply_to_comment comment_id=abc123 text="Done"
```

### Exit codes

| Code | Meaning                               |
| ---- | ------------------------------------- |
| 0    | Done                                  |
| 1    | Failed                                |
| 2    | Wrong usage                           |
| 3    | Conflict with the canvas              |
| 4    | Not signed in, or the key was refused |
| 5    | Not found                             |
| 6    | doop wait timed out                   |

## In CI

With `DOOP_API_KEY` set as a secret, a workflow can keep tokens and exported assets in step with the canvas:

```sh
$ npx @doop-design/cli tokens push tokens.json
$ npx @doop-design/cli export --all --format png -o public/designs
```

`doop inspect <frame> --fail-on-problems` exits 1 when a frame has content past its edge, clipped text or overlapping elements.

## The HTTP API underneath

Frame HTML travels over three endpoints that a script can call without the CLI. They take an agent key as a bearer token. The HTML is the request or response body, and a frame's version comes back as its `ETag`.

```sh
# read
$ curl -H "Authorization: Bearer $DOOP_API_KEY" \
       https://doop.design/api/v1/frames/FRAME_ID/html

# replace, only while the frame is still at that version
$ curl -X PUT -H "Authorization: Bearer $DOOP_API_KEY" -H 'Content-Type: text/html' \
       -H 'If-Match: "VERSION"' --data-binary @hero.html \
       https://doop.design/api/v1/frames/FRAME_ID/html

# create
$ curl -X POST -H "Authorization: Bearer $DOOP_API_KEY" -H 'Content-Type: text/html' \
       --data-binary @hero.html \
       'https://doop.design/api/v1/canvases/CANVAS_ID/frames?name=Hero&width=1440&height=900'
```

Add `?form=rendered` to a read for the frame as it renders, with components and token values written out. A write answers JSON with the frame and its new version, any warnings (an instance of a component that does not exist, say) and the feedback people left for the agent. Failures are status codes:

| Status | Code         | When                                                                     |
| ------ | ------------ | ------------------------------------------------------------------------ |
| 400    | invalid      | The body is not HTML, a new frame has no name, or If-Match is malformed  |
| 401    | unauthorized | No agent key, or one that was revoked                                    |
| 403    | forbidden    | The account may read the canvas but not change it                        |
| 404    | not\_found   | No such frame or canvas for this account                                 |
| 409    | conflict     | The frame moved past If-Match; the answer carries the frame as it is now |
| 413    | too\_large   | More than 10 MB of HTML                                                  |
| 422    | refused      | The HTML embeds base64 data; upload the file as an asset instead         |
