Need help with cli-cheatsheet?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.


helpful libraries for *building* CLIs. Not a list of CLIs.

495 Stars 19 Forks MIT License 108 Commits 5 Opened issues

Services available

Need anything else?


helpful libraries and resources for building Node.js CLIs. Not a list of CLIs.

I put together a 90 minute Course and Workshop on how to put these tools together, if you like video learning. I also make some money if you watch those videos if you want to help :)

CLI Design Thinking


  • Commander: Built by TJ, used in
    , and many others. Key feature: pluggability. Vorpal is another framework inspired by Commander and is seeking maintainers
  • Oclif: Built by Heroku, used in Heroku and Salesforce CLI's. Key feature: pluggability.
  • Sade: Built by lukeed, used in tsdx. Key feature: lightweight?
  • Gluegun: Built by Infinite Red, used in Ignite and AWS Amplify. Key feature: templating/filesystem
  • Ink: Built by Vadim & Sindre. Key Feature: React Components and Yoga Layout. See also import-jsx
  • Scritch: Built by Jamie, used at Eventbrite. Key Feature: compose multiple scripts regardless of language into one CLI.
  • Yargs: Built by bcoe, used by
    , and 14,343 other modules.
  • arg: Built by Vercel, used by
    , and many others. Key Feature: tiny
  • cac: Built by Egoist, used by
    and many others.
  • Pastel for React-ink - used in Twilio

New: see CLUI

Inspiration from other languages - the universe.

Utility Libraries

Performance Optimization

For performance logging, you can try

instead of
(altho the latter uses the former under the hood)

Update Management/Nagging



Context from Git/CI

  • - Parse .git/config into a JavaScript object. sync or async.

Context from filesystem/PATH

  • Like running
    : Find the first instance of an executable in the PATH.
  • filesystem access
  • search up the parents path for where files are located
  • to simulate Node
    • generate relative filepaths e.g.
      relative('a/b/c', 'a/d') // ../../d
  • if dealing with yarn workspaces:
  • File watching
    • (copying with watch functionality)
    • (recommended)
    • Sapper Watcher
    • VSCode's per-platform watchers
  • File finding
    • (dominant)
    • Turn a path string such as /user/:name into a regular expression.
  • Dependency resolution

Config validation

  • used by React Native CLI for validation
  • from Jest but not Jest specific

Loading config from json, rc file, etc*

  • Find and load configuration from a package.json property, rc file, or CommonJS module. Check
    to implement XDG spec compliance.
    • replaces, an old rc-file finder with some different design choices

don't need but nice to know:

Beware the race condition when you check if file exists and then open it. the file could be deleted in betwee. instead, just open the file and handle the error if it doesnt exist.

Loading/Storing config from a persistent store

⚠️ Be aware of the XDG spec. Sindre's libraries use

to get paths compliant with this.

  • simple config storing (maybe try conf-cli to manipulate if needed) the successor to configstore
  • conf like datastore but in the shclinkerverse


  • (recommended)
    • combine with for fuzzy matching

Stdin Parsing

  • (eg when you want to receive pipe results
    cat mydata.json | mycli

Argument Parsing

  • (hasn't been updated in a while though)

⚠️ Your framework may come with parsing built in

Input/Stdin/Argument Processing

make sure to also normalize inputted stuff before you compare

  • path.resolve(str1) === path.resolve(str2)


Command execution

  • - xplatform shell command execution
  • (also a cross platform solution to node's spawn and spawnSync)
  • (recommended)

Remember Windows users for cross-platform nodejs (Guide). e.g. dont execute pkg.json or shell commands with single quotes instead of escaped double quotes

Sometimes processes can spawn processes. This is troublesome for watch/reload features. Kill them all with


You'll probably also use these in conjunction with port monitors (e.g. the process you're working with opens a port, like CRA for Netlify Dev):


If child_processes are going to be a key part of your CLI, be sure to read the docs and this guide to be aware of the API.

You may also want to poll for conditions to be true to execute async processes:



  • (recommended)
  • Log by overwriting the previous output in the terminal. Useful for rendering progress bars, animations, etc.
  • for progress lists
  • remembers previous execution times, estimates them next time


  • (Gluegun has this built in)
  • (sindresorhus' templating)
  • (string replace with multiple matches)
  • (copy files using streams)
  • Mustache and handlebars
  • Liquid templating (from Shopify)
  • "basically glue code between inquirer prompts and handlebar templates"
  • Angular Schematics
  • Yeoman generator
    • specifically you can just use the filesystem commands

Temp folders

  • (create unique temp directories)
  • (very popular. can remove on exit)



  • ensure directory exists:
    • simple replacement for
    • also
  • encrypt files:
  • writing large files:
  • navigating node_modules using the same package npm uses:

Icons & Coloring

  • (recommended - also see Related Packages)
  • (some interesting APIs, handy with React Ink)
  • (colored xplatform unicode symbols for success/info/warning/error)
  • (Unicode symbols with Windows CMD fallbacks)
  • VERY nice color gradient text

Note that you may want to offer the option to FORCE_COLOR in CI logging.



there are also react based renderers

  • react ink


  • Get Terminal Size





Debug Logging

  • (note that you might not need this, Node's inbuilt
    does a lot of the same h/t @stefanjudis)
  • React Native CLI has very simple logging with verbose mode you can still with just chalk dependency
  • In Github Issue Templates, tell your users to report versions:

You often also find specialized logger tools for each domain, like @dazn/lambda-powertools-logger for AWS Lambda, but at their core they all support the core pattern of Log Levels


Plugin/Release Management

  • (used in npm cli)
  • (very low level pull from github)
  • (get package names as if local files were modules)

⚠️ None of these are offline-first. Keen on finding one that respects offline first.

Dependency installs and Upgrading Scaffolds

import { spawn, hasYarn } from 'yarn-or-npm'
// optionalDir for installing?
const prefixFlag = hasYarn() ? '--cwd' : '--prefix'
spawn.sync(['install', prefixFlag, optionalDir], { stdio: 'inherit' })

Error Stacks/Error Handling

  • Removes the mostly unhelpful internal Node.js entries.
  • Captures and cleans stack traces
  • node-cleanup - add a callback for when Node is terminated

Serving Files

  • zero dependency fileserver focused on SPA usecase
  • general local fileserver utility
  • lukeed's alternative to


  • for
    like UI
  • general Heroku CLI utils including OS notification
  • Generate all the recommended files (pre-filled) for the Github community standards. (Issue templates, code of conduct, etc)
  • packaging as executable (so no requirement for node or npm)
  • generate READMEs
  • disable clearing of screen like with React-Scripts
  • for parsing a directory of markdown files into json, just wonderful
    • Other Markdown tools
    • gray-matter
    • remark
  • for randomized selection from a list
  • UUID for tagging a machine for analytics. see also
  • redact env var secrets
  • record terminal session as animated svg for docs
  • for 3d animated scenes in the terminal (idk dont ask)
  • node-cleanup - add a callback for when Node is terminated

New: see CLUI

Other useful lists


Beginner Tutorials


We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.