Skip to content
Clercv2

Typed CLIs for Node.js

Define commands once with route signatures and Standard Schema. Parsing, types, help output, completions, and MCP derive from one definition.

Get Started
cli.ts
import { Types, clerc } from "clerc";

const cli = clerc({
  name: "acme",
  version: "2.0.0",
  description: "Build and deploy TypeScript services",
});

cli.command("deploy <env> [region]", {
  aliases: "d",
  args: {
    env: Types.Enum("staging", "prod"),
    region: { default: "us-east-1" },
  },
  flags: {
    port: {
      type: Types.Integer({ min: 1, max: 65_535 }),
      short: "p",
      default: 3000,
    },
    dryRun: { type: Boolean, short: "n" },
    tags: {
      type: String,
      multiple: true,
      short: "t",
      delimiter: ",",
    },
    json: Boolean,
    yaml: Boolean,
  },
  rules: ({ exclusive, flag }) => [exclusive(flag("json"), flag("yaml"))],
  run({ args, flags, log }) {
    log.step(
      `Deploying to ${args.env} (${args.region})`,
      `port=${flags.port}`,
    );
    if (flags.dryRun) {
      log.box.info("Dry run", "No remote changes.");
    } else {
      log.success(`Deployed ${args.env}`);
    }
  },
});
acme — zsh
exit 0

Released under the MIT License