Skip to content

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))
Terminal window
npm install clibuilder

See Installation for other package managers, then walk through Your First CLI.