Skip to content
Commands

kubb add

The add command installs a plugin, adapter, or parser from the Kubb extension registry at its reviewed version and adds a plugin to kubb.config.ts.

Run kubb add to install an extension from the Kubb registry at the version the registry pins. For a plugin, it also adds the plugin to kubb.config.ts. For an adapter or parser, it prints the code to add.

Usage

Add an official plugin by its slug:

Terminal
kubb add plugin-zod

Add a community plugin by its full id, without the confirmation:

Terminal
kubb add acme/plugin-graphql --yes

Edit the config without installing the package:

Terminal
kubb add plugin-zod --no-install

Arguments

ArgumentRequiredDescription
<id>trueRegistry id as <owner>/<slug>, such as kubb-labs/plugin-react-query. A bare <slug> means kubb-labs/<slug>. Both parts use lowercase letters and digits joined by single hyphens.

Options

OptionDefaultDescription
--config=<path>, -c <path>Path to the Kubb config to edit. Only used for plugins. Without it, the CLI looks for the same config files as kubb generate, in the current directory and then in each parent directory.
--yes, -yfalseSkip the confirmation.
--no-installDo not install the package. A plugin is still added to the config.

What it does

  1. Fetches <registry>/<owner>/<slug>.json. An unknown id fails with "<id>" is not in the registry at <registry>.
  2. Checks the manifest's compatibility against the running Kubb and Node.js versions. A mismatch fails with the same message Kubb prints at runtime, such as "plugin-zod" requires Node.js >=22, but 20.11.0 is running.
  3. For a plugin, finds the config file. Without one, it fails with No kubb.config.ts found. Run `kubb init` first, or pass --config.
  4. Prints the extension's name, kind, and description, the <package>@<version> it installs, and the config file it edits. Then it asks Continue? unless you pass --yes.
  5. Installs <package>@<version> as a dev dependency with the package manager of the current directory.
  6. For a plugin, adds import { <export> } from '<package>' and a <export>() call at the end of the plugins array. A plugin already in the array is left alone. For an adapter or parser, it prints the import and the adapter or parsers property to merge into defineConfig.

The package manager comes from the packageManager field in package.json, then from a lock file (pnpm-lock.yaml, yarn.lock, bun.lock or bun.lockb, package-lock.json). Without either, the CLI uses npm.

When the config cannot be edited, the CLI prints Could not edit <file>: <reason> and the snippet to add by hand. This happens when plugins is not an array literal, or when the export name is already imported from another package.

Pass --yes in scripts and CI, where no one can answer the prompt.

Environment variables

VariableDefaultDescription
KUBB_REGISTRYhttps://kubb.dev/registryBase URL of the registry to read. It must start with http:// or https://. Trailing slashes are removed. See Host your own registry.

Exit codes

kubb add exits with code 1 when the id is invalid, the registry cannot be read or sends an invalid entry, the extension is incompatible, no config is found for a plugin, or the install fails. It exits with code 0 when you cancel at the prompt, and when it prints the snippet because the config could not be edited.

See also