clibuilder
Build a command line application out of typed commands, config files, and plugins.
clibuilder builds command line applications from commands. Each command declares its own
arguments, options, and config schema with zod, and the types of
what run() receives are inferred from those declarations — no separate type definition to keep in
sync.
import { cli, z } from 'clibuilder'
cli({ name: 'greet', version: '1.0.0' }) .default({ arguments: [{ name: 'name', description: 'who to greet' }], options: { times: { description: 'how many times', type: z.number(), default: 1 } }, run(args) { // args.name is string, args.times is number for (let i = 0; i < args.times; i++) this.ui.info(`hello, ${args.name}`) } }) .parse(process.argv) .catch(e => process.exit(e?.code || 1))What you get
Section titled “What you get”Commands & sub-commandsNest commands to any depth — my-cli repo create — with aliases and a generated help message.
Typed arguments & optionsDeclare with zod; run(args) is typed from the declaration, and input is validated before it runs.
Config filesJSON, YAML, cjs, or mjs — resolved by convention from the CLI name and validated per command.
PluginsShip commands as separate packages and let a config file load them into your CLI.
TestingtestCommand() runs a command in-process and hands back its result and its UI messages.
ESM and CJSBoth module formats are published, so it works whichever way your project consumes packages.
Install
Section titled “Install”npm install clibuilderSee Installation for other package managers, then walk through Your First CLI.