{
 "kind": "tool",
 "slug": "commander",
 "path": "tools/commander/",
 "name": "Commander",
 "maker": null,
 "density": "full",
 "crumbs": [
  [
   "Tools",
   "tools/"
  ],
  [
   "Dev workflow and config",
   "tools/dev-workflow/"
  ]
 ],
 "lead": "Options and help for Node.js command-line tools.",
 "chips": [
  {
   "label": "Dev workflow and config",
   "path": "tools/dev-workflow/"
  },
  {
   "label": "NPM"
  }
 ],
 "primary": {
  "label": "Copy install command",
  "copy": "npm install commander"
 },
 "links": [
  {
   "label": "GitHub",
   "href": "https://github.com/tj/commander.js"
  },
  {
   "label": "Website",
   "href": "https://github.com/tj/commander.js#readme"
  }
 ],
 "track": "New versions, deprecation and license changes on your dashboard",
 "verdicts": [
  {
   "key": "license",
   "label": "License",
   "value": "MIT",
   "status": "yes",
   "sub": "Use it in paid apps",
   "quote": "without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software",
   "note": "MIT allows use in paid and closed-source products.",
   "src": "https://github.com/tj/commander.js/blob/master/LICENSE"
  },
  {
   "key": "maint",
   "label": "Maintained",
   "value": "Maintained",
   "status": "yes",
   "sub": "Last change Nov 19, 2026",
   "note": "Latest GitHub release Nov 7, 2026. ",
   "src": "https://github.com/tj/commander.js"
  },
  {
   "key": "pop",
   "label": "Used by agents' projects",
   "value": "174 projects",
   "status": "info",
   "sub": "#10 of 299 in its category",
   "note": "Dependency in 174 public GitHub projects set up for AI coding agents that we scanned (2.8%).",
   "src": null
  },
  {
   "key": "agent",
   "label": "Agent access",
   "value": "Install only",
   "status": "info",
   "sub": null,
   "note": "Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.",
   "src": null
  }
 ],
 "vfoot": "From the package registry and GitHub, checked daily; card checked Nov 10, 2026.",
 "blocks": [
  {
   "id": "overview",
   "nav": "Overview",
   "h2": "What Commander does",
   "parts": [
    {
     "t": "prose",
     "text": "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."
    },
    {
     "t": "h3",
     "text": "What people build with it"
    },
    {
     "t": "uses",
     "items": [
      {
       "title": "Turn a script into a tool with help",
       "text": "Your image script gets named options with defaults, and typing --help shows what each one does, without extra code.",
       "idea": false
      },
      {
       "title": "Clear errors for wrong values",
       "text": "When someone types a value your tool does not accept, it stops with a message that lists the allowed values.",
       "idea": false
      },
      {
       "title": "One tool with several commands",
       "text": "Like git, your tool has separate commands such as deploy and logs, each with its own options and help page.",
       "idea": false
      },
      {
       "title": "Read a setting from the environment",
       "text": "A required port or token can come from a flag or, when the flag is missing, from an environment variable; help names that variable.",
       "idea": false
      },
      {
       "title": "Commands that wait for the network",
       "text": "When a command downloads or uploads something, its code can wait for the result before the tool exits.",
       "idea": false
      },
      {
       "title": "Test your tool without quitting",
       "text": "Your tests run the tool with sample input many times in one process and check the errors instead of the test run ending.",
       "idea": false
      }
     ]
    }
   ]
  },
  {
   "id": "popularity",
   "nav": "Popularity",
   "h2": "Commander popularity",
   "parts": [
    {
     "t": "stats",
     "items": [
      {
       "n": "82",
       "of": "/ 100",
       "l": "Gid Score, #76 overall"
      },
      {
       "n": "788M",
       "l": "downloads a week, npm"
      },
      {
       "n": "28.5K",
       "l": "GitHub stars"
      },
      {
       "n": "174",
       "l": "agent projects use it"
      }
     ]
    },
    {
     "t": "small",
     "text": "Gid Score measures public popularity and activity, not quality.",
     "link": "How the Gid Score is calculated",
     "path": "tools/top/"
    }
   ]
  },
  {
   "id": "usage",
   "nav": "How it is used",
   "h2": "How Commander is used",
   "parts": [
    {
     "t": "list",
     "items": [
      "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%)."
     ]
    },
    {
     "t": "h3",
     "text": "By coding agent"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "127 projects, 3.9%",
       "v": "Claude Code",
       "path": "agents/claude-code/"
      },
      {
       "l": "64 projects, 2.1%",
       "v": "GitHub Copilot",
       "path": "agents/github-copilot/"
      },
      {
       "l": "56 projects, 2.3%",
       "v": "Cursor",
       "path": "agents/cursor/"
      },
      {
       "l": "44 projects, 13.2%",
       "v": "OpenClaw",
       "path": "agents/openclaw/"
      },
      {
       "l": "37 projects, 7.8%",
       "v": "Gemini CLI",
       "path": "agents/gemini-cli/"
      },
      {
       "l": "18 projects, 6.5%",
       "v": "Devin Desktop",
       "path": "agents/devin-desktop/"
      },
      {
       "l": "16 projects, 3.4%",
       "v": "OpenAI Codex",
       "path": "agents/openai-codex/"
      },
      {
       "l": "8 projects, 5.7%",
       "v": "Kiro",
       "path": "agents/kiro/"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Often used with"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "In 67.2% of its projects",
       "v": "chalk",
       "path": "tools/chalk/"
      },
      {
       "l": "In 61.5% of its projects",
       "v": "tsx",
       "path": "tools/tsx/"
      },
      {
       "l": "In 63.8% of its projects",
       "v": "Vitest",
       "path": "tools/vitest/"
      },
      {
       "l": "In 47.1% of its projects",
       "v": "Express",
       "path": "tools/express/"
      },
      {
       "l": "In 67.8% of its projects",
       "v": "Zod",
       "path": "tools/zod/"
      },
      {
       "l": "In 52.3% of its projects",
       "v": "dotenv",
       "path": "tools/dotenv/"
      },
      {
       "l": "In 39.1% of its projects",
       "v": "Model Context Protocol SDK (JavaScript)",
       "path": "tools/modelcontextprotocol/"
      },
      {
       "l": "In 38.5% of its projects",
       "v": "ws",
       "path": "tools/ws/"
      }
     ]
    }
   ]
  },
  {
   "id": "more",
   "nav": null,
   "spy_as": "usage",
   "h2": "More about Commander",
   "parts": [
    {
     "t": "more",
     "items": [
      {
       "title": "Funding",
       "path": "tools/funding/",
       "items": [
        "GitHub Sponsors: https://github.com/shadowspawn",
        "GitHub Sponsors: https://github.com/abetomo",
        "Tidelift: https://tidelift.com/funding/github/npm/commander",
        "4 GitHub sponsors"
       ]
      },
      {
       "title": "More in Dev workflow and config",
       "path": "tools/dev-workflow/",
       "items": [
        {
         "text": "dotenv",
         "path": "tools/dotenv/"
        },
        {
         "text": "Husky",
         "path": "tools/husky/"
        },
        {
         "text": "python-dotenv",
         "path": "tools/python-dotenv/"
        },
        {
         "text": "lint-staged",
         "path": "tools/lint-staged/"
        },
        {
         "text": "concurrently",
         "path": "tools/concurrently/"
        },
        {
         "text": "Rich",
         "path": "tools/rich/"
        },
        {
         "text": "Pydantic Settings",
         "path": "tools/pydantic-settings/"
        },
        {
         "text": "cross-env",
         "path": "tools/cross-env/"
        }
       ]
      }
     ]
    }
   ]
  },
  {
   "id": "alternatives",
   "nav": "Alternatives",
   "h2": "Alternatives",
   "parts": [
    {
     "t": "alts",
     "items": [
      {
       "name": "Commander",
       "me": true,
       "facts": [
        "MIT",
        "Gid 82",
        "788M/wk"
       ]
      },
      {
       "name": "yargs",
       "why": "Pick yargs when you want another widely used Node.js option parser with its own help and command style.",
       "path": "tools/yargs/",
       "facts": []
      },
      {
       "name": "meow",
       "why": "Pick meow for a very small Node.js tool where you write the help text yourself and only need flags parsed.",
       "path": "tools/meow/",
       "facts": []
      },
      {
       "name": "Click",
       "why": "Pick Click when your command-line tool is written in Python.",
       "path": "tools/click-py/",
       "facts": []
      }
     ],
     "more": "Compare Commander with another tool",
     "more_path": "tools/compare/"
    }
   ]
  },
  {
   "id": "start",
   "nav": "Get started",
   "h2": "Get started",
   "parts": [
    {
     "t": "prompt",
     "text": "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."
    },
    {
     "t": "steps",
     "items": [
      {
       "text": "Install Commander in a project that runs Node.js 22.12 or newer.",
       "code": "npm install commander",
       "src": "https://github.com/tj/commander.js/blob/master/Readme.md"
      },
      {
       "text": "Describe the options, call parse(), then read the values with opts().",
       "code": "import { program } from 'commander';\n\nprogram\n  .option('--first')\n  .option('-s, --separator <char>')\n  .argument('<string>');\n\nprogram.parse();\n\nconst options = program.opts();\nconst limit = options.first ? 1 : undefined;\nconsole.log(program.args[0].split(options.separator, limit));\n",
       "src": "https://github.com/tj/commander.js/blob/master/Readme.md"
      },
      {
       "text": "For anything bigger than a quick script, or for tests, create your own Command object instead of the shared one.",
       "code": "import { Command } from 'commander';\nconst program = new Command();\n",
       "src": "https://github.com/tj/commander.js/blob/master/Readme.md"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Mistakes to avoid"
    },
    {
     "t": "mistakes",
     "items": [
      {
       "dont": "const program = require('commander'); program.option(...)",
       "fix": "const { program } = require('commander'), or better import { Command } from 'commander' and new Command()",
       "why": "The default export of a global Command was removed from CommonJS in Commander 12."
      },
      {
       "dont": "import { Command } from 'commander/esm.mjs'",
       "fix": "import { Command } from 'commander'",
       "why": "Commander 15 removed the old esm.mjs entry."
      },
      {
       "dont": "program.parse() when an action is an async function",
       "fix": "await program.parseAsync(process.argv)",
       "why": "parse() does not wait for async actions, so errors and the end of the work can be lost."
      },
      {
       "dont": "program.parse(['--port', '80']) in a test",
       "fix": "program.parse(['--port', '80'], { from: 'user' })",
       "why": "Without from user, the first two items are treated as the node program and the script name and skipped."
      },
      {
       "dont": "Upgrading an old tool and passing extra words it never declared",
       "fix": "Declare every argument, or call .allowExcessArguments() if extra words are expected",
       "why": "Since Commander 13 extra command-arguments are an error by default."
      }
     ]
    }
   ]
  },
  {
   "id": "faq",
   "nav": "Questions",
   "h2": "Questions",
   "parts": [
    {
     "t": "faq",
     "items": [
      {
       "q": "Can I use it with require() in a CommonJS project?",
       "a": "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.",
       "evidence": {
        "url": "https://github.com/tj/commander.js/releases/tag/v15.0.0",
        "quote": "Commander 15 is ESM only, but this does not mean you need to migrate to ESM to use it."
       }
      },
      {
       "q": "Does it make the --help screen for me?",
       "a": "Yes. Help is built from the descriptions you give each option and argument; you can also add your own text.",
       "evidence": {
        "url": "https://github.com/tj/commander.js/blob/master/Readme.md",
        "quote": "Commander looks after parsing the arguments into options and command-arguments, displays usage errors for problems, and implements a help system."
       }
      },
      {
       "q": "How long are old versions supported?",
       "a": "Older major versions get security updates for 12 months. Version 14 is supported until 2027-05-29.",
       "evidence": {
        "url": "https://github.com/tj/commander.js/blob/master/Readme.md",
        "quote": "Older major versions of Commander receive security updates for 12 months."
       }
      },
      {
       "q": "Can options and arguments be checked automatically?",
       "a": "Yes. Unknown options, missing arguments and extra arguments are reported as errors when the command runs.",
       "evidence": {
        "url": "https://github.com/tj/commander.js/blob/master/Readme.md",
        "quote": "Any unknown options, missing arguments, or excess arguments will be reported as an error."
       }
      }
     ]
    }
   ]
  }
 ],
 "glance": [
  [
   "Package",
   "npm commander"
  ],
  [
   "Category",
   "Dev workflow and config"
  ],
  [
   "License",
   "MIT"
  ],
  [
   "Gid Score",
   "81.6"
  ],
  [
   "Rank in category",
   "#10 of 299"
  ],
  [
   "GitHub",
   "tj/commander.js"
  ],
  [
   "Last change",
   "Nov 19, 2026"
  ]
 ],
 "good": [
  "Version 15 needs Node.js 22.12 or newer and loads only as a modern module. Version 14 still gets security fixes until May 2027.",
  "It is strict. An unknown option or an extra word the person types stops the tool with an error, unless you allow it.",
  "After an error, the help or the version, it ends the whole program. In tests or long-running apps, switch that off with exitOverride()."
 ],
 "checked_line": "Read by AgentGid from 7 official pages, card checked Nov 10, 2026; numbers update daily.",
 "logo": "https://agentgid.com/media/avatars/tj.png"
}