kubb studio
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.
kubb studioPair the machine
On the first run, the CLI pairs your machine:
- 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
bto move the session to the background worker, likekubb studio start.
Actions
The first argument picks the action, connect by default.
| Action | What it does |
|---|---|
connect | Holds a foreground session open and generates on request |
start | Resolves pairing and permissions, then connects in the background |
stop | Stops the background worker and keeps its pairing |
login | Pairs this machine again without a session. Saved permissions reset. |
logout | Stops the worker and forgets this project's token |
status | Shows pairing, worker state, permissions, and the log path, each with the command that changes it |
permissions | Changes saved permissions without pairing again. Needs an interactive terminal. |
snapshot | Generates, 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:
- 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, thenkubb studio start. - To change the URL or config, stop the worker and start it with the new flags.
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
| Flag | Alias | Default | What it does |
|---|---|---|---|
--config <path> | -c | Config file path, such as ./kubb.staging.ts | |
--url <url> | https://kubb.studio | Studio URL. Plain http:// works only for localhost, 127.0.0.1, or [::1]. | |
--no-open | Skips opening the approval page | ||
--log-level <level> | -l | info | silent, 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.
| Flag | Lets Studio |
|---|---|
--allow-read | Read generated file contents |
--allow-read-ast | Read the parsed spec (the Kubb AST) |
--allow-write | Write generated files to disk |
--allow-config-edit | Change plugin options in kubb.config.ts |
--allow-install | Install extensions with kubb add. Needs --allow-config-edit. |
--allow-update | Update extensions with kubb update, leaving the config as is |
--allow-remove | Remove extensions with kubb remove. Needs --allow-config-edit. |
--allow-save-input | Save the spec it sends and point input at it. Needs --allow-config-edit. |
--allow-file-refs | Let a $ref read a local file outside the project |
--allow-exec | Run 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.
| Flag | Default | What it does |
|---|---|---|
--token <key> | KUBB_TOKEN | Organization CI API key |
--id <id> | Detected | Stable CI agent identity |
--base-id <id> | Detected | Another CI agent's --id to also compare with, such as the base branch's |
--name <name> | From package.json | Tarball package name, from the nearest package.json with a name and version |
--package-version <version> | From package.json | Tarball package version, from the same package.json |
--json | false | Prints 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.
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.
@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
| Code | When |
|---|---|
0 | The action succeeds. |
1 | The 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
numberandwebUrlwhen Studio sends them, and the summary shows the number and aViewlink. - It adds
changesandbranchChangeswhen a comparison exists. - Installing a snapshot needs a separate
registryAPI key.
| Field | Compared with |
|---|---|
changes | The previous snapshot on the same pull request or branch. |
branchChanges | The 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
| Option | Default | Description |
|---|---|---|
--id <id> | Detected | Stable CI agent identity. Detected on GitHub Actions, GitLab CI, Bitbucket Pipelines, and CircleCI. |
--base-id <id> | Detected | The --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-idon pull request runs. --idturns off base detection, so also pass--base-idto getbranchChanges.
GitLab CI
| Pipeline | CI agent | Compared with |
|---|---|---|
| Merge request | One agent per merge request | branchChanges: the target branch's latest snapshot. changes: the merge request's previous pipeline. |
| Branch | One agent per branch, the default branch included | changes: 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
dependenciesanddevDependenciesinpackage.json. - The packages
kubb.config.tsimports. - 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
optionsin 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
nullvalue 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
| Agent | Plugins it can run |
|---|---|
kubb studio on your machine | @kubb/plugin-* packages, and installed packages whose manifest has kind: "plugin" |
| Docker agent and hosted sandbox | Only 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, orwl-copywhen 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 loginadds one. stopwaits for a running generation to clean up. An interrupted job does not run again.
Studio permissions
--allow-save-inputsaves the spec Studio sends and pointsinputat it. Grant--allow-config-edittoo. A pasted document goes toopenapi.yaml, oropenapi.jsonfor JSON (openapi-<entry>for a later config entry). A URL or git file goes intoinputas 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 inoutput.pathon connect, so you can browse them before you select Generate. - The agent keeps recent generations up to the
KUBB_AGENT_MAX_GENERATIONScaps, with a separate budget for the initial output. Unchanged output keeps its ID across reconnects.
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.