A minimal template for building a Node.js library in TypeScript with ESM support and an optional CLI. Ships pre-configured with formatting, linting, 100% test coverage enforcement, pre-commit hooks, and CI.
Create a new repository from this template on GitHub using this link, or clone it locally and point it at your own remote.
Install pnpm, then install dependencies:
pnpm installInstall Lefthook, then register the pre-commit hook:
lefthook installReplace or extend the template files to fit your project:
src/cli.ts— Replace or remove the placeholder CLI. Remove this file, thebinentry inpackage.json, and theyargsand@types/yargsdependencies if your project doesn't need a CLI.src/fibonacci.ts— Replace with your own library logic.src/index.ts— Update the public API exports to match your library.CLAUDE.md— Replace with guidance specific to your project.LICENSE— Replace with your preferred license, or keep the Unlicense.package.json— Update the package name, description, version, author, and other metadata.README.md— Replace with a description of your project.
Write code in src/. Test files live alongside source as *.test.ts. Run the test suite with:
pnpm vitest runThe project enforces 100% code coverage on every run.
Each git commit runs the pre-commit hook registered during setup, which checks your changes and fixes what it can in place. If it fails, fix any reported issues, re-stage the changed files, and commit again.
After committing, push to main or open a pull request from another branch — CI will run the same checks across all files, plus additional checks of its own.
Update the version in package.json, push a version tag, and create a GitHub Release. To publish to the npm registry, run:
pnpm publishFor a more opinionated starting point in a specific framework:
- Action Starter — JavaScript GitHub Action projects.
- Discord Bot Starter — Discord bot projects.
- React Starter — React app projects.