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.

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 same project folder. 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.
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>https://kubb.studioStudio URL. Plain http:// works only for localhost, 127.0.0.1, or [::1].
--no-openSkips opening the approval page
--log-level <level>-linfosilent, info, or verbose

Permissions

Each permission is off by default. The CLI asks once per project for each one you do not pass. Outside an interactive terminal, it skips the questions, so pass the flags the run needs.

FlagLets Studio
--allow-readRead generated file contents
--allow-read-astRead the parsed spec (the Kubb AST)
--allow-writeWrite generated files to disk
--allow-config-editChange plugin options in kubb.config.ts
--allow-installInstall extensions with kubb add. Needs --allow-config-edit.
--allow-updateUpdate extensions with kubb update, leaving the config as is
--allow-removeRemove extensions with kubb remove. Needs --allow-config-edit.
--allow-save-inputSave the spec it sends and point input at it. Needs --allow-config-edit.
--allow-file-refsLet a $ref read a local file outside the project
--allow-execRun the formatter, the linter, and output.postGenerate

See Studio permissions for what each one changes.

Snapshot

snapshot takes --config, --url, --log-level, and these flags, but no --allow-* flag.

FlagDefaultWhat it does
--token <key>KUBB_TOKENOrganization CI API key
--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 to pair and needs stored credentials, so use snapshot there.

Install tsdown first: npm i -D tsdown. snapshot builds the package's dist files with it.

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.

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.

  • 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.
  • 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

  • --allow-save-input saves the spec Studio sends and points input at it. Grant --allow-config-edit too. A pasted document goes to openapi.yaml, or openapi.json for JSON (openapi-<entry> for a later config entry). A URL or git file goes into input as is.
  • Without --allow-read, a session still generates and reports file paths, but Studio cannot show their contents.
  • With --allow-read, Studio loads the files already in output.path on connect, so you can browse them before you select Generate.
  • The agent keeps recent generations up to the KUBB_AGENT_MAX_GENERATIONS caps, with a separate budget for the initial output. Unchanged output keeps its ID across reconnects.
Flags only add permissions, and login resets the saved ones. To turn one off, run kubb studio permissions, then restart a running connection, since it keeps the old permissions. Restart with the same --url and --config, but without that permission's --allow-* flag, which would grant it again.