Skip to navigation

Connect a repository

Run init from the runtype-connect CLI to connect your agent repository to Runtype. A product groups the agents in this repository, and an ingest key lets them send traces to it. The command creates both, writes your environment variables to .env, configures your coding agent, and prepares a tracing setup prompt.

You can run commands with npx @runtypelabs/connect, or as runtype-connect after a global install.

Before you begin

You need the following:

  • A git repository or project directory with an agent built on the AI SDK, LangGraph, the OpenAI Agents SDK (Python or TypeScript), Pydantic AI, Mastra, eve, Flue, or a custom loop that emits OpenTelemetry GenAI spans.
  • git on your PATH, if the project is a git repository.
  • Node.js 22.12 or later.
  • A coding agent that supports Model Context Protocol (MCP) servers, such as Claude Code, Codex, Cursor, Gemini CLI, OpenCode, or VS Code. The CLI also works without a coding agent.
  • A Runtype account. If you don’t have an account, prefer not to sign in now, or have no browser on this machine, follow Connect without a browser.

Connect the repository with init

In your repository root, run init to connect the repository to Runtype:

Connect the repository
npx @runtypelabs/connect init

The command does the following:

  • Signs you in through the browser, or reuses your existing session.
  • Finds or creates a product named after your repository.
  • Creates an ingest key, writes RUNTYPE_INGEST_KEY, RUNTYPE_OTLP_URL, and RUNTYPE_ENVIRONMENT to .env, and keeps .env out of git.
  • Adds the Runtype Connect MCP server and skill file to your coding agent, and offers permission rules for Claude Code.
  • Detects your framework and opens your coding agent with a tracing setup prompt.

Reload your coding agent so it picks up the Runtype Connect MCP tools.

Running init again changes nothing on your account. It verifies the ingest key already in .env, creates no duplicate key, leaves unchanged files as they are, and keeps any skill file that you edited.

After upgrading the CLI, run npx @runtypelabs/connect sync to refresh tracked MCP server entries and skill files. To remove them, run npx @runtypelabs/connect uninstall. For details, see Update or remove the Connect setup.

Start interactively without a subcommand

In an interactive terminal, run the package with no subcommand to start the guided setup:

Guided start
npx @runtypelabs/connect

The command runs init, accepts the same options, and asks whether to open your coding agent with the setup prompt.

Files that init writes

init writes or updates the following files on your computer:

  • .env (or --env-file): writes RUNTYPE_INGEST_KEY, RUNTYPE_OTLP_URL, and RUNTYPE_ENVIRONMENT, and keeps every other line, comment, and quoting style unchanged. If git tracks .env and an untracked .env.local exists (and you didn’t pass --env-file), init writes to .env.local instead.
  • .gitignore: adds the env file, and .claude/settings.local.json when you accept the Claude Code rules, if git doesn’t already ignore them.
  • Coding agent MCP configuration: adds the runtype-connect server entry to your coding agent’s user-level configuration, with no credential stored in that file. Pass --no-mcp to skip it. For manual setup, see Add the Runtype Connect MCP server.
  • Skill file: writes the runtype-connect skill file into the repository. Pass --skill-scope user to write it to your home directory, or --no-skill to skip it. To replace an edited skill file, see Install or replace the runtype-connect skill.
  • .claude/settings.local.json (Claude Code only): stores the Claude Code permission rules when you accept the terminal prompt or pass --allow-rules.
  • Install registry: writes install-registry.json in the CLI’s configuration directory, outside the repository, to track the MCP server entries and skill files that sync and uninstall manage.

The three variables that init writes to .env look like the following:

.env
RUNTYPE_INGEST_KEY=rt_YOUR_INGEST_KEY
RUNTYPE_OTLP_URL=https://api.runtype.com/v1/otel/v1/traces
RUNTYPE_ENVIRONMENT=development

You don’t need to edit this file by hand after init runs. rt_YOUR_INGEST_KEY stands for the real ingest key that init writes to .env.

init never prints the full ingest key. It displays a masked form only. The ingest key can send only traces, and only to this product.

RUNTYPE_ENVIRONMENT names the environment that your traces report. init sets it to development only when it’s absent, so init keeps any existing value. Keep development for local runs, and set it to production where your agent runs in production.

If git tracks .env and no untracked .env.local exists, init stops before writing anything. Pass --env-file .env.local instead.

How init picks the product name, coding agent, and framework

When you omit --name, --agent, or --framework, init resolves each value as follows:

  • Product name: uses --name PRODUCT_NAME when passed, otherwise the repository’s git remote path, or the directory name when there is no remote. In a monorepo subdirectory, if the repository’s product already has keys, pass --name PRODUCT_NAME to give that subdirectory its own product.
  • Coding agent: uses --agent when passed, otherwise the coding agent shell that you’re running in, or the supported coding agents found on your PATH. If init finds several coding agents, it prompts you to pick one.
  • Framework: uses --framework when passed, otherwise detects the framework from your project manifests and falls back to OpenTelemetry GenAI in TypeScript or Python. A framework built on another one comes first, so eve and Mastra take priority over the AI SDK. When your project already sends telemetry, such as Logfire or Flue’s OpenTelemetry instrumentation, init picks the setup that adds Runtype beside it.

Options for init

The following table lists the options that init accepts:

OptionDefaultDescription
--name PRODUCT_NAMEGit remote path or directory nameProduct name to find or create.
--env-file PATH.envEnv file inside the repository to write.
--framework FRAMEWORKAuto-detectedTracing setup prompt to build: "AI SDK", LangGraph, "OpenAI Agents SDK", "Pydantic AI", Mastra, "OpenAI Agents SDK (TypeScript)", eve, Flue, or "OpenTelemetry GenAI".
--agent AGENTAuto-detectedCoding agent to configure: claude-code, codex, cursor, gemini-cli, opencode, or vscode (aliases: claude, gemini, copilot, cursor-agent).
--no-mcpDisabledSkip adding the Runtype Connect MCP server to your coding agent.
--no-skillDisabledSkip writing the runtype-connect skill file.
--skill-scope SCOPEprojectWhere to write the skill file: project (repository root) or user (home directory).
--no-browserDisabledSign up without a browser and create an unclaimed organization (no signed-in owner until you claim it with an email code).
--launchTerminal promptOpen your coding agent with the setup prompt without asking for confirmation.
--no-launchDefault outside a terminalPrint the setup prompt instead of opening your coding agent.
--allow-rulesTerminal promptAdd the Claude Code permission rules without asking.
--no-allow-rulesDisabledSkip offering or adding the Claude Code permission rules.
--jsonDisabledPrint the result as JSON and open nothing. Never prints the ingest key.

For global flags and environment variables, see Connect CLI.

Prepare the repository before signing in

To install the local configuration before signing in, run setup in the repository root:

Prepare the repository
npx @runtypelabs/connect setup

setup adds the Runtype Connect MCP server, writes the runtype-connect skill file, offers the Claude Code permission rules, and prints the connect command. It makes no network request, writes no key, leaves .env and any existing sign-in untouched, and is safe to run again. Running init afterward keeps what setup added.

Start from the dashboard

You can also start from the Connect an agent page in the Runtype dashboard. On the Products page, under Connect what you already have, select Connect an agent. The Connect from your terminal card on the same page shows the command to copy directly. If you open Connect an agent from an existing product, the command includes that product’s name. Opening the page creates nothing on your account.

The Connect an agent page gives you two ways to start:

  • Copy command: copies npx @runtypelabs/connect to run in your repository root.
  • Copy prompt: copies a setup prompt to hand to your coding agent.

When you sign in during setup, the browser opens the Authorize access page and tells you to return to the terminal after you approve.

After your first trace arrives, the page shows “A run arrived” and links to Go to the product canvas or See your products. In the dashboard, a connected product’s card shows its recent runs, errors, and p95 latency, and the line Connected agent. Its canvas lists Connected agents, or displays “Waiting for the first trace” before the first trace arrives.

Connect without a browser

On a machine where no browser can open, or when you don’t want to sign in now, sign up and connect without a browser:

Connect without a browser
npx @runtypelabs/connect init --no-browser

Your coding agent can also run this command for you.

init --no-browser creates an unclaimed organization, which has no signed-in owner until someone claims it with an email code. The command creates one product and its ingest key, and writes .env the same way init does. It stores the session in an owner-only file in the CLI’s configuration directory, outside any git repository. The MCP server entry uses this computer’s saved session, so your coding agent’s configuration holds no credential.

The command prints a claim deadline 72 hours after sign-up. A computer holds one unclaimed sign-up at a time.

Until you claim the organization, it accepts traces and runs no simulations. Every tool that reads traces, sets up tracing, or describes your agents works. Tools that prepare or change a simulation, signal, issue-mining pass, conversation event, change brief, share link, or test target return claim_required with the claim link and deadline. For unclaimed limits and plan allowances, see Limits and pricing.

Claim an unclaimed organization

To claim the organization interactively, run npx @runtypelabs/connect claim and follow the prompts for the owner’s email address and six-digit verification code.

To claim the organization with options, send the verification email and then submit the six-digit code:

Claim the organization
npx @runtypelabs/connect claim --email OWNER_EMAIL
npx @runtypelabs/connect claim --otp EMAILED_CODE

Replace the following:

  • OWNER_EMAIL: email address of the person who owns the organization. Runtype refuses an address that already has an account. To use an existing account, run npx @runtypelabs/connect claim --forget, then npx @runtypelabs/connect login, then npx @runtypelabs/connect init.
  • EMAILED_CODE: six-digit code from the email that the first command sends. The code expires after 10 minutes.

In an interactive terminal, claim --email OWNER_EMAIL prompts for the six-digit code right after sending the email.

After you claim the organization, the ingest key in .env keeps working, and Runtype enables simulations and model runs. If nobody claims the organization by the 72-hour deadline, the ingest key stops accepting traces and the saved session stops working.

To check whether the organization is claimed without prompting, run claim --status:

Check claim status
npx @runtypelabs/connect claim --status

To print the status as JSON, add --json.

Check the local setup with doctor

To inspect the local setup without modifying any files, run doctor in the repository root:

Check the local setup
npx @runtypelabs/connect doctor

doctor never prints the full ingest key. It shows only the key’s prefix hint and prints no other values from .env.

doctor checks your env file, git ignore rules, the traces endpoint (RUNTYPE_OTLP_URL), your sign-in session, the resolved product, and the ingest key. It also verifies your coding agent’s MCP server entry, the runtype-connect skill file, and Claude Code permission rules. When .env sets RUNTYPE_CONTENT, it also checks that value: withheld passes and declares that the app keeps conversation content out of its traces, so check reports such traces as degraded; any other value warns.

To narrow the checks or print JSON, pass any of the following options to doctor:

Check a specific product and coding agent
npx @runtypelabs/connect doctor --product PRODUCT_ID --agent AGENT --json

Replace the following:

  • PRODUCT_ID: product ID to check the ingest key against. Required when you aren’t signed in, or when doctor can’t match .env to one product in an organization with several products.
  • AGENT: coding agent to check (claude-code, codex, cursor, gemini-cli, opencode, or vscode, or their short aliases). Without --agent, doctor checks the active coding agent or all supported agents.

Next steps