@kubb/cli
Generate files based on a kubb.config.ts configuration file using the Kubb CLI. The CLI displays progress updates including plugin execution status, file counts, and timing information during generation.
Installation
bun add -d @kubb/clipnpm add -D @kubb/clinpm install --save-dev @kubb/cliyarn add -D @kubb/cliUsage
kubb --config kubb.config.tsUSAGE kubb generate
COMMANDS
generate [input] Generate files based on a 'kubb.config.ts' file
validate Validate a Swagger/OpenAPI file
mcp Start the server to enable the MCP client to interact with the LLM.
Use kubb <command> --help for more information about a command.kubb generate
Generate files based on a kubb.config.ts file
TIP
kubb generate and kubb will call the same generate functionality.
USAGE kubb generate [OPTIONS]
OPTIONS
-c, --config Path to the Kubb config
-l, --logLevel=<silent|info|verbose|debug> Log level control
-w, --watch Watch mode based on the input file
-v, --verbose Override logLevel to verbose (shows plugin timings)
-s, --silent Override logLevel to silent (shows plugin timings)
-d, --debug Override logLevel to debug (shows all details)
-h, --help Show helpPath of the input file(overrides the one in kubb.config.js)
kubb petStore.yamlOptions
--config (-c)
Path to the Kubb config.
kubb --config kubb.config.ts--log-level (-l)
silent: suppresses all log messages, warnings, and errorsinfo: logs warnings, errors, and informational messages (default)verbose: adds plugin timing breakdown and performance metricsdebug: shows all messages fromverboseplus detailed execution traces
kubb --log-level verbose--verbose (-v)
Enables verbose logging with plugin performance metrics. The summary shows plugin execution times and performance breakdown.
Output includes:
- Plugin timing breakdown with visual bars
- Performance metrics for slowest plugins
- All info-level messages
kubb --verbose--debug
TIP
Debug mode creates detailed log files in the .kubb directory:
.kubb/kubb-{name}-{timestamp}.log- Contains all debug messages with timestamps
After each generation completes, the CLI will display the exact location of the debug log file.
Debug mode provides comprehensive logging including:
- Setup phase details (configuration, plugins, paths)
- Plugin installation and execution timing
- Hook execution with duration measurements
- Schema parsing information
- File generation progress with paths
- Formatter/linter execution details
- Error messages with full stack traces
Use debug mode for:
- Troubleshooting generation issues
- Understanding plugin execution flow
- Performance analysis
- Debugging schema parsing problems
Alias for kubb generate --log-level debug
kubb --debugSee the Debugging Guide for more details on using debug mode.
--watch (-w)
Watch mode based on the input file.
kubb --watch--version (-v)
Output the version number.
kubb --version--help (-h)
Display the help.
kubb --helpkubb validate
Check syntax and structural errors in Swagger/OpenAPI files. The command provides feedback as errors or warnings.
Use in CI pipelines, pre-commit hooks, and development for early error detection.
IMPORTANT
@kubb/oas should be installed
TIP
The validation uses oas-normalize to validate Swagger/OpenAPI files.
USAGE kubb validate [OPTIONS]
OPTIONS
-i, --input Path to Swagger/OpenAPI file
-h, --help Show helpOptions
--input (-i)
Path to the Swagger/OpenAPI file.
kubb validate --input petstore.yamlkubb mcp
Start a Model Context Protocol (MCP) server that exposes Kubb's code generation to AI assistants like Claude, Cursor, and other MCP-compatible tools.
The MCP server allows AI assistants to generate code from OpenAPI specifications using conversational commands.
IMPORTANT
@kubb/mcp should be installed to use this command.
bun add -d @kubb/mcppnpm add -D @kubb/mcpnpm install --save-dev @kubb/mcpyarn add -D @kubb/mcpUsage
npx kubb mcpThis starts an MCP server that communicates via stdio (standard input/output). MCP clients like Claude Desktop and Cursor can connect to this server.
For more information about configuring MCP for Kubb, see using Kubb MCP.