Skip to content
Commands

kubb generate

The generate command runs the Kubb code-generation pipeline based on your kubb.config.ts.

Run kubb generate to read your kubb.config.ts and run the code-generation pipeline. It's the default command, so running kubb with no arguments does the same.

Usage

Generate from the input set in your config:

Terminal
kubb generate

Pass an input file to override the config:

Terminal
kubb generate ./petStore.yaml

Arguments

ArgumentDescription
[input]Optional path, URL, or git input (git+<repo>#<ref>:<path>) of a Swagger/OpenAPI document. Overrides the input set in the config.

Options

OptionDefaultDescription
--config=<path>, -c <path>Path to a config file, such as ./kubb.staging.ts.
--log-level=<silent|info|verbose>, -linfoSet the verbosity. Use verbose to see plugin timings.
--silent, -sfalseForce the log level to silent. Suppresses output.
--verbosefalseForce the log level to verbose. Shows slow plugins.
--reporter=<cli|json|file|html>Pick which reporters to trigger, comma-separated. Defaults to cli.
--watch, -wfalseRe-run the pipeline whenever the local input file changes.
--dry-runfalsePreview a run without writing files, formatting, linting, or running post-generate commands. The summary shows planned file changes compared with disk.

--reporter takes no short flag. The camelCase spellings from v4 (--logLevel, --dryRun) still work and print a deprecation warning.

--watch follows a local input file only. A URL or git input is generated once, so rerun Kubb after the remote spec changes.

In --watch mode, each rebuild line shows the duration and the schemas and operations the spec gained or lost; the summary below it lists the files it added, modified, or removed. In an interactive terminal, press r to rebuild and q to quit.

Reporters

A reporter decides how a run is rendered. The config registers available reporters with reporters. --reporter picks which ones to trigger by name, comma-separated (--reporter cli,file). Four reporters are registered by default.

The CLI summary starts with the outcome and duration, then labels plugin results and the output path. Files with unchanged content are counted separately, including when output.clean rewrites the output directory.

Summary
✓ Generation complete  466ms

  17 files generated · 54 unchanged
  Plugins  4 passed
  Output   ./src/gen

File changes
  14 added · 3 modified · 1 deleted
  Lines  +312 −47

File changes compare filesystem output with its contents before the run. Custom storage drivers omit this section. Line totals compare counts of each line, so moving a line within a file does not count as a removal and addition. With --dry-run, the summary says “planned” and “Nothing was written.” Plain terminals and AI agent sessions show the same summary.

ReporterOutput
cliThe end-of-run summary in the terminal. Default. Uses plain text in non-interactive terminals and AI agent sessions.
jsonA machine-readable report on stdout for CI. See Diagnostics for the full JSON shape.
fileThe run's diagnostics, written to .kubb/kubb[-<name>]-<timestamp>.log. The <name> segment is dropped when the config has no name. A run without diagnostics writes no file.
htmlA browsable report directory with generated files and diagnostics, written to .kubb/kubb[-<name>]-<timestamp>/index.html.

Write a log file:

Terminal
kubb generate --reporter file

Print a JSON report for CI. The exit code is non-zero on any error:

Terminal
kubb generate --reporter json