Skip to content
Agents tracked: 506 Releases (7d): 634 Agent status: 4 with issuesSince last limit reset: Claude 15d · Codex 0d For AI agents: Markdown Updated Nov 26, 2026

Commander

Options and help for Node.js command-line tools.

Dev workflow and configNPM

GitHubWebsite

1. License

“without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software”

MIT allows use in paid and closed-source products.

github.com/tj/commander.js/blob/master/LICENSE

From the package registry and GitHub, checked daily; card checked Nov 10, 2026. Tap a verdict to see its source.How we checkedReport an error

What Commander does

Commander is a free JavaScript package for building command-line tools in Node.js. You describe the options your tool takes, and it reads what the person typed, shows a help screen and prints a clear error for wrong input. Your assistant writes less code to turn a script into a proper tool.

What people build with it

Turn a script into a tool with help

Your image script gets named options with defaults, and typing --help shows what each one does, without extra code.

Clear errors for wrong values

When someone types a value your tool does not accept, it stops with a message that lists the allowed values.

One tool with several commands

Like git, your tool has separate commands such as deploy and logs, each with its own options and help page.

Read a setting from the environment

A required port or token can come from a flag or, when the flag is missing, from an environment variable; help names that variable.

Commands that wait for the network

When a command downloads or uploads something, its code can wait for the result before the tool exits.

Test your tool without quitting

Your tests run the tool with sample input many times in one process and check the errors instead of the test run ending.

Commander popularity

82 / 100
Gid Score, #76 overall
788M
downloads a week, npm
28.5K
GitHub stars
174
agent projects use it
Commander: downloads per weeknpm, commander 788,288,057
Commander: GitHub starstj/commander.js 28,466

Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated

How Commander is used

  • Commander is a dependency in 174 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (3.6% of the 4,867 JavaScript/TypeScript ones), #10 of 299 in dev workflow and config.
  • Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 558; those are left out of every share on this page.
  • Projects that use it most often also use chalk (67.2%), tsx (61.5%), Vitest (63.8%).
  • It is more common in projects set up for OpenClaw (13.2%) than for GitHub Copilot (2.1%).

By coding agent

127 projects, 3.9%
64 projects, 2.1%
56 projects, 2.3%
44 projects, 13.2%
37 projects, 7.8%
18 projects, 6.5%
16 projects, 3.4%
8 projects, 5.7%

Often used with

In 67.2% of its projects
In 61.5% of its projects
In 63.8% of its projects
In 47.1% of its projects
In 67.8% of its projects
In 52.3% of its projects
In 38.5% of its projects

More about Commander

Funding
  • GitHub Sponsors: https://github.com/shadowspawn
  • GitHub Sponsors: https://github.com/abetomo
  • Tidelift: https://tidelift.com/funding/github/npm/commander
  • 4 GitHub sponsors

See all

More in Dev workflow and config

Alternatives

Commander This page

MITGid 82788M/wk

yargs

Pick yargs when you want another widely used Node.js option parser with its own help and command style.

meow

Pick meow for a very small Node.js tool where you write the help text yourself and only need flags parsed.

Click

Pick Click when your command-line tool is written in Python.

Compare Commander with another tool

Get started

Tell your AI assistant

“Use commander 15.1.0 (pin it; Node.js 22.12+, ESM import) to give my script named options with defaults, allowed values via Option().choices(), a --help screen and a version flag; use parseAsync() if any action is async and exitOverride() in tests.”

  1. Install Commander in a project that runs Node.js 22.12 or newer.

    npm install commander

    From github.com/tj/commander.js/blob/master/Readme.md

  2. Describe the options, call parse(), then read the values with opts().

    import { program } from 'commander';
    
    program
      .option('--first')
      .option('-s, --separator <char>')
      .argument('<string>');
    
    program.parse();
    
    const options = program.opts();
    const limit = options.first ? 1 : undefined;
    console.log(program.args[0].split(options.separator, limit));
    

    From github.com/tj/commander.js/blob/master/Readme.md

  3. For anything bigger than a quick script, or for tests, create your own Command object instead of the shared one.

    import { Command } from 'commander';
    const program = new Command();
    

    From github.com/tj/commander.js/blob/master/Readme.md

Mistakes to avoid

const program = require('commander'); program.option(...)
const { program } = require('commander'), or better import { Command } from 'commander' and new Command()

The default export of a global Command was removed from CommonJS in Commander 12.

import { Command } from 'commander/esm.mjs'
import { Command } from 'commander'

Commander 15 removed the old esm.mjs entry.

program.parse() when an action is an async function
await program.parseAsync(process.argv)

parse() does not wait for async actions, so errors and the end of the work can be lost.

program.parse(['--port', '80']) in a test
program.parse(['--port', '80'], { from: 'user' })

Without from user, the first two items are treated as the node program and the script name and skipped.

Upgrading an old tool and passing extra words it never declared
Declare every argument, or call .allowExcessArguments() if extra words are expected

Since Commander 13 extra command-arguments are an error by default.

Questions

Can I use it with require() in a CommonJS project?

Commander 15 is ESM only, but Node.js 22.12+ can load it from CommonJS. If your test runner or bundler cannot, stay on Commander 14 for now.

Does it make the --help screen for me?

Yes. Help is built from the descriptions you give each option and argument; you can also add your own text.

How long are old versions supported?

Older major versions get security updates for 12 months. Version 14 is supported until 2027-05-29.

Can options and arguments be checked automatically?

Yes. Unknown options, missing arguments and extra arguments are reported as errors when the command runs.