Docs

CLI

The CLI ships inside the @trymirio/mirio package. Run it with npx @trymirio/mirio <command> before the package is installed, or npx @trymirio/mirio <command> after. Every command accepts --json for machine-readable output on stdout. Errors say what went wrong and what to do next. Exit codes: 0 ok, 1 error, 2 check failed.

Versions. Commands and options newer than 0.2.0 say the version they need, like "(0.2.4)". npx @trymirio/mirio --version prints yours; npx @trymirio/mirio@latest <command> runs the newest without upgrading. Since 0.2.4, an option or command the CLI doesn't know names its version and the newest one it has seen, so an agent following newer docs knows to upgrade.

Configuration: mirio.json at the repo root (projectId, apiUrl, formsDir), secret key in .mirio/secret (gitignored). MIRIO_SECRET_KEY and MIRIO_API_URL override both, which is what CI uses; in a host or CI, MIRIO_SECRET_KEY is a deploy key, which only registers forms.

mirio init

Creates a sandbox project and sets up the repo.

npx @trymirio/mirio init [--agent claude-code] [--name "Marketing site"] [--api-url https://api.trymirio.com] [--forms-dir mirio/forms] [--force]

Writes mirio.json, .mirio/secret, mirio/client.ts, mirio/forms/, adds .mirio/ to .gitignore, and appends a short "Mirio forms" section to AGENTS.md and CLAUDE.md (whichever exist; creates AGENTS.md if neither). Prints the claim link. Refuses to overwrite an existing mirio.json without --force. Provisioning is rate limited per IP. In a monorepo, run it in the app's folder: at a monorepo root (no package.json, a workspace setup, or no React) with an app below it, it stops before doing anything (a link code stays unused) and names the app folders, Next.js and Astro apps first; --force sets up the current folder anyway. The install hint matches your package manager.

--agent <name> tells Mirio which coding agent ran the command (agents should name themselves). Without it the CLI uses MIRIO_AGENT, then AI_AGENT, then CLAUDECODE=1 (Claude Code); init --link sends it too.

Another checkout of the same repo

.mirio/secret is gitignored, so it exists only in the checkout where init ran. A git worktree or a fresh clone has mirio.json and the forms but no key: the dev server validates forms without registering them, and push, test and status stop with "No secret key found". Give that checkout the same key, don't run init again (that would create a new project):

  • Copy the file: mkdir -p .mirio && cp ../main-checkout/.mirio/secret .mirio/ (any path to the first checkout).
  • Or set MIRIO_SECRET_KEY in that checkout's environment. npx @trymirio/mirio env print --secret in the first checkout prints it (without --secret, env print makes a deploy key, which can only register forms).

init --link doesn't help here: a site's "Connect a repo" code works only while the site has no key yet. New key on the site's page (owners) replaces the key, so the first checkout and anything else using the secret key stop working until you update them (deploy keys keep working); use it only when the key is lost.

Connects the repo to a site that was started in the Mirio dashboard (New form). The dashboard puts the command, with a one-time code, at the top of the prompt it gives you for the form; codes work once and expire after 24 hours.

npx @trymirio/mirio init --link mil_XXXXX-XXXXX-XXXXX-XXXXX [--force]

It does everything init does (config, .mirio/secret, mirio/client.ts, the plugin, CSS and the AGENTS.md section) but uses the site created in the dashboard, which is already claimed, so there is no claim link. It prints Connected to <site> and the forms waiting for a file:

✓ Connected to Acme marketing (prj_…)
Forms waiting for a file:
  mirio/forms/waitlist.ts — Waitlist
      Template: waitlist
  mirio/forms/quote.ts — Quote request
      A short intake for people who want a custom quote: what they need built, rough budget…

Write each file with defineForm and the same slug; the dev server (or mirio push) registers it and the draft becomes the form. --json returns the project id and the drafts (never the key). An expired or used code asks you to copy a fresh prompt from the form's page; a site that is already connected to another repo returns the API's hint (copy MIRIO_SECRET_KEY from that repo, or create a reconnect code on the site's page under Sites). --force replaces an existing mirio.json.

Setup edits

Both forms of init also set up the site, unless you pass --no-setup:

  • Framework plugin. Next.js: wraps the default export of next.config.(ts|mjs|js) in withMirio(...) and adds the import (handles export default nextConfig, export default { … } and module.exports = …). Vite and React Router: adds mirio() to plugins in vite.config.*. Astro: adds mirio() to vite.plugins in astro.config.*. When the file has a shape it doesn't recognize, nothing is written and the two lines to add are printed.
  • CSS. With Tailwind v4, adds @import "@trymirio/mirio/theme.css" and the @source line after @import "tailwindcss" in the global stylesheet; on shadcn/ui sites (components.json, whose tailwind.css path is used) also @import "@trymirio/mirio/themes/shadcn.css". With Tailwind v3 it adds @trymirio/mirio/styles.css (and themes/shadcn-v3.css) at the top. Without Tailwind it prints import '@trymirio/mirio/styles.css'.

mirio push [slug] [--env production|preview|development]

Loads every schema in the forms directory, validates it locally, and registers it. Prints the version number and the diff from the previous version. Warns while the project is unclaimed. With the framework plugin you rarely need it: the dev server registers a form when its file is saved, and builds run sync. The push is tagged with its source (see sync); from a laptop that is development, so it never changes the questions the dashboard shows for a live form. Pass --env to override.

✓ waitlist  v3 (new version)
    + role (dropdown)
    ~ name → full_name
⚠ Project is unclaimed. Public origins are rejected until it is claimed: https://trymirio.com/claim/…

mirio test [slug]

Sends a sample submission built from the schema, with the secret key and a test flag, then reads it back. Test submissions are stored with status test and never count as responses or toward the response limit (triage still reviews them, at most 20 per form a day, and those reviews count toward the triage quota), and never trigger notifications.

mirio status

Project mode (sandbox or live), claim link, allowed origins, delivery destinations, drafts created in Mirio that are still "Waiting for a file: mirio/forms/.ts ()", and a table of forms with version, 7-day submissions, last submission, the agents policy, whether triage is on and whether an ideal response is set (read from Mirio). Warns when review is on without an ideal response (fit levels need one: mirio review <slug> --ideal "…"), prints one line per schema that still carries moved settings (notifyEmails, allowedOrigins, review), and flags forms whose local schema differs from what was registered.

Settings (0.2.4): settings aren't part of a form's version, so a form whose fields match can still have settings in the file that Mirio doesn't (a thank-you message, the agents policy). status compares them and says which differ and what changes them: "settings differ (agents, success): the next production deploy sets them, or mirio push --env production" (on a live form, only production changes agents, turnstileSiteKey and success), else "run mirio push". The agents column shows the policy Mirio applies, with the file's next to it when they differ ("accept (file: block)"). --json: drift: "settings_changed", settingsChanged (the keys), settingsNeedProduction, agents (Mirio's) and localAgents (the file's, when different). Moved settings (review, notifyEmails, allowedOrigins) aren't compared. mirio check doesn't fail on it, since the deploy pushes them.

Updates: status and sync say when a newer @trymirio/mirio is on npm ("@trymirio/mirio 0.1.5 is out (you have 0.1.4). What changed: https://trymirio.com/docs/changelog · Upgrade: pnpm add @trymirio/mirio@latest"; --json has it as update). They ask the registry at most once a day (cached in ~/.cache/@trymirio/mirio), give up after 1.5 seconds and never fail a command; the dev server's sync and CI builds don't check. MIRIO_NO_UPDATE_CHECK=1 turns it off. See the changelog.

mirio sync [--env production|preview|development]

The build step the framework plugin runs (withMirio during next build, mirio() during vite build and astro build); call it yourself in any other CI. Only a real build runs it: next typegen, next test and other commands that load next.config don't.

  • With a key (MIRIO_SECRET_KEY, a deploy key on a host, or .mirio/secret locally): registers every form, tagged with its source.
  • Without one: checks the registered forms through the public schema endpoint. It fails (exit 2) only when visitors would be rejected: the project is unclaimed (on a production build), or a form is not registered yet (a new form, or a draft created in Mirio whose file has not been registered). It warns when a form's questions changed since the registered version (those responses are accepted and flagged).

An unclaimed project fails only a production build (see the source rules below; MIRIO_ENV=production counts). Preview and pull-request builds (a Vercel preview, a Netlify deploy preview, a GitHub pull request, another branch in CI) and local builds only warn, so a pull request's checks pass before the site is claimed. If Mirio can't be reached, the build continues with a warning.

The source comes from the host: Vercel (VERCEL_ENV, VERCEL_GIT_COMMIT_REF, VERCEL_GIT_COMMIT_SHA, VERCEL_URL), Netlify (CONTEXT, BRANCH, COMMIT_REF, DEPLOY_URL), Cloudflare Pages (CF_PAGES_BRANCH, CF_PAGES_COMMIT_SHA, CF_PAGES_URL; production on MIRIO_PRODUCTION_BRANCH or main), GitHub Actions (GITHUB_REF_NAME, GITHUB_SHA; same branch rule; a pull request, from GITHUB_EVENT_NAME or GITHUB_HEAD_REF, is preview with its head branch, whatever that branch is called), Render (RENDER, IS_PULL_REQUEST, RENDER_GIT_BRANCH, RENDER_GIT_COMMIT), Railway (RAILWAY_ENVIRONMENT_NAME, RAILWAY_GIT_BRANCH, RAILWAY_GIT_COMMIT_SHA); GitLab, CircleCI, Buildkite, Jenkins, Bitbucket Pipelines, Azure Pipelines and Travis by their branch and pull/merge request variables (production on MIRIO_PRODUCTION_BRANCH, else the provider's default branch when it says, else main; preview otherwise); and any other build server that sets CI (production). MIRIO_ENV overrides. A build with no host signal and no CI is development, a local next build included, so building a branch on your laptop never changes production; if your build server doesn't set CI, set MIRIO_ENV=production (the build output says so). Production registrations set the questions the dashboard shows; preview and development ones never do.

mirio sync production (vercel, main@1a2b3c4) · 3 forms · registering
✓ demo-request v4 registered
✓ waitlist v2 unchanged

mirio env vercel|netlify|print [--secret]

(0.2.3; earlier versions put the secret key in.) Makes a deploy key and puts it into the host as MIRIO_SECRET_KEY, so deploy builds can register forms. A deploy key can only register forms: the host never holds the site's secret key. Run it where the secret key is (.mirio/secret).

  • vercel: vercel env add MIRIO_SECRET_KEY production and … preview, with the key on stdin. Needs the Vercel CLI, logged in and vercel linked. The key is named after the linked Vercel project ("Vercel: my-site"), else "Vercel".
  • netlify: netlify env:set MIRIO_SECRET_KEY … --context production and deploy-preview. Needs the Netlify CLI, logged in and netlify linked.
  • print: makes a deploy key and prints MIRIO_SECRET_KEY=dk_… to your terminal, to paste into any host's or CI's settings.
  • --secret: uses the site's secret key instead of making a deploy key. For another checkout of the repo (env print --secret), not for a host. When MIRIO_SECRET_KEY is set to a deploy key, it reads .mirio/secret instead, and stops if there's no secret key there.

Mirio never prints the key for vercel and netlify, and redacts it from the host CLI's output. When the host CLI is missing, not logged in, not linked, or the variable already exists, the error says what to run, and the deploy key it made is revoked (if that fails too, the error names the key to revoke). A key the API returns in any other shape than dk_ and 40 letters, digits or _ is refused before the host CLI sees it. MIRIO_SECRET_KEY that is already a deploy key is used as it is. The site's page in the dashboard lists deploy keys (made here or in the dashboard) and revokes them. --json returns { target, name, key: "deploy" | "secret", deployKey?, environments, value? (print only), warnings }. Against an API from before deploy keys, it falls back to the secret key and says so.

mirio check [--allow-sandbox]

A strict local check. Exits 2 when the project is unclaimed or any local schema differs from the registered one (or was never registered). Builds don't need it any more: the framework plugin runs sync, which fails only when visitors would be rejected.

mirio claim [--open] [--wait]

Prints the claim link. --open opens it in a browser. --wait polls until the project is live.

mirio submissions [slug] [--status all|complete|partial|spam|test] [--limit 20]

Reads submissions through the project API, with each response's kind (complete, partial, spam, test), when it came in, its owner (when any has one, see Routing) and its first answers. For sandbox projects this is the agent's own test data and expires after 72 hours.

mirio destinations …

Wire delivery without the dashboard. Destinations belong to a form: pass --form <slug>, or --all-forms to create one per form.

npx @trymirio/mirio destinations list
npx @trymirio/mirio destinations add slack --form demo-request      # "Add to Slack": prints a link for a person, waits for the channel
npx @trymirio/mirio destinations add slack https://hooks.slack.com/services/… --all-forms
npx @trymirio/mirio destinations add postgres "postgres://…pooler.supabase.com:6543/postgres" [--table demo_requests] --form demo-request
npx @trymirio/mirio destinations add email [email protected] --form demo-request      # workspace members only
npx @trymirio/mirio destinations add email [email protected] --form demo-request --categories "Sales lead,Partnership" --fit high,medium
npx @trymirio/mirio destinations add slack https://hooks.slack.com/services/… --form demo-request --fit high
npx @trymirio/mirio destinations add slack https://hooks.slack.com/services/… --form demo-request --group "Urgency: This week"
npx @trymirio/mirio destinations add slack --form demo-request --where intent=enterprise,sales      # only these answers
npx @trymirio/mirio destinations add webhook https://example.com/hooks/mirio --form demo-request      # prints the signing secret once
npx @trymirio/mirio destinations add slack https://hooks.slack.com/services/… --form demo-request --unfinished 30
npx @trymirio/mirio destinations update dst_… --unfinished 60      # or --unfinished off
npx @trymirio/mirio destinations update dst_… --nudge 2h --digest 09:00@Europe/Berlin      # Slack: reminders (each also takes off)
npx @trymirio/mirio destinations update dst_… --where plan=team      # replaces the conditions on answers; --clear-where removes them
npx @trymirio/mirio destinations remove dst_…
npx @trymirio/mirio destinations test dst_…
npx @trymirio/mirio destinations test dst_… --unfinished      # a sample unfinished alert (0.2.4)

Slack without a URL prints a 30-minute link to "Add to Slack" for a person in the site's workspace (an agent can't click through Slack's install screen) and waits up to 10 minutes for the channel to appear; --no-wait prints the link and exits, and --json returns { connectUrl, expiresAt, destinations } without waiting. Claimed sites only.

Webhook URLs must be public https:// addresses, and databases public hosts: Mirio refuses localhost, private ranges and internal names (see Destinations).

Email goes only to workspace members (no verification step); for shared inboxes and aliases use Slack. Adding a non-member address fails with the API's hint. Connection strings are encrypted at rest and never printed back. See Destinations.

The claimer's email. The person who claimed the site gets each form's responses by email by default, but a form that isn't registered yet (a draft from the dashboard) only gets that email if it still has no destination when its file is first registered. So adding Slack, a webhook or a database to such a form prints a warning with the line that keeps them (--json: warnings):

⚠ demo-request isn't registered yet, so [email protected] (who claimed the site) won't get its responses by email: Mirio adds them only to a form that has no destination when it's first registered. To keep them, also run `mirio destinations add email [email protected] --form demo-request`.

Forms that are registered already keep their email destinations; adding another destination changes nothing there.

--categories (comma-separated, matching the form's review categories) and --fit (high, medium, low) filter what an email or Slack destination sends, using the AI review. Responses without a review (review off, or the review failed) pass those. The flags are rejected for webhooks and Postgres, which receive every response with the review attached. destinations list shows each filter in plain words ("Sales lead or Partnership, high or medium fit"); --json includes the filter object.

--where <key=values> (0.2.2) filters an email or Slack destination by answers: --where intent=enterprise,sales sends only responses whose intent is enterprise or sales (any case). Use the field's key from the schema file; it works on any field, hidden ones included. Repeat it for more fields; all must match. A response without that answer isn't sent, with or without triage, and it applies to unfinished alerts too. For choice fields, pass option values (labels work too); the API refuses a key or option the form doesn't have, with the list. A value can't contain a comma. On destinations update <id>, --where replaces the conditions on answers (the categories, fit and groups stay) and --clear-where removes them. With "Add to Slack", the filter is set on the channel once it's connected. destinations list shows them as "intent is enterprise or sales". See Filter on answers.

--unfinished <minutes> (0.2.2) turns on unfinished alerts for an email, Slack or webhook destination: it also hears about a response where the person gave an email and then stopped, once they haven't saved for that many minutes (whole minutes from 10 to 1440). At most once per response; of a filter, only --where applies (unfinished responses aren't triaged). Rejected for Postgres. With Slack's "Add to Slack" link, the option is set on the channel once it's connected (with --no-wait, set it later with update). destinations update <id> --unfinished <minutes|off> changes or clears it on an existing destination (PATCH /v1/project/destinations/{id}). destinations list has an unfinished column ("after 30 minutes", "off"); --json includes unfinishedAfterMinutes.

destinations update <id> --nudge <time[:fit]|off> and --digest <HH:00[@zone]|off> (0.2.2) set a Slack channel's nudges and daily digest. --nudge 2h reminds the channel once about a high-fit response nobody has acted on two hours after it came in; the time is 90m, 2h or minutes (10 minutes to 24 hours), and :high,medium watches medium fit too (:high is the default); --nudge on is 2 hours, high fit. --digest 09:00 posts a summary every day at 9:00 in America/Los_Angeles; add @ and an IANA time zone for another (17:00@Europe/Berlin, 08:00@UTC); whole hours only. Both are refused for other destination types. destinations list has a reminders column ("nudge after 2 hours (high fit) · digest 09:00 Europe/Berlin"); --json includes nudge and digest.

mirio handled <slug> <submission-id> [--note "…"]

Says a response was taken care of outside Mirio (0.2.2): a call booked from the CRM, an answer from someone's inbox, your own agent's follow-up. It's recorded as an action of kind handled (via: "api"), like the team's Book or Reply: the response's Activity in Mirio shows "Marked as handled by an agent" with the note, webhooks and databases get a submission.action event, Slack nudges about it stop, and the daily digest no longer lists it as waiting. --note (up to 500 characters) says what was done. --json prints { slug, submissionId, action }. Each run records one action. API: POST /v1/project/forms/:slug/submissions/:id/actions with { "kind": "handled", "note"? }.

npx @trymirio/mirio submissions demo-request --json        # find the id
npx @trymirio/mirio handled demo-request sub_… --note "Booked a call from HubSpot"

mirio domains list|add <domain>|remove <domain>

The site's production domains (allowed origins). Visitors from them can submit once the project is claimed; localhost always works. Accepts example.com, www.example.com, *.example.com or a full origin with a port. A domain and its www. form count as one site: adding either allows both (most sites redirect one to the other). API: GET/POST/DELETE /v1/project/domains.

npx @trymirio/mirio domains add example.com
npx @trymirio/mirio domains list
npx @trymirio/mirio domains remove staging.example.com

mirio review <slug> [--ideal "…"] [--summary "…"] [--categories "A,B"] [--group "Name: A, B"] [--remove-group "Name"] [--off|--on]

Triage for one form. With no flags it shows the settings; flags change them and keep the rest (so --ideal alone keeps the categories). The ideal response describes a great respondent in plain words and enables fit levels; --summary says what each summary should focus on (3 to 500 characters); categories are 2 to 12 labels; --group "Urgency: This week, Later" adds a group triage sorts into, or replaces the one with that name (repeatable, up to 5), and --remove-group drops one. API: GET/PUT /v1/project/forms/:slug/review. See AI review.

npx @trymirio/mirio review demo-request --ideal "Product or research leads at 20–500 person software companies who want to start this quarter."

mirio replies <slug> [--booking-url <url>] [--instructions "…"]

How the team replies, from Mirio or Slack, for one form (0.2.2). With no flags it shows the settings; a flag changes that one and keeps the other, and "" clears it. --booking-url is the calendar page the Book button sends (https:// only; without it, Book uses the schema's success: { type: 'schedule', url }), and --instructions (up to 1,000 characters) is what every drafted reply follows: tone, what to offer, what not to promise, the sign-off. API: GET/PUT /v1/project/forms/:slug/replies. See Replies.

npx @trymirio/mirio replies demo-request --booking-url https://cal.com/acme/demo --instructions "Warm and short. Offer a 20-minute call. Don't quote prices."

mirio confirmation <slug> [--on|--off] [--subject "…"] [--body "…"|--body-file <path>]

The instant confirmation for one form (0.2.2): the email Mirio sends the person right after they submit, from your team. With no flags it shows whether it's on, who it's from, where replies go, a preview with sample values, and what stops it (an unclaimed site, no email question, {{booking_link}} without a booking link). Flags change one thing and keep the rest; "" clears the subject or message. --on with nothing written yet starts from a plain template, and says so. The subject and message take the merge fields {{first_name}}, {{form_name}}, {{workspace_name}} and {{booking_link}}; anything else in {{ }} is refused before the API is called. Who gets replies is picked in the dashboard (the form's Setup → Confirmation); by default whoever claimed the site. API: GET/PUT /v1/project/forms/:slug/confirmation.

npx @trymirio/mirio confirmation demo-request --on
npx @trymirio/mirio confirmation demo-request --subject "Thanks, {{first_name}}" --body-file mirio/confirmation.txt

mirio routing <slug> [--rule "<when> => <emails>"]… [--clear]

(0.2.3) Who owns each response of a form (Routing to people). With no flags it shows the rules in order, who takes turns, and warnings. Each --rule is <when> => <member emails> and together they replace the rules; <when> is parts separated by ; (fit=high,medium, category=Sales lead, group:Urgency=This week, or <field key>=<values> for an answer), and empty means everything else. --clear removes them. --json prints { slug, rules, warnings, changed }. API: GET/PUT /v1/project/forms/:slug/routing.

npx @trymirio/mirio routing demo-request --rule "fit=high => [email protected]" --rule "=> [email protected], [email protected]"

mirio assign <slug> <submission-id> <email|none>

(0.2.3) Hands a response to a workspace member by email, or unassigns it with none. It's in the response's Activity ("An agent gave it to Ada Lovelace"). --json prints { slug, submissionId, owner }. API: PATCH /v1/project/forms/:slug/submissions/:id with { "owner": "<email>" | null }.

mirio turnstile [set <secret key> [--site-key <key>]|remove]

Cloudflare Turnstile with your own widget. set gives Mirio the widget's secret key so it can check visitors' tokens: the site key comes from settings.turnstileSiteKey in your schema files (--site-key when they use more than one), Mirio checks the secret key with Cloudflare, and it is stored encrypted and never printed back. With no action it lists the forms that set a site key and whether their tokens are checked; remove deletes the secret key. API: GET/PUT/DELETE /v1/project/turnstile.

npx @trymirio/mirio turnstile set 0x4AAAAAAA…
npx @trymirio/mirio turnstile