> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.runtype.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.runtype.com/_mcp/server.

# Connect CLI

> Commands, flags, output modes, product resolution, and exit codes for the runtype-connect CLI.

The `runtype-connect` CLI (`@runtypelabs/connect`) connects an existing AI agent repository to Runtype and calls tools on the Runtype Connect MCP server. It requires Node.js 22.12.0 or later and targets `https://mcp.runtype.com/mcp` (`https://api.runtype.com`) by default.

## Run the CLI

Run commands with `npx`, or install `@runtypelabs/connect` globally (`npm install -g @runtypelabs/connect`) and call `runtype-connect` directly:

**`Run the CLI`**

```bash title="Run the CLI"
npx @runtypelabs/connect COMMAND
runtype-connect COMMAND
```

Replace `COMMAND` with a Connect command, a built-in command, or a server tool name.

In an interactive TTY (without `--no-input` or `RUNTYPE_CONNECT_NO_INPUT`), running with no command or only `init` flags starts `init`. Outside an interactive terminal, running with no command prints top-level help.

## Command overview

The following table lists the Connect and built-in commands. Every tool on the Runtype Connect MCP server also runs as a kebab-case command (see [Tool commands](#tool-commands)).

| Command                   | Purpose                                                                                                            |
| ------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| `setup`                   | Installs the MCP server, skill file, and optional Claude Code rules without signing in.                            |
| `init`                    | Signs in, creates or connects a product and ingest key, writes `.env`, and configures your coding agent.           |
| `simulate`                | Prepares an existing product's simulation context and hands it to your coding agent for a draft plan and estimate. |
| `claim`                   | Claims a temporary no-browser account, checks claim status, or removes a saved no-browser session.                 |
| `mcp`                     | Serves the Runtype Connect MCP server over stdio.                                                                  |
| `check`                   | Verifies that recent development runs carry required trace attributes and content.                                 |
| `doctor`                  | Checks local env files, credentials, product, ingest key, MCP entry, skill file, and permissions.                  |
| `relay`                   | Forwards simulation calls from Runtype to a local agent or MCP server.                                             |
| `sync`                    | Updates tracked skill files and repairs tracked MCP server entries installed by `init`.                            |
| `uninstall`               | Removes tracked MCP server entries, skill files, and optionally Runtype env variables.                             |
| `login`, `logout`         | Signs in to the Connect MCP server or revokes and deletes the stored credential.                                   |
| `auth status`, `whoami`   | Shows the active server, profile, credential source, and identity without a network call.                          |
| `auth token`              | Prints the active bearer token to stdout.                                                                          |
| `tools`, `schema`, `call` | Lists server tools, prints a tool's JSON schema, or calls a tool by exact name.                                    |
| `skill install`           | Writes or prints the `runtype-connect` `SKILL.md` file.                                                            |
| `completion`              | Prints a shell completion script for `bash`, `zsh`, or `fish`.                                                     |
| `version`, `help`         | Prints the CLI version or command help.                                                                            |

## Global flags and environment variables

Global flags apply to every command and can appear anywhere before `--`, except `--api-url` and `--api` must appear before `doctor`, `check`, and the commands of read-only tools such as `get-status`. Don't place a global flag right after a command flag that expects a value.

The following table lists the global flags:

| Flag                                    | Default                   | Description                                                                                                                                                              |
| --------------------------------------- | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `--api-url URL`, `--api URL`            | `https://api.runtype.com` | Targets `URL` (`http` or `https`), sending MCP requests to `URL/v1/connect/mcp` and writing `URL/v1/otel/v1/traces` for traces. Accepts `--api-url=URL` and `--api=URL`. |
| `--token TOKEN`                         | None                      | Uses `TOKEN` as the bearer credential for one command.                                                                                                                   |
| `--profile NAME`                        | `default`                 | Selects a named stored sign-in profile.                                                                                                                                  |
| `--no-input`                            | Off                       | Disables interactive prompts and implicit stdin reads.                                                                                                                   |
| `--color`, `--color=MODE`, `--no-color` | `auto`                    | Controls ANSI color output (`auto`, `always`, or `never`). Bare `--color` sets `always`; `--no-color` sets `never`.                                                      |
| `-v`, `--verbose`                       | Off                       | Requests server log messages and prints them to stderr.                                                                                                                  |

`-V` and `--version` work only as the first argument. `-h` and `--help` work as the first argument for top-level help or after any command for that command's help.

The following table lists the environment variables that configure the CLI:

| Variable                            | Default                                                                                                                     | Description                                                                                                                                                                            |
| ----------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `RUNTYPE_API_URL`                   | `https://api.runtype.com`                                                                                                   | Overrides the Runtype API base URL when `--api-url` isn't set.                                                                                                                         |
| `RUNTYPE_CONNECT_TOKEN`             | None                                                                                                                        | Supplies a credential when `--token` isn't set.                                                                                                                                        |
| `RUNTYPE_CONNECT_PROFILE`           | `default`                                                                                                                   | Selects the stored sign-in profile when `--profile` isn't set.                                                                                                                         |
| `RUNTYPE_CONNECT_CREDENTIAL_STORE`  | `auto`                                                                                                                      | Where `login` stores credentials: `auto` (OS keychain with file fallback), `keychain`, `file`, or `ephemeral` (memory only). On Linux, `keychain` requires `DBUS_SESSION_BUS_ADDRESS`. |
| `RUNTYPE_CONNECT_CONFIG_DIR`        | `$XDG_CONFIG_HOME/runtype-connect` (`~/.config/runtype-connect`) on macOS and Linux; `%APPDATA%\runtype-connect` on Windows | Overrides the directory for config, sessions, file credentials, and cache (`RUNTYPE_CONNECT_CONFIG_DIR/cache`).                                                                        |
| `XDG_CONFIG_HOME`, `XDG_CACHE_HOME` | `~/.config`, `~/.cache`                                                                                                     | Base config and cache directories on macOS and Linux when `RUNTYPE_CONNECT_CONFIG_DIR` is unset (Windows cache default: `%LOCALAPPDATA%\runtype-connect\cache`).                       |
| `RUNTYPE_CONNECT_NO_INPUT`          | Off                                                                                                                         | Disables interactive prompts and implicit stdin reads for any value other than empty, `0`, `false`, `no`, or `off`.                                                                    |
| `NO_COLOR`                          | Unset                                                                                                                       | Non-empty value disables color output and overrides `--color`.                                                                                                                         |
| `FORCE_COLOR`                       | Unset                                                                                                                       | Enables or disables color output when `--color` is `auto` and `NO_COLOR` is unset.                                                                                                     |
| `TERM`                              | Unset                                                                                                                       | `TERM=dumb` disables color output in `--color=auto` mode.                                                                                                                              |
| `BROWSER`                           | Unset                                                                                                                       | `BROWSER=none` stops `login` from opening a browser. `login` also skips the browser over SSH or without a graphical display and prints the sign-in URL instead.                        |

Inside Claude Code, Codex, Cursor, Gemini CLI, OpenCode, or VS Code, `init` and `setup` configure that coding agent and `doctor` checks it by default. Inside Claude Code, Codex, Cursor Agent, Gemini CLI, or OpenCode, `--max-output` defaults to `30000` characters. Set `AI_AGENT` to use the same output default in another coding agent.

The CLI resolves credentials in the following order:

1. `--token`.
2. `RUNTYPE_CONNECT_TOKEN` (fails with exit code `2` if `--token` sets a different value).
3. This computer's no-browser session from `init --no-browser`, unless you signed in with `login` after it.
4. The stored sign-in from `login` for the target server and profile.

## Connect commands

Connect commands manage repository setup, no-browser sign-up claims, local checks, local relays, and updating or removing what `init` installed. Run `setup` when you want your coding agent to handle sign-in later; run `init` to sign in and connect the repository now. Connect commands take precedence over server tools with the same name and accept `-h`, `--help`, `--FLAG VALUE`, and `--FLAG=VALUE`.

### `setup`

Installs the Runtype Connect MCP server, the repository `runtype-connect` skill, and optional Claude Code permission rules without signing in, making network requests, or touching `.env`. It's safe to run again and prints the commands that sign in and connect the repository (`init` and `init --no-browser`). Run `setup` with the following syntax:

**`setup usage`**

```bash title="setup usage"
runtype-connect setup [FLAGS]
```

Replace `FLAGS` with any flags from the following table:

| Flag                 | Default                    | Description                                                                                                                                                                                       |
| -------------------- | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--agent AGENT`      | Active coding agent        | Coding agent to configure (same names and aliases as `init --agent`).                                                                                                                             |
| `--no-mcp`           | Adds the MCP server        | Skips adding the Runtype Connect MCP server.                                                                                                                                                      |
| `--no-browser`       | Remote HTTP MCP entry      | Configures the MCP entry to run `mcp` over stdio with this computer's `init --no-browser` session.                                                                                                |
| `--allow-rules`      | Prompts in a terminal      | Adds Claude Code permission rules without asking (Claude Code only). Outside an interactive terminal or with `--json`, fails with exit code `2` for any API other than `https://api.runtype.com`. |
| `--no-allow-rules`   | Prompts in a terminal      | Skips Claude Code permission rules.                                                                                                                                                               |
| `--remove-ask-rules` | Keeps matching `ask` rules | With `--allow-rules`, also removes the `ask` rules that match Connect commands and tools, including any you added.                                                                                |
| `--json`             | Human-readable output      | Prints `{ projectRoot, mcp, skill, permissions, next: { signIn, noBrowser } }` as JSON.                                                                                                           |

### `init`

Connects the repository in the current directory to Runtype. `init` signs you in, finds or creates a product, creates an ingest key, and writes `RUNTYPE_INGEST_KEY`, `RUNTYPE_OTLP_URL`, and `RUNTYPE_ENVIRONMENT` to `.env` (creating new env files with `0600` permissions on Unix). It updates `.gitignore` if needed, installs the MCP server (`runtype-connect`, or `runtype-connect-HOST` for a custom API URL) and `runtype-connect` skill, and prints or opens the setup prompt. The MCP entry is the remote HTTP server, and signing in to it from the coding agent is optional. The setup prompt tells the coding agent to run every Connect step in its first session as `runtype-connect COMMAND --json`, and not to stop for the MCP sign-in.

`init` records the MCP entries and skill files it installs in the CLI configuration directory so `sync` and `uninstall` can update or remove them. If saving that record fails, `init` still succeeds and prints a warning (also returned in `warnings` under `--json`). Running `init` again checks the existing key without creating a new one and never prints the ingest key secret. Run `init` with the following syntax:

**`init usage`**

```bash title="init usage"
runtype-connect init [FLAGS]
```

Replace `FLAGS` with any flags from the following table:

| Flag                  | Default                                                                                         | Description                                                                                                                                                                                                                                                             |
| --------------------- | ----------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--name NAME`         | Git remote or directory name                                                                    | Product name to find or create.                                                                                                                                                                                                                                         |
| `--env-file PATH`     | `.env` (or `.env.local` if git tracks `.env` and an untracked `.env.local` exists)              | Writes env vars to `PATH` inside the repository. Refuses tracked files and symlinks to tracked or unignored targets.                                                                                                                                                    |
| `--framework NAME`    | Auto-detected (fallback: `OpenTelemetry GenAI`)                                                 | Instrumentation setup prompt (case-insensitive): `AI SDK`, `LangGraph`, `OpenAI Agents SDK`, `Pydantic AI`, `Mastra`, `OpenAI Agents SDK (TypeScript)`, `eve`, `Flue`, or `OpenTelemetry GenAI`.                                                                        |
| `--agent AGENT`       | Active coding agent, else the agent you picked last time, else chosen from `PATH` interactively | Coding agent to configure and open (case-insensitive): `claude-code`, `codex`, `cursor`, `gemini-cli`, `opencode`, or `vscode` (aliases: `claude`, `gemini`, `copilot`, `cursor-agent`). When `init` opens the agent, it remembers an agent it can open for later runs. |
| `--no-mcp`            | Adds the MCP server                                                                             | Skips adding the Runtype Connect MCP server.                                                                                                                                                                                                                            |
| `--no-skill`          | Writes the skill file                                                                           | Skips writing the `runtype-connect` skill file.                                                                                                                                                                                                                         |
| `--skill-scope SCOPE` | `project`                                                                                       | `project` (repository root) or `user` (home directory). Writes `.claude/skills/runtype-connect/SKILL.md` for Claude Code or no agent, and `.agents/skills/runtype-connect/SKILL.md` for other agents. Keeps edited copies.                                              |
| `--no-browser`        | Browser sign-in                                                                                 | Creates a temporary, unclaimed account with one product and ingest key without opening a browser, saves the session outside the repository, and configures stdio `mcp`. Claim within 72 hours with `claim` to keep it.                                                  |
| `--launch`            | Prompts in a terminal                                                                           | Opens your coding agent (Claude Code, Codex, Cursor Agent, Gemini CLI, or OpenCode) with the setup prompt without asking. Prints and copies the prompt if the agent can't be opened.                                                                                    |
| `--no-launch`         | Default off a terminal                                                                          | Prints the setup prompt without opening a coding agent.                                                                                                                                                                                                                 |
| `--allow-rules`       | Prompts in a terminal                                                                           | Adds Claude Code permission rules without asking (Claude Code only). Outside an interactive terminal or with `--json`, fails with exit code `2` for any API other than `https://api.runtype.com`.                                                                       |
| `--no-allow-rules`    | Prompts in a terminal                                                                           | Skips Claude Code permission rules.                                                                                                                                                                                                                                     |
| `--remove-ask-rules`  | Keeps matching `ask` rules                                                                      | With `--allow-rules`, also removes the `ask` rules that match Connect commands and tools, including any you added.                                                                                                                                                      |
| `--json`              | Human-readable output                                                                           | Prints the init report as JSON (`maskedKey` only, plus `warnings` if any) and opens no coding agent.                                                                                                                                                                    |

For the full repository setup workflow, see [Connect a repository](/connect/connect-a-repository).

### `simulate`

Prepares a simulation for the exact product you select. It signs you in or reuses your session, reads saved product context, and offers to open your coding agent. It keeps the existing product and its saved targets, authentication and traces. It doesn't run repository setup or start a simulation.

Run `simulate` with the following syntax:

**`simulate usage`**

```bash title="simulate usage"
runtype-connect simulate --product PRODUCT_ID [FLAGS]
```

Replace `PRODUCT_ID` with the product ID from its **Simulations** page. Replace `FLAGS` with any flags from this table:

| Flag                              | Default                                                                                         | Description                                                                                                                              |
| --------------------------------- | ----------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `--product ID`, `--product-id ID` | Required                                                                                        | Selects an existing product by its exact ID.                                                                                             |
| `--brief TEXT`                    | Empty                                                                                           | Includes your task brief in the preparation and agent handoff.                                                                           |
| `--agent AGENT`                   | Active coding agent, else the agent you picked last time, else chosen from `PATH` interactively | Chooses the coding agent, using the same names and aliases as `init --agent`. An agent `simulate` can open is remembered for later runs. |
| `--no-launch`                     | Prompts in a terminal                                                                           | Prints and copies the handoff instead of opening an agent.                                                                               |
| `--json`                          | Human-readable handoff                                                                          | Prints the preparation result and `handoffPrompt` as JSON without opening an agent.                                                      |

The agent prepares a draft plan and estimate for you to review in the dashboard. You start the run there. `simulate` requires explicit starts for the product's baseline and proposed changes. Starting a run yourself keeps that requirement in place. Runs already queued or running continue. See [Run a baseline simulation](/simulate/run-a-baseline-simulation#prepare-with-your-coding-agent).

### `claim`

Claims the temporary organization created by `init --no-browser`, checks whether it is claimed, or deletes the saved no-browser session. With no flags in an interactive terminal, `claim` checks status and prompts through email verification. Run `claim` with the following syntax:

**`claim usage`**

```bash title="claim usage"
runtype-connect claim [FLAGS]
```

Replace `FLAGS` with any flags from the following table:

| Flag            | Default               | Description                                                                                                                                                           |
| --------------- | --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--email EMAIL` | None                  | Sends a 6-digit verification code to `EMAIL` and prompts for it interactively unless `--json` is set.                                                                 |
| `--otp CODE`    | None                  | Completes the claim with the 6-digit code sent by email.                                                                                                              |
| `--status`      | Off                   | Checks whether the organization is claimed without prompting.                                                                                                         |
| `--forget`      | Off                   | Deletes the saved no-browser session and removes `RUNTYPE_INGEST_KEY` (and `RUNTYPE_OTLP_URL` if unchanged) from the env file when it still holds this session's key. |
| `--json`        | Human-readable output | Prints the result as JSON without prompting.                                                                                                                          |

### `mcp`

Serves the Runtype Connect MCP server over stdio until stdin closes, relaying JSON-RPC messages with this computer's `init --no-browser` session or a stored sign-in. Start the stdio relay with the following command:

**`mcp usage`**

```bash title="mcp usage"
runtype-connect mcp
```

`mcp` takes no command flags; global flags apply. For coding agent setup details, see [Connect your coding agent](/connect/connect-your-coding-agent).

### `check`

Calls `check_first_trace` for the repository's product and reports whether recent development runs carry required attributes and content. When a required check fails, `check` prints a fix prompt. It makes no changes and requires a sign-in or no-browser session. Run `check` with the following syntax:

**`check usage`**

```bash title="check usage"
runtype-connect check [FLAGS]
```

Replace `FLAGS` with any flags from the following table:

| Flag                   | Default                | Description                                                                  |
| ---------------------- | ---------------------- | ---------------------------------------------------------------------------- |
| `--product PRODUCT_ID` | Resolved automatically | Checks `PRODUCT_ID` instead of resolving from `.env` or the repository name. |
| `--wait SECONDS`       | `30`                   | Waits up to `SECONDS` (integer `0` to `50`) for a first run to arrive.       |
| `--since TIMESTAMP`    | None                   | Examines only runs received at or after `TIMESTAMP` (ISO 8601).              |
| `--json`               | Human-readable output  | Prints the check result as JSON.                                             |

`check` exits `0` for `healthy`, `1` for `needs_attention`, `5` for `degraded` (the output says what is missing and what it costs), and `6` for `processing` or `no_traces`. For what each check inspects, see [Send a first trace](/connect/send-a-first-trace).

### `doctor`

Checks the repository's Connect setup without changing anything. `doctor` runs `env_file`, `otlp_endpoint`, `session`, `product`, `ingest_key`, `mcp_server`, `skill`, and `permissions`, plus `content` when `.env` sets `RUNTYPE_CONTENT`, reporting `pass`, `warn`, `fail`, or `skip` for each. It shows only the ingest key prefix and prints no other values from `.env`. Run `doctor` with the following syntax:

**`doctor usage`**

```bash title="doctor usage"
runtype-connect doctor [FLAGS]
```

Replace `FLAGS` with any flags from the following table:

| Flag                   | Default                                      | Description                                                                                           |
| ---------------------- | -------------------------------------------- | ----------------------------------------------------------------------------------------------------- |
| `--product PRODUCT_ID` | Resolved automatically when signed in        | Checks the ingest key against `PRODUCT_ID` (works without signing in).                                |
| `--agent AGENT`        | Active coding agent, or all supported agents | Checks the MCP server entry and `permissions` for `AGENT` (same names and aliases as `init --agent`). |
| `--json`               | Human-readable output                        | Prints `{ ok, apiUrl, mcpUrl, signedIn, prepared, checks }` as JSON.                                  |

`mcp_server` passes when the entry points to the Runtype Connect server, whether or not the coding agent has signed in to it. For the remote server, the detail says that signing in is optional and how to do it in the coding agent. `session` and `product` check the CLI's own sign-in and access to the product, which the coding agent's first session uses.

`permissions` checks the Claude Code rules for Runtype Connect, warns when rules are missing, a deny rule blocks Connect, or `.mcp.json` defines another `runtype-connect` server, and skips for other agents. It never fails `doctor`.

After `setup` and before `init` (when the MCP server or skill is in place without `.env`), `doctor` fails `env_file`, names `init` as the next step, and sets `prepared` to `true`. `doctor` exits `0` with no failed checks, `1` on a failed check, `2` when the server can't report the setup status, `3` when sign-in is refused, and `4` when a URL is unreachable or returns an unexpected HTTP status.

### `relay`

Pairs this computer with your Runtype account and forwards simulation calls from Runtype to one local loopback address until you stop it with Ctrl-C. Requires a claimed organization (signed in with `login` or claimed with `claim`). When the repository has `.runtype/agents.yaml` (or `.runtype/agents.yml`), `relay` reads defaults from it and can start and stop your local server automatically. Start the relay with one of the following forms:

**`relay usage`**

```bash title="relay usage"
runtype-connect relay [--entry NAME] [--manifest PATH] [FLAGS]
runtype-connect relay --agent AGENT_ID --forward-to LOOPBACK_URL [FLAGS]
runtype-connect relay --protocol mcp --forward-to LOOPBACK_URL [FLAGS]
```

Replace the following:

* `NAME`: the entry name in `.runtype/agents.yaml` when the manifest defines multiple entries.
* `PATH`: the path to a manifest file.
* `AGENT_ID`: the agent ID (`agents[].id` from `npx @runtypelabs/connect get-status`; required for `a2a` and `chat` unless set in the manifest).
* `LOOPBACK_URL`: the local address the agent or MCP server listens on.
* `FLAGS`: any optional flags from the following table.

The following table lists the flags for `relay`:

| Flag                                              | Default                                                                 | Description                                                                                                                                                                                                                  |
| ------------------------------------------------- | ----------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--manifest PATH`                                 | `.runtype/agents.yaml` (or `.yml`) at the repository root, when present | Reads agent entries from `PATH`.                                                                                                                                                                                             |
| `--entry NAME`                                    | The only entry when the manifest defines one                            | Selects the manifest entry. Required when the manifest defines multiple entries.                                                                                                                                             |
| `--no-start`                                      | Off                                                                     | Skips starting the manifest's `command` when the local address isn't reachable.                                                                                                                                              |
| `--agent AGENT_ID`                                | Manifest entry's `agentId`                                              | Agent ID to make callable. Required for `a2a` and `chat` unless set in the manifest.                                                                                                                                         |
| `--forward-to LOOPBACK_URL`                       | Manifest entry's `forwardTo`                                            | Local loopback URL to forward calls to. Required unless set in the manifest. Accepts `127.0.0.1`, `localhost`, or `::1` without a query or fragment for `a2a` and `chat`; requires literal `127.0.0.1` or `[::1]` for `mcp`. |
| `--protocol PROTOCOL`                             | Manifest entry's `protocol`, or `a2a`                                   | Local protocol: `a2a`, `chat` (accepts `{"userId","sessionId","message"}` and returns `{"sessionId","reply"}`), or `mcp` (Streamable HTTP MCP server). Explicit flags override the manifest.                                 |
| `--connect`                                       | Off                                                                     | Registers the agent or MCP server as a simulation test target after pairing.                                                                                                                                                 |
| `--product-id PRODUCT_ID`, `--product PRODUCT_ID` | Resolved from `.env` or sole org product                                | Product ID used when registering a target with `--connect`.                                                                                                                                                                  |
| `--name NAME`                                     | Computer hostname                                                       | Display name for this computer when paired.                                                                                                                                                                                  |
| `--json`                                          | Human-readable output                                                   | Prints one JSON line when ready (`status: "callable"` for agents; `status: "listening"` for MCP servers; includes `targetId` with `--connect`).                                                                              |

With `--protocol a2a`, `relay` forwards only `POST` requests to `LOOPBACK_URL` and `GET` requests to A2A card paths (`/.well-known/agent-card.json` and `/.well-known/agent.json`) on that origin. With `--protocol chat`, it forwards only `POST` requests to `LOOPBACK_URL` and serves a generated A2A card itself.

When a manifest entry sets `command` and the local server isn't ready (a `2xx` from `healthPath` when set, otherwise any HTTP response from `forwardTo`), `relay` starts `command` in `cwd` unless you pass `--no-start`. `relay` waits up to `readyTimeoutMs` (default 15 seconds) for that same check to pass and stops the process when `relay` exits. An already running server is left alone.

For the `.runtype/agents.yaml` schema and manifest errors, see [Agent manifest](/reference/agent-manifest). For the local relay workflow, see [Test against your real agent](/simulate/test-against-your-real-agent).

### `sync`

Refreshes the Runtype Connect skill files and MCP server entries that `init` installed on this computer, without network requests or sign-in. Run `sync` after upgrading the CLI to update tracked skill files to the installed version. It rewrites each tracked skill file (keeping files you edited after installation unless you pass `--force`), recreates deleted tracked skill files, and restores tracked MCP entries.

`sync` acts only on installations recorded by `init`; entries from `setup` or `skill install` aren't tracked until you run `init`. Run `sync` with the following syntax:

**`sync usage`**

```bash title="sync usage"
runtype-connect sync [FLAGS]
```

Replace `FLAGS` with any flags from the following table:

| Flag            | Default               | Description                                                                                    |
| --------------- | --------------------- | ---------------------------------------------------------------------------------------------- |
| `--agent AGENT` | Every tracked agent   | Syncs only MCP entries and skill files for `AGENT` (same names and aliases as `init --agent`). |
| `--project DIR` | Every tracked project | Syncs only skill files tracked for `DIR`. Doesn't filter MCP entries.                          |
| `--force`       | Off                   | Overwrites skill files edited after installation.                                              |
| `--dry-run`     | Off                   | Reports what would change without writing files.                                               |
| `--json`        | Human-readable output | Prints `{ dryRun, mcp, skills }` as JSON.                                                      |

MCP statuses are `unchanged`, `updated`, `installed`, and `failed`. Skill statuses are `unchanged`, `updated`, `recreated`, `missing` (`--dry-run` only), `modified_by_user`, and `failed`. `sync` exits `0` when no item fails and `1` when any item fails.

### `uninstall`

Removes the Runtype Connect MCP server entries and skill files that `init` installed on this computer, leaving other MCP servers and edited skill files (unless you pass `--force`) untouched. Makes no network requests.

`uninstall` acts only on installations recorded by `init`. It doesn't remove the product or ingest key in Runtype, your sign-in (`logout`), a no-browser session (`claim --forget`), Claude Code permission rules, `.gitignore` entries, `.runtype/agents.yaml`, or files created by `setup` or `skill install`. Run `uninstall` with the following syntax:

**`uninstall usage`**

```bash title="uninstall usage"
runtype-connect uninstall [FLAGS]
```

Replace `FLAGS` with any flags from the following table:

| Flag              | Default                                        | Description                                                                                                                          |
| ----------------- | ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| `--agent AGENT`   | Every tracked agent                            | Removes only entries for `AGENT` (same names and aliases as `init --agent`).                                                         |
| `--project DIR`   | Every tracked project                          | Removes only skill files tracked for `DIR` and sets the directory `--wipe` cleans.                                                   |
| `--wipe`          | Off                                            | Removes `RUNTYPE_INGEST_KEY`, `RUNTYPE_OTLP_URL`, and `RUNTYPE_ENVIRONMENT` from the env file, keeping all other lines and comments. |
| `--env-file PATH` | `.env` in the current directory or `--project` | Env file that `--wipe` cleans. Unlike `init`, doesn't switch to `.env.local` automatically.                                          |
| `--force`         | Off                                            | Deletes skill files edited after installation.                                                                                       |
| `--dry-run`       | Off                                            | Reports what would be removed without changing files.                                                                                |
| `--json`          | Human-readable output                          | Prints `{ dryRun, mcp, skills, envFile }` as JSON (`envFile` appears with `--wipe`).                                                 |

MCP statuses are `removed`, `already_absent`, and `failed`. Skill statuses are `removed`, `already_absent`, `modified_by_user`, `kept_shared` (used by another tracked agent), and `failed`. Env file statuses are `cleaned`, `unchanged`, `not_found`, and `failed` (with `removed` listing removed variables). `uninstall` exits `0` when nothing fails and `1` when any item or the env file fails.

### Claude Code permission rules

For Claude Code, `setup` and `init` offer rules that let read-only Connect tools run without asking (plus `doctor`, `check`, and the CLI commands of those read-only tools, such as `get-status`, when installed globally as `runtype-connect`; these commands take `--api-url` only before the command name). They write no rule for any other Connect command or tool, so your Claude Code permission mode decides on those, including `init`, `claim`, `setup`, `login`, `relay`, `sync`, and `uninstall`. When `.claude/settings.local.json` holds `ask` rules that match Connect commands and tools, both commands offer to remove them, and remove them only when you confirm or pass `--remove-ask-rules` with `--allow-rules`. Every other `ask` rule stays. Without `--allow-rules` or `--no-allow-rules`, both commands ask in an interactive terminal and write no rules outside one or with `--json`.

## Built-in commands

Built-in commands handle authentication, tool discovery, skill installation, and shell completion. All built-in commands except `call` and `version` accept `-h` or `--help` and accept `--FLAG VALUE` or `--FLAG=VALUE`. For `call`, run `call TOOL_NAME --help` to print that tool's help.

### `login`

Signs in to the Runtype Connect MCP server and saves the credential in the configured credential store. Run `login` with the following syntax:

**`login usage`**

```bash title="login usage"
runtype-connect login [FLAGS]
```

Replace `FLAGS` with any flags from the following table:

| Flag                     | Default                        | Description                                                                                                                           |
| ------------------------ | ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------- |
| `--with-token`           | Off                            | Reads an API key from stdin (or prompts in a terminal), verifies it, and stores it. Pipe the key on stdin off a terminal.             |
| `--device`               | Off                            | Runs OAuth device-code sign-in and prints a code to approve on another device. Can't be combined with `--with-token` or `--complete`. |
| `--no-browser`           | Opens a browser when available | Prints the sign-in URL (or uses the paste-code flow) instead of opening a browser.                                                    |
| `--json`                 | Default off a terminal         | Prints `{ url, code, next }` as JSON and exits so a script or agent can finish with `--complete`.                                     |
| `--complete URL_OR_CODE` | None                           | Completes a sign-in started with `--json`.                                                                                            |

### `logout`

Revokes a stored OAuth session on the server and deletes the stored credential locally. If `RUNTYPE_CONNECT_TOKEN` is still set, `logout` notes it on stdout (or in `envTokenStillSet` in JSON output). Takes no command flags. Run `logout` with the following command:

**`logout usage`**

```bash title="logout usage"
runtype-connect logout
```

### `auth status` and `whoami`

Shows the active server, profile, credential source, identity claims, and OAuth expiry or refreshability without a network request. `whoami` is an alias for `auth status`. Exits `0` when signed in and `3` when signed out or expired. Check sign-in status with either command:

**`auth status usage`**

```bash title="auth status usage"
runtype-connect auth status [--json]
runtype-connect whoami [--json]
```

Pass `--json` to print JSON in a terminal; non-TTY stdout prints JSON automatically.

### `auth token`

Prints the active bearer token to stdout, refreshing an expiring OAuth token first, and exits `3` when no credential is available. Takes no command flags. Print the token with the following command:

**`auth token usage`**

```bash title="auth token usage"
runtype-connect auth token
```

### `tools`

Lists the tools offered by the Runtype Connect MCP server. Run `tools` with the following syntax:

**`tools usage`**

```bash title="tools usage"
runtype-connect tools [FLAGS]
```

Replace `FLAGS` with any flags from the following table:

| Flag             | Default                       | Description                                                  |
| ---------------- | ----------------------------- | ------------------------------------------------------------ |
| `--search QUERY` | None                          | Filters tools by name, command path, title, and description. |
| `--refresh`      | Uses fresh cache              | Fetches a fresh tool list from the server.                   |
| `--all`          | Visible tools only            | Includes hidden tools.                                       |
| `--json`         | Text on a TTY; JSON off a TTY | Prints the tool list as JSON.                                |

### `schema`

Prints a tool's `name`, `command`, `inputSchema`, `outputSchema`, and `annotations` as JSON. Pass the server tool name (for example, `get_status`):

**`schema usage`**

```bash title="schema usage"
runtype-connect schema TOOL_NAME
```

Replace `TOOL_NAME` with the server tool name.

### `call`

Calls a server tool by its exact name with the same argument and output flags as any tool command. Use `call` for tools that aren't cached or share a name with a built-in command:

**`call usage`**

```bash title="call usage"
runtype-connect call TOOL_NAME [FLAGS]
```

Replace the following:

* `TOOL_NAME`: the exact tool name on the server.
* `FLAGS`: the tool's argument and output flags.

### `skill install`

Writes the `runtype-connect` `SKILL.md` file, overwriting any existing file at the target path. Defaults to `.claude/skills/runtype-connect/SKILL.md` in the repository root (or the current directory outside git). Run `skill install` with the following syntax:

**`skill install usage`**

```bash title="skill install usage"
runtype-connect skill install [FLAGS]
```

Replace `FLAGS` with any flags from the following table:

| Flag        | Default                                          | Description                                              |
| ----------- | ------------------------------------------------ | -------------------------------------------------------- |
| `--dir DIR` | Repository root `.claude/skills/runtype-connect` | Writes `SKILL.md` inside `DIR`.                          |
| `--global`  | Off                                              | Installs to `~/.claude/skills/runtype-connect/SKILL.md`. |
| `--print`   | Writes to disk                                   | Prints `SKILL.md` to stdout instead of writing a file.   |

### `completion`

Prints a shell completion script to stdout for the shell you name:

**`completion usage`**

```bash title="completion usage"
runtype-connect completion SHELL
```

Replace `SHELL` with `bash`, `zsh`, or `fish`.

### `version` and `help`

`version`, `--version`, and `-V` print the CLI version as the first argument. `help`, `--help`, and `-h` print top-level help as the first argument, and `help COMMAND` (or `COMMAND --help`) prints help for `COMMAND`. Check the version or print help with these commands:

**`version and help usage`**

```bash title="version and help usage"
runtype-connect version
runtype-connect --version
runtype-connect help COMMAND
```

Replace `COMMAND` with a Connect, built-in, or tool command name.

## Tool commands

Every tool on the Runtype Connect MCP server runs as a CLI command, including the run-inspection commands `get-run-outline`, `search-run`, `read-span-payload`, and `get-span-context` (see [Investigate a large run](/analyze/investigate-a-large-run)). The CLI caches the server's tool list and refreshes it on an unknown command or flag, so new server tools work without upgrading the CLI. For the full catalog, see [Connect MCP tools](/reference/connect-mcp-tools).

### How tools and arguments map

Tool names and input schema properties map to commands and flags by the following rules:

* **Command names**: both the exact server name (`get_status`) and its kebab-case alias (`get-status`) invoke the tool.
* **Flag names**: every top-level input property becomes a kebab-case flag (`productId` becomes `--product-id`).
* **Name collisions**: a property matching a reserved flag becomes `--arg-NAME`. Run `TOOL_NAME --help` to see final flag names.
* **Schema defaults**: a required property with a schema default isn't required on the command line. Run `TOOL_NAME --help` to see each tool's flags.
* **Single positional argument**: if a tool has one required `string` property, pass it positionally or as a flag.
* **Non-object schemas**: pass non-object inputs with `--json-body`, `--input`, or piped stdin.
* **Booleans**: pass `--FLAG` for `true`, `--no-FLAG` for `false`, or `--FLAG=true` and `--FLAG=false`.
* **Arrays and maps**: repeat flags (`--FLAG VALUE_1 --FLAG VALUE_2`). Scalar arrays also accept a JSON array string. Map flags take `KEY=VALUE` pairs (duplicate keys exit `2`).
* **Objects and JSON files**: accept inline JSON, `@PATH` for a UTF-8 file, or `@-` for stdin. Escape a leading `@` as `@@`.
* **Body and field input**: pass full arguments with `--input FILE`, `--json-body JSON`, or stdin, and set nested fields with `-F` (`--field`) and `-f` (`--raw-field`). Precedence from lowest to highest: body input, `-f` and `-F`, then typed flags and positional arguments. Objects deep-merge; arrays and scalars replace.

Call a tool by its kebab-case name and flags, or pass `--json-body` when you need an explicit `null` value:

**`Call tool commands`**

```bash title="Call tool commands"
npx @runtypelabs/connect get-status --json
npx @runtypelabs/connect check-first-trace --product-id PRODUCT_ID --json
npx @runtypelabs/connect query-traces --json-body '{"environment": null}' --json
```

Replace `PRODUCT_ID` with the product ID printed by `init`.

A result's `next.cli` field starts with the command you used (`npx @runtypelabs/connect` or `runtype-connect`, or `npx @runtypelabs/connect` when a coding agent calls MCP tools directly) and adds `--api-url` when you target another API.

### Common tool flags

Every tool command accepts the following flags in addition to its schema-derived flags:

| Flag                                    | Default                                                     | Description                                                                                                                                                                                                                                                    |
| --------------------------------------- | ----------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--json`                                | `auto`                                                      | Prints the full MCP tool result envelope as JSON (same as `--output json`).                                                                                                                                                                                    |
| `-o MODE`, `--output MODE`              | `auto`                                                      | Output format: `auto`, `json`, `text`, `raw`, `ndjson`, or `table`.                                                                                                                                                                                            |
| `--jsonl`                               | Off                                                         | Alias for `--output ndjson`.                                                                                                                                                                                                                                   |
| `--stream MODE`                         | `auto`                                                      | Streaming output: `auto`, `raw` (text deltas to stdout), or `off`. `--stream raw` can't combine with `--output json`, `ndjson`, `table`, or an active output limit (pass `--max-output 0`).                                                                    |
| `--input FILE`                          | None                                                        | Reads the JSON arguments object from `FILE`, or stdin for `-`. Can't combine with `--json-body`.                                                                                                                                                               |
| `--json-body JSON`                      | None                                                        | Passes the arguments object as an inline JSON string. Can't combine with `--input`.                                                                                                                                                                            |
| `-F KEY=VALUE`, `--field KEY=VALUE`     | None                                                        | Sets a typed JSON or schema-aware field (repeatable; supports `KEY[SUB]=VALUE`, `KEY[]=VALUE`, `@PATH`).                                                                                                                                                       |
| `-f KEY=VALUE`, `--raw-field KEY=VALUE` | None                                                        | Sets a string field without JSON parsing or `@PATH` expansion (repeatable; supports `KEY[SUB]=VALUE`, `KEY[]=VALUE`).                                                                                                                                          |
| `--raw-strings`                         | Off                                                         | Makes `-F` treat values as raw strings.                                                                                                                                                                                                                        |
| `--dry-run`                             | Off                                                         | Prints `{ tool, arguments }` as JSON without calling the server.                                                                                                                                                                                               |
| `--example`                             | Off                                                         | Prints an example arguments JSON object and exits `0`.                                                                                                                                                                                                         |
| `-y`, `--yes`                           | Prompts in a terminal                                       | Confirms destructive tools (such as `share-report`) without prompting. Required off a TTY or when reading stdin.                                                                                                                                               |
| `--timeout DURATION`                    | Default client timeout                                      | Request timeout with optional `ms`, `s`, `m`, or `h` unit (for example, `30000`, `500ms`, `1.5s`, `5m`, `1h`).                                                                                                                                                 |
| `--max-output CHARS`                    | Unlimited for humans; `30000` under a detected coding agent | Truncates output past `CHARS` characters and writes the full result to `results/` in the CLI cache directory. JSON becomes `{"truncated":true,"bytes":N,"path":"...","preview":"..."}`; text keeps head and tail. Pass `0`, `none`, or `unlimited` to disable. |
| `-h`, `--help`                          | None                                                        | Prints usage, signature, flags, and an example command.                                                                                                                                                                                                        |
| `--help-all`                            | None                                                        | Prints the full tool description and deprecated flags.                                                                                                                                                                                                         |

Repeating a non-repeatable reserved flag, or combining `--json`, `--jsonl`, and `--output` with conflicting modes, fails with exit code `2`.

## JSON output and errors

Output formatting depends on `--json` (or `--output`) and whether stdout is a TTY:

* **Connect commands** (`setup`, `init`, `claim`, `check`, `doctor`, `relay`, `sync`, `uninstall`): print text by default and JSON with `--json`. `init --json` omits the ingest key secret and opens no coding agent; `claim --json` disables prompts.
* **Built-in commands**: `schema` always prints JSON. `tools`, `auth status` (`whoami`), `login`, `logout`, and `skill install` (without `--print`) emit JSON automatically off a TTY.
* **Tool commands on a TTY (`--output auto`)**: `get-status`, `get-agent-profile`, `get-report`, and `list-runs` render terminal summaries. Other tools print pretty-printed JSON of `structuredContent` (or text blocks).
* **Tool commands off a TTY (`--output auto`)**: print compact single-line JSON of `structuredContent`.
* **Tool commands with `--json`**: print the full MCP tool result envelope (`content`, `structuredContent`, `isError`) as JSON even on a TTY.

Errors print to stderr as plain text (`Error: ...`) with a hint on a TTY, or as a single JSON line off a TTY:

**`Non-TTY error envelope on stderr`**

```json title="Non-TTY error envelope on stderr"
{"error":{"code":"auth_required","message":"check needs you to be signed in to Runtype Connect","hint":"Run: runtype-connect login, or run runtype-connect init in the repository","exitCode":3}}
```

## How commands resolve the product

When looking for a local ingest key, commands read `.env`, or `.env.local` if git tracks `.env` and an untracked `.env.local` exists (or if only `.env.local` sets `RUNTYPE_INGEST_KEY`). The CLI uses that key only when `RUNTYPE_OTLP_URL` matches `API_URL/v1/otel/v1/traces` and the key has the Runtype ingest key format.

Product resolution works as follows:

* **Product-scoped tool commands** (tools accepting `productId`, other than `get-status`): when you omit `--product-id`, the CLI resolves the product from the local `.env` ingest key. Otherwise the server uses your organization's only product, or lists your products if you have more than one.
* **`get-status`**: when you omit `--product-id` in a multi-product organization, the CLI matches the local `.env` ingest key to one product, calls `get_status` again for it, and adds `productFrom: "ingest_key_in_env"` and `productNote` to the result.
* **`check`**: uses `--product`, then the local `.env` ingest key, then the organization's only product or the product named after the repository. Exits `2` and lists products if none matches.
* **`doctor`**: uses `--product`, then (when signed in) the local `.env` ingest key, the organization's only product, or the product named after the repository.
* **`relay --connect`**: uses `--product-id` (`--product`), then the local `.env` ingest key, then the organization's only product.

## Exit codes

The CLI uses fixed exit codes so scripts and coding agents can branch on outcomes. The following table lists every exit code:

| Exit code | Category                      | Meaning and command-specific behavior                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| --------- | ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `0`       | Success                       | Command succeeded. `check` is `healthy`; `doctor` has no failed checks.                                                                                                                                                                                                                                                                                                                                                                                                       |
| `1`       | Tool or runtime error         | Tool error, unexpected runtime error, or Node.js older than 22.12.0. `check` is `needs_attention`; `doctor` failed a check; `setup`, `sync`, or `uninstall` failed an item.                                                                                                                                                                                                                                                                                                   |
| `2`       | Usage or configuration        | Unknown command or flag, invalid argument, `--api-url` or `--api` after `doctor`, `check`, or a read-only tool's command, `--allow-rules` off a terminal for a non-default API, conflicting `--token` and `RUNTYPE_CONNECT_TOKEN`, unwritable config directory or credential store before sign-in, missing `--yes`, ambiguous product, missing or invalid `.runtype/agents.yaml`, manifest command that fails to start or exits before ready, or local configuration refusal. |
| `3`       | Authentication                | Sign-in required or credential refused. Returned by `auth status` (`whoami`), `auth token`, `doctor`, and `init` off a terminal or with `--json` when no credential is stored (writes nothing and suggests `init --no-browser`, `login --device`, or `RUNTYPE_CONNECT_TOKEN`).                                                                                                                                                                                                |
| `4`       | Network, timeout, or protocol | Network error, request timeout, invalid server response, unreachable URL in `doctor`, or a `relay` manifest command not ready within `readyTimeoutMs`.                                                                                                                                                                                                                                                                                                                        |
| `5`       | Degraded                      | Returned by `check` when the status is `degraded`: the traces arrive below the fidelity Runtype needs. The output says what is missing and what it costs.                                                                                                                                                                                                                                                                                                                     |
| `6`       | Wait timed out                | Timed out waiting for a result. Returned by `check` when the status is `processing` or `no_traces`.                                                                                                                                                                                                                                                                                                                                                                           |
| `130`     | Interrupted                   | Process interrupted by Ctrl-C (`SIGINT`). Ctrl-C stops the command and exits `130`; press it again to exit immediately.                                                                                                                                                                                                                                                                                                                                                       |

## Next steps

Continue with one of the following pages:

* [Quickstart](/quickstart): run through connecting an agent from `init` to a first simulation report.
* [Trace attributes](/reference/trace-attributes): look up the span and resource attributes Runtype reads from traces.
* [Limits and pricing](/reference/limits-and-pricing): check span, retention, and signal allowances by plan.
* [Troubleshooting](/reference/troubleshooting): resolve ingest errors, first-trace failures, and connection problems.