# Runtype for Coding Agents

Use this guide when the user asks to connect their coding harness to Runtype. If they only ask what Runtype does, explain it without installing software or creating an account. During setup, use the CLI until the hosted MCP tools are available.

Signup never requires a browser. Ask only for the email address and emailed 6-digit code during new-account verification. Do not tell the user to open a dashboard, sign-in page, or OAuth window during signup. Existing-account recovery and the harness's MCP OAuth are separate paths below.

## Golden path — do exactly this

If the live Runtype MCP tools are already available in this session, skip setup and go to "After MCP is active" below. Otherwise follow every step in order:

### 1. Install the CLI and check auth

```bash
npm install -g @runtypelabs/cli
runtype auth status
```

Reuse an installed CLI rather than reinstalling it. If status reports `authenticated` with `accountState: "full"`, skip to step 3. If it reports a pending signup, follow its `next` command instead of registering again. If it reports `unauthenticated` with a non-null `requestedOrgId`, this directory is linked to an organization (`.runtype/project.json`, `--org`, or `RUNTYPE_ORG`) that has no stored login: do not register a new account. Have the user privately run `runtype auth login --api-key <key>` with a key from that organization (or `runtype login` in their own terminal), then verify with `runtype auth whoami --no-tty`. If the link looks wrong, confirm with the user before `runtype unlink`. If `RUNTYPE_API_KEY` is configured, verify it with `runtype auth whoami --no-tty` and reuse that account before following stored signup state: `auth status` only inspects stored credentials. Never print the key.

### 2. Sign the user up from the terminal

Ask the user one question: "What email address should I use for your Runtype account?" Then run:

```bash
runtype auth register --email <their-email>
```

This creates the account and emails the user a 6-digit code. Ask the user: "Runtype emailed a 6-digit code to <their-email> — what is it?" Then run:

```bash
runtype auth verify <code>
```

That completes signup. Every command in this flow prints JSON with a `next` field — follow it. Notes:

- These commands work without a TTY and never open a browser.
- `register` is safe to re-run; it resumes a pending signup instead of creating a duplicate account.
- After `register` (before `verify`) you already hold a temporary credential: CLI commands work with restricted models and quota, and `verify` upgrades the same stored login in place. Do not build anything substantial until `verify` succeeds.
- If the email already has an account, `email_already_registered` means signup cannot claim it. Have the user configure an API key privately in their terminal/environment (`RUNTYPE_API_KEY` or `runtype auth login --api-key <key>`), then run `runtype auth whoami --no-tty` to verify the effective credential. Do not ask them to paste a key into chat or register a replacement account.
- A wrong code returns `otp_invalid` — ask the user to re-check and run `runtype auth verify` again. An expired code returns `otp_expired` — re-send with `runtype auth claim <email>`. Codes expire after 10 minutes and lock after 5 wrong attempts, so confirm the code with the user rather than guessing; after a lockout or expiry, re-send with `runtype auth claim <email>`.

### 3. Install skills and the MCP connection

```bash
runtype install-mcp
```

This detects one coding harness, installs its Runtype skills, and writes user-level hosted MCP configuration. If selection is ambiguous, use `--agent <id>` for the current harness. Relay any harness-owned OAuth action to the user; it may open a browser and is separate from browserless signup.

### 4. Keep working in this session with the CLI

Do not stop just because the new MCP connection is not visible yet. Use CLI commands for useful first-session work:

```bash
runtype auth whoami
runtype --help
```

Continue the user's task, not an unsolicited inventory of their account. Read command help before mutations. `runtype mcp tools` lists hosted tools and `runtype mcp call <tool>` invokes one without a restart; use this bridge for build instructions, schemas, validation, and setup checks too.

### 5. Tell the user to restart or reload the harness

Before finishing this session, read the final status and next steps from `runtype install-mcp`. Retry any failed skill installation. Do not call setup complete while the command reports `action-required`, `partial`, or an error.

Only after signup is verified and skills are installed, tell the user exactly what changed and ask them to restart or reload the coding harness. Use direct language such as:

> Your Runtype account is verified and the skills plus MCP connection are installed. Please restart or reload this coding agent (or start a new session) so it can activate the new MCP tools. I used the CLI to keep this first session productive; after restart I will use MCP by default.

If an action remains, report that exact action instead of using the success wording above. Do not claim the running agent can use MCP until its Runtype tools actually appear.

### 6. Switch to MCP after restart

Once the tools appear, use Runtype MCP first. Do not fall back to the CLI just because it worked previously. For a product build, call `get_build_instructions` with:

```json
{
  "task": "build-product",
  "description": "Describe the user's product goal here"
}
```

For a bare flow use `task: "generate-flow"`; for scoping use `"explain-capabilities"`. Read-only account operations do not need build instructions. Fetch only relevant schema topics, validate before creating or updating, and test safely before reporting success.

## If the install needs recovery

`runtype install-mcp` intentionally changes one confidently selected harness, not every agent config it can find. If detection is ambiguous, re-run it with one explicit id:

```bash
runtype install-mcp --agent claude
runtype install-mcp --agent codex
runtype install-mcp --agent cursor
runtype install-mcp --agent gemini
runtype install-mcp --agent opencode
runtype install-mcp --agent vscode
```

Use only the line for the current harness. Follow the command's restart instructions. Use `--force` only when the command reports that an existing MCP server named `runtype` points to a different URL and the user agrees to replace it.

## Auth reference

The signup commands wrap the agent auth protocol documented at `https://runtype.com/auth.md` (anonymous registration plus an email claim ceremony). You normally never need the raw protocol — the CLI is the supported client:

- `runtype auth register --email <email>` — create the account and send the code (one step)
- `runtype auth claim <email>` — re-send or change the email for a pending signup
- `runtype auth verify <code>` — finish signup with the 6-digit code
- `runtype auth login --api-key <key>` — privately store an existing credential; not an account-creation command
- `runtype auth status` — inspect the login this directory uses, linked-org state, and pending signup state
- `runtype auth accounts` — list stored logins (one per organization)
- `runtype link <orgId>` — pin the current project to an organization (writes `.runtype/project.json`, no secrets)
- `runtype auth whoami --no-tty` — verify the effective credential (environment key first, then stored login)

A user-supplied `RUNTYPE_API_KEY` environment variable also authenticates API-backed CLI commands without a stored login; `auth status` still describes only the stored state. Never print a credential into the transcript or write one into a committed file.

Browser login (`runtype auth login` with no flags) exists for humans running the CLI in their own interactive terminal. Do not use it from a coding harness.

## After MCP is active

- Call `get_build_instructions` before building.
- Use `get_platform_documentation` instead of inventing payload shapes.
- Let the installed Runtype skills route task-specific work: product builds, live account operations, Persona embeds, templates, and SDK/CLI workflows.
- If the user gives you a `use.runtype.com/now?...`, example, or template/FPO link, use the Runtype template skill and MCP tools rather than opening the login-gated dashboard page.
- Validate before creating/updating. Check product setup, then test with safe inputs and authorized side effects. Report what passed and what remains blocked or untested.

Runtype MCP can create and operate agents, flows, products, records, secrets, evals, and surfaces; attach built-in, HTTP, MCP, flow, and subagent tools; and ship chat, API, webhook, messaging, schedule, MCP, and hosted-page experiences.

Docs: [docs.runtype.com](https://docs.runtype.com)
Dashboard: [use.runtype.com](https://use.runtype.com)
API: [api.runtype.com](https://api.runtype.com)
