Skip to content
Commands

kubb studio

Command reference for kubb studio. Connect a project to Kubb Studio, run it in the background, manage pairing and permissions, and publish CI snapshots.

kubb studio connects your project to Kubb Studio. The CLI generates on your machine and sends progress and file paths to Studio. To share more, grant permissions, such as --allow-read for file contents.

Terminal
kubb studio

Pair the machine

On the first run, the CLI pairs your machine:

Show pairing code and pageApprove the codeTokenAsk which permissions to grantConnectGeneration jobskubb studioYouStudiokubb studioYouStudio
  • Approve the code before it expires. The CLI copies it to the clipboard when it can.
  • The permission list starts unchecked. The CLI remembers your answers per project folder.
  • Each job logs one line: time, command, requester, and result. Steps and diagnostics stay in Studio.
  • Press b to move the session to the background worker, like kubb studio start.

Pair with a code

An agent that an MCP client starts pairs itself, with no person approving it. The kubb_studio_connect MCP tool hands out a one-time code and the command to run:

Terminal
KUBB_STUDIO_PAIRING_CODE=kubb_pair_... npx kubb studio connect --allow-write --no-open --url https://kubb.studio
  • When KUBB_STUDIO_PAIRING_CODE is set, connect, start, and login redeem the code instead of showing a pairing code. The CLI reads the code from the environment, so it never shows in the process list, and never logs it.
  • A code works once and lasts 5 minutes. The CLI sends it once and never again, even when Studio refuses it.
  • Only the flags grant permissions, and the CLI asks no questions. --allow-write alone is enough for a factory.
  • No browser opens, with or without --no-open.
  • The token lasts an hour. A connected CLI refreshes it at 70 to 85 percent of its lifetime, picked at random so many agents do not refresh at once.
  • The same person, MCP client, and project folder pairing again gets the same agent and a new token.
  • Once connected, the CLI prints the agent ID. The MCP client passes that ID to kubb_studio_generate.

When Studio refuses the code, the CLI prints why as KUBB_STUDIO_REFUSED and exits with code 1:

Studio answersWhyWhat to do
invalid_grantThe code is unknown or used, or its connection was revokedAsk the MCP client for a new code
expired_tokenThe code is older than 5 minutesAsk the MCP client for a new code
access_deniedThe plan reached its MCP agent limitRemove an MCP agent in Studio, or upgrade the plan

When Studio later rejects the token of an agent paired with a code, the CLI forgets the token and exits with KUBB_STUDIO_REFUSED. Ask the MCP client for a new code.

Actions

The first argument picks the action, connect by default.

ActionWhat it does
connectHolds a foreground session open and generates on request
startResolves pairing and permissions, then connects in the background
stopStops the background worker and keeps its pairing
loginPairs this machine again without a session. Saved permissions reset.
logoutStops the worker and forgets this project's token
statusShows pairing, worker state, permissions, and the log path, each with the command that changes it
permissionsChanges saved permissions without pairing again. Needs an interactive terminal.
snapshotGenerates, packs, and uploads a snapshot, then exits. See Publish snapshots from CI.

Background connection

Run start, status, and stop from the project folder or any folder inside it. start asks its questions, then returns while the worker connects. status reports its state:

kubb studio startconnection losttoken rejectedkubb studio stopauthentication requiredstartingconnectedreconnectingstopped
  • One worker owns a project. Stop it before a foreground connect.
  • The worker survives a closed terminal and retries temporary failures. Start it again after a crash or reboot.
  • When its token is rejected, run kubb studio login, then kubb studio start.
  • To change the URL or config, stop the worker and start it with the new flags.
  • The worker listens on a loopback port derived from the project folder. When start reports the port is occupied by another program, set KUBB_STUDIO_CONTROL_PORT to a free port.
Flags only add permissions. To turn one off, run kubb studio permissions, then restart without that --allow-* flag. A running connection keeps the old permissions until it restarts.

Credentials

Credentials, worker state, and the worker log live in KUBB_HOME, ~/.kubb by default. See Studio credentials.

Options

connect, start, and login take the connection and permission flags. status takes --url only, and snapshot has its own set.

Connection

FlagAliasDefaultWhat it does
--config <path>-cConfig file path, such as ./kubb.staging.ts
--url <url>The Studio the project paired with, else https://kubb.studioStudio URL. Plain http:// works only for localhost, 127.0.0.1, or [::1].
--no-openSkips opening the approval page. A pairing code never opens one.
--log-level <level>-linfosilent, info, or verbose

Permissions

Each --allow-* flag grants one permission, and each is off by default. Permissions lists the flags and what each one lets Studio do.

Snapshot

snapshot takes --config, --url, --log-level, and these flags, but no --allow-* flag. It reads the organization CI API key from KUBB_TOKEN.

FlagDefaultWhat it does
--token <key>KUBB_TOKENDeprecated. Organization CI API key. A flag shows the key in the process list and the shell history, so set KUBB_TOKEN instead
--id <id>DetectedStable CI agent identity
--base-id <id>DetectedAnother CI agent's --id to also compare with, such as the base branch's
--name <name>From package.jsonTarball package name, from the nearest package.json with a name and version
--package-version <version>From package.jsonTarball package version, from the same package.json
--jsonfalsePrints the result as one JSON object

snapshot generates like kubb generate, then runs the formatter, the linter, and output.postGenerate. It refuses a tarball over 50 MB. In CI, the CLI refuses a browser pairing and needs stored credentials or a pairing code, so use snapshot there.

snapshot builds the package's dist files with tsdown: the project's own, or the one on PATH. Install it with npm i -D tsdown, or globally in CI with npm i -g tsdown. kubb-labs/action installs it for you.

Snapshot output

--json prints one object with the snapshot's id, version, URLs, and comparisons. See CI snapshots for its fields.

CI agent identity

snapshot detects GitHub Actions, GitLab CI, Bitbucket Pipelines, and CircleCI. Other providers need a stable --id. See CI snapshots.

Plugins in Studio

Studio builds its plugin list and option forms from extension manifests. A third-party plugin works once it is installed and ships a manifest with kind: "plugin", without a registry entry. Install it with your package manager or kubb add, then reconnect.

The agent imports only @kubb/plugin-* packages and installed packages whose manifest has kind: "plugin". It refuses any other package name before importing anything.

See Studio agent for where the agent finds extensions.

Exit codes

CodeWhen
0The action succeeds.
1The action fails.

Less common cases

CI snapshots

In CI, kubb studio snapshot identifies the CI agent and compares the new snapshot with earlier ones.

It uploads to the Studio's public API: POST /v1/snapshots on the --url host with api. in front, such as https://api.kubb.studio for https://kubb.studio and https://api.dev.kubb.studio for https://dev.kubb.studio. A Studio on localhost takes it on its own origin.

JSON output

--json prints one object with id, name, version, integrity, url, snapshotIdUrl, expiresAt, and agentUrl.

  • It adds number and webUrl when Studio sends them, and the summary shows the number and a View link.
  • It adds changes and branchChanges when a comparison exists.
  • Installing a snapshot needs a separate registry API key.
FieldCompared with
changesThe previous snapshot on the same pull request or branch.
branchChangesThe latest snapshot of the --base-id agent, or of the base branch of a GitHub pull request or GitLab merge request. branch names that agent. baseFound is false when that agent does not exist yet, and true when it has no snapshot of this package.

CI agent identity details

OptionDefaultDescription
--id <id>DetectedStable CI agent identity. Detected on GitHub Actions, GitLab CI, Bitbucket Pipelines, and CircleCI.
--base-id <id>DetectedThe --id of another CI agent to also compare with, such as the base branch's. Detected on GitHub pull requests and GitLab merge requests.
  • Other providers need a stable --id. Use one on the base branch and pass it as --base-id on pull request runs.
  • --id turns off base detection, so also pass --base-id to get branchChanges.

GitLab CI

PipelineCI agentCompared with
Merge requestOne agent per merge requestbranchChanges: the target branch's latest snapshot. changes: the merge request's previous pipeline.
BranchOne agent per branch, the default branch includedchanges: the branch's previous pipeline.

A merge request snapshot records the head commit of the source branch. Pass --id to group runs your own way.

Studio agent

When Studio lists a plugin as not installed, check where the agent looks. Studio builds its plugin list and option forms from extension manifests.

On connect, the agent reports each extension with a valid kubb-extension.json from:

  • The dependencies and devDependencies in package.json.
  • The packages kubb.config.ts imports.
  • The extensions bundled with kubb: @kubb/adapter-oas, @kubb/parser-ts, @kubb/parser-md, and @kubb/plugin-barrel.

Settings forms

  • The config's adapter and parsers get a settings form from the options in their manifest.
  • The agent sends a JSON copy of their options on connect. On generate, Studio's edits merge over the options in kubb.config.ts.
  • A null value unsets an option for that run, so its default applies.
  • An extension without a manifest, such as parserTsx, is listed without fields.

Plugins the agent runs

AgentPlugins it can run
kubb studio on your machine@kubb/plugin-* packages, and installed packages whose manifest has kind: "plugin"
Docker agent and hosted sandboxOnly the packages in their image, with no runtime installs

The agent calls the factory the manifest names in export. It refuses any other package name before importing anything, and config edits follow the same rule.

Studio also lists extension registry plugins. A plugin the agent cannot run shows as not installed, with a kubb add <id> hint.

Studio credentials

When you pair a machine, the CLI stores the credentials, worker state, and worker log in KUBB_HOME, ~/.kubb by default. status prints the log path. A worker log that reaches 1 MiB moves to worker.log.1.

  • The CLI keeps one pairing per project. The project is the folder of the Kubb config it finds from the current folder, walking up like kubb generate, or the current folder when there is no config.
  • Approve the pairing code before it expires. The CLI copies it with pbcopy, clip.exe, xclip, or wl-copy when one is available.
  • A connected CLI renews its token daily, so it does not pair again. A token from a pairing code lasts an hour and renews before it expires.
  • Pairing also creates a key that never leaves your machine. It goes in the system keychain (macOS Keychain, Windows Credential Manager, or Secret Service on Linux), or next to the token when no keychain allows access, such as in CI or a container.
  • A project paired with an earlier release has no key and keeps working. kubb studio login adds one.
  • stop waits for a running generation to clean up. An interrupted job does not run again.

Studio permissions

See Permissions.