Skip to content

Installation

Terminal window
# npm
npm install clibuilder
# yarn
yarn add clibuilder
# pnpm
pnpm add clibuilder
# rush
rush add -p clibuilder
  • Node.js 20.19 or newer.
  • TypeScript is optional but recommended. The type inference in run(args) is the main reason to use clibuilder over a hand-rolled parser; in plain JavaScript everything still works, you just don’t see the inferred types.

clibuilder publishes both ESM and CJS, so either of these works:

// ESM
import { cli, command, z } from 'clibuilder'
// CJS
const { 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.