Installation
# npmnpm install clibuilder
# yarnyarn add clibuilder
# pnpmpnpm add clibuilder
# rushrush add -p clibuilderRequirements
Section titled “Requirements”- Node.js 20.19 or newer.
- TypeScript is optional but recommended. The type inference in
run(args)is the main reason to useclibuilderover a hand-rolled parser; in plain JavaScript everything still works, you just don’t see the inferred types.
Module formats
Section titled “Module formats”clibuilder publishes both ESM and CJS, so either of these works:
// ESMimport { cli, command, z } from 'clibuilder'// CJSconst { cli, command, z } = require('clibuilder')clibuilder depends on zod and re-exports it as
z. Import it from clibuilder rather than installing zod separately —
that guarantees the schemas you build are the same zod instance the library validates with.
import { z } from 'clibuilder'Build something with it: Your First CLI.