---
title: CLI
description: Every Dex command and its options.
---

Run `npx dex <command>` at or below `dex.config.ts`. `--help` lists commands; `--version` prints the version. The command comes with `@dexhq/canvas`; `npm create dex@latest` runs its `create` before it is installed (flags after `--`), as does `npx @dexhq/canvas create`.

## Set up and maintain

| Command | Does |
| --- | --- |
| `npm create dex@latest [folder]` | In a project (where its `package.json` is), adds a studio in `studio/`; anywhere in a workspace (pnpm, bun, yarn or npm workspaces, Turborepo, Nx), gives it its own app (`apps/studio`) when a shared package holds the components, or puts it inside the app that holds them, with one install and a `studio` script at the root and the agents' configs at the workspace root (`--app <name>` or `--in <package>` to choose); and asks how `DESIGN.md` starts: a draft from the design system (the default), a DESIGN.md in the repository linked as `designSystem.guide`, a file or URL imported, or empty (`--design-md draft\|<path>\|<url>\|none`); in an empty folder, starts a new project from a starter, all shadcn on Base UI (`--template vite` (the default; also `shadcn`): a Vite + React app; `standalone`: the studio on its own, with no app; `turborepo`: `apps/web`, a shared `packages/ui` and the studio in `apps/studio`; asked in a terminal), installs it with `--pm`, else the package manager running `create` (`bunx`, `pnpm dlx`, `yarn dlx`; `npx` says nothing, as everyone has it), else the starter's own (npm, or bun for a Turborepo), and sets the studio up in it the same way, with a first file. It shows what it found and where from, confirms the components, styles, primitives, icon set and agents, shows the plan (every file and command) and asks "Go ahead?", then writes, installs with your package manager and runs `doctor`. Every question has a flag: `--components <folder>\|none` (from where you run it; in a workspace the studio goes where that folder's package says), `--import <specifier>`, `--shadcn`, `--styles <file>\|none`, `--primitives` / `--no-primitives`, `--icons lucide\|phosphor\|hugeicons` (the icon set the interface draws with; default: the one your components use, else Lucide), `--provider <module>\|none` (what wraps every view; for Mantine, Chakra UI and Radix Themes it writes `studio/provider.tsx` by default), `--agent <ids>\|none` (a comma list), `--dir <folder>`, `--pm bun\|pnpm\|yarn\|npm`, `--studio <spec>` (where to install it from instead: `file:./dexhq-canvas-0.2.0.tgz`, or another version, `^0.2.0`), `--skip-install`. `--yes` takes what it finds; without a terminal it does too, printing each choice beside its flag, and exits 2 when nothing found is safe to take, and 1 when the install fails (the files are written). `--dry-run` shows the plan and writes nothing, going on past a choice it can't make with the first; `--json` prints one event per line: each thing it isn't sure of is a `question` (one sentence, and its choices, each with the exact flags that answer it), and each `hint` says what is left to your agent, such as a provider the design system exports or components that aren't React. Run it again with the answers' flags and it asks nothing. Where a studio is set up already (in a workspace, in any of its packages), it plans only what differs from what this version writes, from the choices `dex.config.ts` made first, then flags, then what it finds: `designSystem` facts your project's files say dropped, `ui.icons` and `plugins: [next()]` added, a studio `tsconfig.json` that copies your paths made to extend yours, and a file, agent config or install an earlier run left out. It asks "Go ahead?" (`--yes` takes it, `--dry-run` shows it), keeps the config's other keys, comments and formatting, never touches `DESIGN.md`, `provider.tsx`, `contributors.json` or files, and says what an older setup added to your own `.gitignore` and scripts rather than removing it. A second run changes nothing. `init` is the same, kept for older scripts. See [Design systems](/docs/design-systems). |
| `agents add <agent>` | Adds the studio to `claude`, `codex`, `cursor`, `copilot` or `opencode`, as the studio's "Add MCP config" does. |
| `components [--json] [--components <folder>]` | Lists the design system's components and how to import them. `--components` scans another folder and prints the `designSystem.components` that points at it. |
| `doctor` | Checks the setup; exits with an error on failure. |
| `upgrade [--dry-run]` | Brings a studio set up by an older version up to date, and does nothing when there is nothing to move; the update notice's **Update** runs it after every install: moves `design-system/index.ts` into `designSystem` in `dex.config.ts`, and its prose into `DESIGN.md`; moves snapshots into `.studio/` and deletes the old presence file, leaving one `.gitignore` line for both; removes copied rules nobody edited; and deletes each file's old `explorations/` folder, which nothing reads now (directions are rows of a canvas section). `--dry-run` writes nothing. Exits 2, writing nothing, when the config cannot be edited. See [Upgrading](/docs/upgrading). |

## Run

| Command | Does |
| --- | --- |
| `dev` | Starts the studio at http://localhost:3008, or `port` / `STUDIO_PORT`, showing its version, address and a newer Dex when npm has one. When the port is taken by anything but this project's Dex (another checkout's, say), it moves on to the next free port and says what holds the first; with `STUDIO_PORT` set, as the installed app sets it, it keeps to that port and stops instead. When this project's own Dex is already running, it says where. With `--live`, a linked studio also goes live (`cloud live`). |
| `build` | Checks, then builds a read-only static site to `outDir`: browse, play, share, and read the comments as they are when it builds (`build.comments: false` leaves them out). Pictures every view on the canvases for the canvas to show when zoomed out, when Playwright's Chromium is installed (`build.pictures: false` skips them). |
| `preview` | Serves the build. |
| `extension` | Prints where the Snapshot browser extension is and how to install it. See [Snapshots](/docs/snapshots). |
| `stop` | Stops this project's (this checkout's) Dex, wherever it runs, and no other. |
| `app install` | On a Mac, makes `~/Applications/Dex.app`, as **Desktop app…** in the menu under your name does, and replaces the `Dex · <project>.app` an earlier Dex made. Opening it starts `dev` when the studio isn't running (its output goes to `~/Library/Logs/Dex/<project>.log`), then opens the studio in a window of its own. It also answers the project's own link, `dex-<id>://start`, which the "Dex isn't running" page offers as Start Dex. It keeps up with updates and a new Node by itself: `dev` writes its launcher again as it starts. Run `app install` again after moving the project or changing its port. |
| `app remove` | Removes that app, and only an app Dex made. |

## Work

Usually run by your agent. A file is named by its folder, `files/<slug>/`: `--slug <file>` is the slug. A person is `--person <slug>`; `--owner` still works for it.

| Command | Does |
| --- | --- |
| `whoami` | Who you are, from your GitHub account or git user, added as a contributor the first time. |
| `new --title "<title>" [--person <slug>] [--description "<question>"]` | Creates a file, with its first view and canvas, made by you, or with `--person` by another contributor. Its folder is a new id. Without a title it says "Name the file." |
| `contributor --name "<name>" --git "<git user>" --discipline product\|brand\|engineering` | Adds a contributor and folder. |
| `threads [--slug <file>] [--all]` | Threads waiting for an agent, as JSON; `--all` for every thread. |
| `thread --id <id> [--note "<reply>"] [--acknowledge \| --resolve \| --dismiss] [--agent "<name>"]` | Replies, changes status, or both. |
| `check` | Validates files, canvases and references, and resolves every view's imports as `build` does (the project's aliases and `baseUrl`, each package's exports), so it fails on an import `build` would. |
| `scope --person <slug> [--base main]` | Changes that person may not make: anything outside their `people/<slug>/` folders and files' shared parts. |
| `presence --slug <file> --view <view> [--agent "<name>"] [--clear]` | Shows which view an agent is editing. Claude Code's hook does this. |
| `snapshot --slug <file> [--view <view>]` | Snapshots every frame (or one view's), light and dark, as the MCP server's `snapshot` tool does, and lists console errors and overflow. Needs the studio running and Playwright. |

## Cloud workspaces

[Team plan](/docs/cloud-workspaces). `--url` defaults to https://cloud.dexhq.dev; change it to [self-host](/docs/self-hosting).

| Command | Does |
| --- | --- |
| `cloud login --token <token> [--url <service url>]` | Stores a token in your user config. |
| `cloud link --workspace <slug> [--url <service url>]` | Writes `studio.cloud.json`. |
| `cloud status` | Workspace, account and plan. |
| `cloud push` | Copies the threads in each file's `comments.jsonl` to the workspace. Safe to rerun. |
| `cloud live` | Mirrors the workspace's [live files](/docs/live-workspaces) to disk both ways, while it runs. |
| `cloud publish` | Builds, with the canvases' pictures as `build` makes them, uploads and prints the link. See [Publishing](/docs/publishing). |
| `cloud unlink` | Removes `studio.cloud.json`. |

## Agents and environment

| Name | Does |
| --- | --- |
| `claude [...]` | Claude Code, with studio feedback arriving in the session as it is posted (a channel). Other options go to `claude`. |
| `mcp [--agent "<name>"]` | The [MCP server](/docs/mcp), over stdio. |
| `hook` | Claude Code hook for guidelines and presence. `create` adds it to `.claude/settings.json`. |
| `STUDIO_PORT` | Port for `dev` and `preview`. |
| `STUDIO_CLOUD_TOKEN` | Token that overrides `cloud login`, for CI and agents. |
| `DEX_NO_UPDATE_CHECK` | Set to anything to stop `dev` asking npm, as it starts and once a day after, whether a newer Dex is out. It never asks in CI. |
