Typescript CLI template project

I have created a starter project for creating node cli commands with Typescript.

It comes with pre-configured / pre-installed:

  • yarn package manager
  • eslint with Typescript support
  • airbnb-typescript/base eslint profile
  • prettier for code formatting
  • husky with pre-configured for pre-commit and pre-push hooks
  • commander for handling command line argument and cli help.


You can clone the project from Github: https://github.com/killerchip/ts-cli-template

or use Github’s Generate from template project feature.

Once you cloned the project you might want to change project’s name in

  • package.json > name

  • package.json > bin key. This will be the cli command that your users will use when launching your program.

  • src/cli.ts: The name of your cli command in help files.

Entry point

Start building your code around src/index.ts that’s the entry point.

eslint and prettier

When you commit your code, the parts you touched will be automatically go through prettier transformation.

When you push your code, it will go also under eslint investigation. If problems found the code won’t be pushed.

Manually checking eslint rules:

yarn lint

Manually running prettier on all files, automatically formatting them.

yarn prettier

Modify .eslintignore, .eslintrc.js, .prettierignore, .prettierrc.js to adjust eslint and prettier behavior

See https://eslint.org/ and https://prettier.io/ for more details.


cli.ts has sample code for using commander to automatically build help description and handling command line options.

See https://www.npmjs.com/package/commander for more details.