# CLI and configuration URL: https://protohq.design/docs/cli/ Install @protohq/cli in a React 19 + Vite 8 app, then run proto login, bun run proto init --skills, and bun run proto dev. Pass --app in a monorepo. The… Install `@protohq/cli` in a React 19 + Vite 8 app, then run `proto login`, `bun run proto init --skills`, and `bun run proto dev`. Pass `--app ` in a monorepo. The binary is named `proto`. ## Invocation and account model ```sh proto [positionals] [options] [--json] [--app ] [--verbose] ``` - `--json` prints a single JSON value on stdout. Human output is for people and may change. Exception: `proto mcp --json` writes startup errors to stderr so stdout stays reserved for JSON-RPC. - App selection uses `--app ` (relative to the working directory, or `apps/`). Without it, Proto walks up to the nearest `proto.config.ts`, then tries a single `apps/*/proto.config.ts`. Multiple matches fail with `app_required`. - Unknown flags, missing values, and extra positionals exit `2`. `proto --help` lists commands and `proto --version` prints the installed version. - `--remote` works only on comment commands, review commands, and `proto url`, always paired with `--share `. Free runs locally, including authoring, review, and static builds. Interactive commands (`proto dev`, `proto start`, `proto init`, and `proto mcp`) require a free account (Google, GitHub, or an email link through `proto login`); CI is exempt when `CI` is set to a non-empty value other than `false` or `0`. Headless local commands (`check`, `build`, `stories run`, `migrate`, `stop`, `status`) and Vite/Storybook/Vitest integrations need no login. Stored sessions remain usable offline. When upgrading from `0.1.x`, replace legacy package imports with `@protohq/cli` across every workspace manifest and remove any legacy `remote` block nested under `review` in `proto.config.ts`; run `proto login` instead for hosted review access. ## Shared local address and lifecycle `proto dev` starts Proto in the background when needed and serves every project gallery under one address: ```console $ proto dev Started Proto in the background. Stop it with: proto stop Proto http://127.0.0.1:4400/p/solstice/ Home http://127.0.0.1:4400/ ``` - Ctrl-C stops only the project running in that terminal. Other projects and Proto stay up. - `proto start` and `proto stop` manage the background server idempotently. Stopping Proto leaves project terminals alive and waiting for the next `proto start`; their isolated preview servers remain reachable. - `proto status --json` inspects daemon state, versions, project URLs, and preview origins without starting anything. - `proto dev --json` prints one stdout JSON line and sends later lifecycle updates to stderr. - `PROTOHQ_PORT` chooses Proto's port (default `4400`, remembered between starts). Stop Proto before changing the port (`proto stop`, then `PROTOHQ_PORT=4500 proto start`). - Use `proto url ` for a gallery link and `proto url --bare` for the isolated preview URL after the project's first start. ## Command groups | Group | Commands | | ------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Lifecycle | `proto init`, `proto dev`, `proto start`, `proto stop`, `proto status`, `proto build`, `proto mcp` | | Discovery & checks | `proto list`, `proto check`, `proto url`, `proto flow list`, `proto flow show`, `proto flow coverage` | | Scaffolding & evidence | `proto new`, `proto flow new`, `proto screenshot`, `proto evidence` | | Review store (local or `--remote --share `) | `proto comments list`, `show`, `add`, `reply`, `resolve`, `reopen`, `edit`, `attach`, `detach`, `attachments`, `delete`; `proto review status` | | Human-only review & account | `proto review approve`, `proto review reopen`, `proto review unlock`, `proto login`, `proto logout`, `proto whoami`, `proto workspace list`, `proto workspace use`, `proto share`, `proto migrate` | See the generated [command catalog](/docs/commands/) for the complete CLI and local MCP matrix, and the [CLI skill reference](https://github.com/proto-hq/proto/blob/main/skills/proto/references/cli.md) for detailed JSON response shapes. ## Exit codes and errors | Exit | Meaning | Typical codes | | ---- | ------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | | `0` | Success (warnings allowed) | — | | `1` | Check problems or runtime error | `invalid_config`, `slug_taken`, `comment_not_found`, `port_in_use`, `daemon_unavailable`, `project_offline`, `key_busy` | | `2` | Usage error | Unknown command or flag, missing argument, `app_required` | | `3` | Missing optional peer | `playwright_missing`, missing `@modelcontextprotocol/sdk` | | `4` | Remote or authentication error | `not_logged_in`, `auth_required`, `plan_required`, `seat_required`, `cli_outdated` | Structured errors print `{ "error": { "code", "message" } }` with `--json`. Every code and HTTP status is listed in the [error registry](/docs/errors/). ## Configuration Configuration lives in `proto.config.ts` using `defineProtoConfig` from `@protohq/cli/config`. Every key, type, and default is documented in [Configuration](/docs/configuration/) and mirrored in the [JSON Schema](https://github.com/proto-hq/proto/blob/main/schema/proto-config.schema.json). Because JavaScript functions, regular expressions, and cross-field rules cannot be expressed in JSON Schema, always validate your config with `proto check`. For Vite, Storybook, and Vitest setup see the [setup skill](https://github.com/proto-hq/proto/blob/main/skills/proto/references/setup.md); for prototypes, flows, and canvas patterns see the [authoring skill](https://github.com/proto-hq/proto/blob/main/skills/proto/references/authoring.md). --- # Command catalog URL: https://protohq.design/docs/commands/ Generated from the shipped CLI/local MCP catalog. Generated from the shipped CLI/local MCP catalog. | CLI | Local MCP | Tier | Authority | Exclusion | | --- | --- | --- | --- | --- | | proto login | — | cloud | cloud mutation | Cloud management is CLI-only; agents use the remote MCP | | proto logout | — | cloud | cloud mutation | Cloud management is CLI-only; agents use the remote MCP | | proto whoami | — | cloud | read | Cloud management is CLI-only; agents use the remote MCP | | proto workspace list | — | cloud | read | Cloud management is CLI-only; agents use the remote MCP | | proto workspace use | — | cloud | cloud mutation | Cloud management is CLI-only; agents use the remote MCP | | proto share | — | cloud | cloud mutation | Cloud management is CLI-only; agents use the remote MCP | | proto share list | — | cloud | read | Cloud management is CLI-only; agents use the remote MCP | | proto share invite | — | cloud | cloud mutation | Cloud management is CLI-only; agents use the remote MCP | | proto share revoke | — | cloud | cloud mutation | Cloud management is CLI-only; agents use the remote MCP | | proto list | proto_list | local | read | — | | proto stories list | proto_stories_list | local | read | — | | proto stories run | proto_stories_run | local | read | — | | proto stories url | proto_stories_url | local | read | — | | proto check | proto_check | local | read | — | | proto url | proto_url | local | read | — | | proto flow list | proto_flow_list | local | read | — | | proto flow show | proto_flow_show | local | read | — | | proto flow coverage | proto_flow_coverage | local | read | — | | proto new | proto_new | local | write files | — | | proto flow new | proto_flow_new | local | write files | — | | proto comments list | proto_comments_list | local | read | — | | proto comments show | proto_comments_show | local | read | — | | proto comments add | proto_comments_add | local | comment | — | | proto comments reply | proto_comments_reply | local | comment | — | | proto comments resolve | proto_comments_resolve | local | comment | — | | proto comments reopen | proto_comments_reopen | local | comment | — | | proto comments attach | proto_comments_attach | local | comment (own) | — | | proto comments detach | proto_comments_detach | local | comment (own) | — | | proto comments edit | proto_comments_edit | local | comment (own) | — | | proto comments attachments | proto_comments_attachments | local | read | — | | proto comments delete | proto_comments_delete | local | review session / local | — | | proto review status | proto_review_status | local | read | — | | proto review approve | — | local | review | Agents never approve | | proto review reopen | — | local | review | Agents never approve | | proto review unlock | — | local | local only | Operator recovery for another host's lock | | proto screenshot | proto_screenshot | local | write files | — | | proto evidence | proto_evidence | local | write files | — | | proto init | — | local | read | Process lifecycle | | proto dev | — | local | read | Process lifecycle | | proto build | — | local | read | Process lifecycle | | proto mcp | — | local | read | Process lifecycle | | proto start | — | local | read | Process lifecycle | | proto stop | — | local | read | Process lifecycle | | proto status | — | local | read | Process lifecycle | | proto migrate | — | local | write files | Operator action with interactive verification | --- # Configuration URL: https://protohq.design/docs/configuration/ Proto reads proto.config.ts from your app root using defineProtoConfig from @protohq/cli/config. The table below is generated from protoConfigSchema. Proto reads `proto.config.ts` from your app root using `defineProtoConfig` from `@protohq/cli/config`. The table below is generated from `protoConfigSchema`. | Key | Type | Default | Description | | --------------------------------------------- | ------------------------------------------------------------------------------ | ---------------------- | -------------------------------------------------------------------------------------------------------------- | | `stories.roots[].id` | `string` | _(required)_ | Unique lowercase identifier for a mounted Storybook story root. | | `stories.roots[].title` | `string` | _(optional)_ | Optional display title for the story root in the gallery sidebar. | | `stories.roots[].dir` | `string` | `"."` | Directory for the story root, relative to the app root. | | `stories.roots[].stories` | `string` or `string[]` | _(required)_ | Glob or list of globs locating story files inside `dir`. | | `stories.roots[].preview` | `string` | _(required)_ | Path to the Storybook preview module for this story root. | | `stories.roots[].vite` | `string` | _(required)_ | Path to the Vite config used to render stories in this root. | | `stories.roots[].static[].from` | `string` | _(required)_ | Source directory of static assets served for the story root. | | `stories.roots[].static[].to` | `string` | _(required)_ | Mount path where those static assets are served. | | `stories.roots[].themeGlobal` | `string` | `"theme"` | Storybook global name synchronized with the shell theme toggle. | | `stories.roots[].guards.forbidRuntimeImports` | `(string \| RegExp)[]` | _(optional)_ | Optional per-root list of forbidden runtime import matchers for stories. | | `title` | `string` | _(required)_ | Gallery title shown in the header, browser tab, and project home. | | `prototypes` | `string` or `string[]` | `"src/**/*.proto.tsx"` | Glob or list of globs matching component and draft prototype files. | | `drafts` | `string` | `"src/drafts"` | Directory for free-form exploration drafts inside the prototypes glob. | | `flows` | `string` | `"flows"` | Directory containing `.flow.ts` user-journey definitions. | | `canvas` | `string` | `"proto.canvas.tsx"` | File exporting `Canvas` (providers and CSS) and optional `Frame` chrome. | | `specs` | `Record \| ((root: string) => Record \| null)` | _(optional)_ | Map of `{ id: label }` spec groups, or a Node function returning that map or `null`. | | `roles` | `Record` | `{}` | Map of `{ id: label }` preview roles offered in the shell role picker. | | `siteUrl` | `string` (URL) | _(optional)_ | Origin used to resolve relative paths on external flow nodes. | | `locale` | `"en" \| "pt-BR"` | `"en"` | Gallery shell language (`en` or `pt-BR`). | | `guards.forbidRuntimeImports` | `(string \| RegExp)[]` | `[]` | Module paths, prefixes, globs, package names, or RegExp patterns forbidden in prototypes, drafts, and stories. | | `guards.productionBoundary` | `boolean` | `true` | Fail the production app build when prototype-only modules reach the production bundle. | | `evidence.dir` | `string` | `"docs/design"` | App-relative output directory for `proto screenshot` and `proto evidence` artifacts. | | `build.includeReview` | `boolean` | `false` | Include local review comments and status in static `proto build` output. | | `dev.poll` | `boolean` | `false` | Use a polling file watcher for prototypes and config. | | `dev.allowedHosts` | `string[]` | `[]` | Extra hostnames (without ports) permitted to access this project's gallery URLs. | ## Environment overrides - `PROTOHQ_PORT`: chooses Proto's shared local port (default `4400`, remembered between starts). Stop Proto before changing the port. - `PROTOHQ_POLL=1`: enables polling file watching (`dev.poll`). - `PROTOHQ_TOKEN`: supplies a CLI session token for hosted commands or CI. - `PROTOHQ_WORKSPACE`: selects the active Proto Cloud workspace slug. - `PROTOHQ_API_URL`: overrides the API origin for loopback development or `https://staging-api.protohq.design`. See [CLI and configuration](/docs/cli/), [command catalog](/docs/commands/), and the [JSON Schema](https://github.com/proto-hq/proto/blob/main/schema/proto-config.schema.json). Run `proto check` to validate functions, regular expressions, and cross-field rules that JSON Schema cannot express. --- # Error registry URL: https://protohq.design/docs/errors/ Generated from the shipped registry. A dash means the transport does not assign a code. Generated from the shipped registry. A dash means the transport does not assign a code. | Code | CLI exit | HTTP | Message | | ------------------------ | -------- | ---- | ----------------------------------------------------------------------------------------------------------- | | daemon_unavailable | 1 | — | Proto did not start. See ~/.config/protohq/daemon/daemon.log. | | project_busy | 1 | — | <label> is busy with <command> (pid <n>). Try again when it finishes, or run proto dev to share one server. | | project_offline | 1 | 503 | <label> is not running. Start it with: cd <folder> && proto dev | | project_not_found | — | 404 | No project is registered as <label>. | | origin_not_allowed | — | 403 | Origin not allowed | | state_unavailable | 1 | — | Proto cannot use ~/.config/protohq/daemon: <reason>. | | daemon_version_mismatch | 1 | — | Proto is running a newer version than this project supports. Upgrade @protohq/cli in this project. | | billing_busy | 4 | 409 | A seat change is in progress. Try again. | | billing_update_failed | 4 | 503 | Billing update failed, try again. | | stripe_signature_invalid | — | 400 | Invalid Stripe signature. | | upload_incomplete | 4 | 409 | Some files did not upload. Rerun the command. | | cli_outdated | 4 | 426 | Update @protohq/cli to use Proto Cloud. | | share_not_found | 1 | 404 | No share with that name. | | share_access_denied | 1 | 403 | You do not have access to this share. | | share_paused | 4 | 423 | Paused by the workspace owner. | | share_revoked | 4 | 410 | This share is no longer available. | | share_disabled | 4 | 410 | This share was disabled. | | version_pruned | 1 | 410 | This version is no longer retained. | | seat_required | 4 | 403 | This action needs an Editor seat. | | plan_limit_reached | 4 | 402 | The workspace plan limit was reached. | | snapshot_too_large | 1 | 413 | Snapshots are limited to 50 MB, 5,000 files and 10 MB per file. | | capture_invalid | 1 | 422 | A share thumbnail was refused; publish again with --no-captures. | | device_code_expired | 4 | — | The login code expired. Run proto login again. | | device_code_denied | 4 | — | The login was denied in the browser. | | workspace_slug_taken | — | 409 | That URL is taken. | | workspace_slug_invalid | — | 422 | Use 3–40 lowercase letters, numbers and hyphens. | | workspace_personal | — | 409 | Your personal workspace goes with your account. | | subscription_active | — | 409 | Cancel the subscription in Billing first. | | confirm_mismatch | — | 422 | Type the workspace URL to confirm. | | member_not_found | — | 404 | Pick a member of this workspace. | | deletion_blocked | — | 409 | Resolve the workspace blockers before deleting your account. | | deletion_token_invalid | — | 400 | This link expired. Start again from Account settings. | | legal_required | — | 403 | Accept the current legal documents to continue. | | legal_version_mismatch | — | 409 | The legal documents have changed. Reload and try again. | | legal_unpublished | — | 503 | Sign-up opens soon. | | account_changed | — | 409 | This browser is signed in to another account now. Reload and try again. | | rate_limited | — | 429 | Too many requests. Try again later. | | request_resolved | — | 409 | This access request has already been resolved. | | billing_unavailable | — | 503 | Billing is unavailable. Retry. | | photo_invalid | — | 422 | Use a square image under 512 KB. | | session_current | — | 409 | Use Sign out for this browser. | | workspace_not_found | 1 | 404 | No workspace with that slug. | | forbidden | 4 | 403 | You can't do this in this workspace. | | member_exists | 1 | 409 | This person is already in the workspace. | | last_owner | 1 | 409 | A workspace needs an owner. Transfer ownership first. | | email_unverified | — | 403 | Verify your email before continuing. | | invitation_expired | 1 | 410 | Invitation expired. | | signup_closed | — | 403 | Sign-up on this staging instance is closed for this address. | | plan_required | 4 | 402 | This needs Proto Pro. | | not_found | 1 | 404 | Not found. | | not_logged_in | 4 | 401 | Run proto login to sign in. | | network_unavailable | 4 | — | Can't reach Proto Cloud. Check your connection. | | api_url_refused | 1 | — | PROTOHQ_API_URL must be a loopback URL or https://staging-api.protohq.design. | | share_target_required | 2 | — | Choose one: a slug, --flow <id> or --all. | | share_no_invitees | 2 | — | Invite someone with --approver or --commenter. | | share_dirty_tree | 1 | — | The snapshot contains uncommitted changes. | | share_target_not_found | 1 | — | No prototype or flow with that name. | | storybook_missing | 3 | — | storybook is not installed in <root>; install storybook and @storybook/react-vite. | | storybook_unsupported | 3 | — | Storybook <version> is not supported; proto needs ~10.6.0. | | story_not_found | 1 | 404 | No story matches <id>. | | invalid_input | 2 | 400 | Invalid request input. | | review_has_open_comments | 1 | 409 | Open comments remain; confirm before approving. | | snapshot_stale | — | 409 | A new version is live. Reload to review it. | | internal_error | 1 | 500 | The review operation failed. | | invalid_config | 1 | — | proto.config.ts is invalid. | | not_a_vite_app | 1 | — | No Vite config found; pass --app <dir>. | | app_required | 2 | — | Several apps found; pass --app <dir>. | | port_in_use | 1 | — | Port <port> is used by another program; set PROTOHQ_PORT to move Proto. | | slug_taken | 1 | — | A prototype with this slug already exists. | | comment_not_found | 1 | 404 | Comment not found. | | message_not_owned | 1 | 403 | Only the author can edit this message. | | attachment_too_large | 1 | 413 | Images are limited to 5 MB. | | attachment_type | 1 | 415 | Only PNG, JPEG, WebP or GIF images. | | attachment_limit | 1 | 422 | At most 6 images per message. | | attachment_expired | 1 | 410 | The upload expired; attach it again. | | key_busy | 1 | 409 | The review key is busy; retry. | | cross_origin_write | — | 403 | Writes must come from the gallery's own origin. | | ambiguous_credentials | 4 | 400 | Send a session or a bearer credential, not both. | | auth_required | 4 | 401 | Sign in to review. | | invalid_credential | 4 | 401 | The credential is not valid. | | scope_denied | 4 | 403 | Approval happens in the browser; credentials cannot approve. | | redirect_refused | 4 | — | The remote answered with a redirect; credentials are never re-sent. | | schema_mismatch | — | 503 | The review database schema does not match; apply the server database migrations. | | playwright_missing | 3 | — | Playwright Chromium is not installed. Run: bunx playwright install chromium | | migration_conflict | 1 | — | A target key exists with different content. | | migration_unverified | 1 | — | Migration verification failed. | | migration_source_changed | 1 | — | The source changed during the run; put it in read-only mode, then re-run. | | source_not_read_only | 1 | — | The source accepted a write probe. Set PROTOTYPES_READ_ONLY=1 and drain requests first. | | invalid_source | 1 | 422 | Source paths must stay inside the app's source roots. | | host_not_allowed | — | 403 | Open the gallery at 127.0.0.1 or add the host to dev.allowedHosts. | --- # Getting started URL: https://protohq.design/docs/getting-started/ Install @protohq/cli in a React 19 + Vite 8 application to run the full local prototype gallery and review loop on your machine — free forever, including for… Install `@protohq/cli` in a React 19 + Vite 8 application to run the full local prototype gallery and review loop on your machine — free forever, including for commercial projects. ## Prerequisites - **React 19** and **Vite 8** installed in the target app. Proto compiles prototypes with your app's own Vite config and React installation. - **Node.js 22+** or **Bun** to run the `proto` CLI. - A free Proto account for interactive local commands (`proto dev`, `proto start`, `proto init`, `proto mcp`). Sign in with Google, GitHub, or an email link through `proto login`. CI environments (`CI=1`) and headless commands (`proto check`, `proto build`, `proto status`, `proto stop`, `proto migrate`) do not require login. ## Install and initialize Run these commands inside your app directory (or pass `--app ` from a monorepo root): ```sh bun add -d @protohq/cli bunx proto login bunx proto init --skills bunx proto dev --open ``` `proto init` scaffolds five pieces without altering your production app: - `proto.config.ts` — gallery title, specs, roles, and build/network guards. - `proto.canvas.tsx` — exports `Canvas` (providers and app CSS) and optional `Frame` chrome. - `src/drafts/welcome/index.proto.tsx` — a starter draft you can open immediately. - `proto()` added to your `vite.config.ts` plugins array so prototype code can never leak into your production bundle. - `--skills` installs the `proto` and `proto-apply-comments` skills into `.agents/skills/` at the repository root. Optional peer dependencies are only needed if you use those specific features: | Feature | Optional peer | Setup | | ------------------------------------ | --------------------------------------- | --------------------------------------------------------------- | | Screenshots and HTML evidence | `playwright` (`^1.64.0`) | `bun add -d playwright` then `bunx playwright install chromium` | | Local stdio MCP server (`proto mcp`) | `@modelcontextprotocol/sdk` (`^1.32.2`) | `bun add -d @modelcontextprotocol/sdk` | ## Write your first component prototype Place a `*.proto.tsx` file next to the production view it renders. Export a static `meta` object via `definePrototype` and a default React component that passes fixture props: ```tsx // src/components/stay-checkout.proto.tsx import { definePrototype, setParam, type PrototypeProps } from "@protohq/cli"; import { StayCheckout } from "./stay-checkout"; export const meta = definePrototype({ title: "Stay checkout", spec: "booking", surface: "B1", route: "/stays/casa-mare/checkout", states: [ { id: "ready", label: "Ready" }, { id: "card-error", label: "Card declined" }, { id: "confirmed", label: "Confirmed" }, ], }); export default function Prototype({ state }: PrototypeProps) { return ( setParam("state", "confirmed")} /> ); } ``` Save the file and the gallery updates immediately at `http://127.0.0.1:4400/p/