Node.js Starter
A minimal template for building a Node.js library in TypeScript with ESM support and an optional CLI. Type checking, linting, and formatting are enforced on every commit, tests with 100% coverage run on every pull request, and every tag you push gets a draft GitHub release with the packed package attached. Publishing the draft then stages the same package on npm.
Getting Started
Create a new repository from this template on GitHub using this link, or clone it locally and point it at your own remote.
Setup
Install pnpm, then install dependencies:
pnpm install
Install Lefthook, then register the pre-commit hook:
lefthook install
Customizing
Replace or extend the template files to fit your project:
src/ — Replace the placeholder library, CLI, and tests with your own code.
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, and other metadata.
README.md — Replace with a description of your project.
If your project doesn't need a CLI, remove src/cli.ts, the bin entry in package.json, and the yargs and @types/yargs dependencies.
Development
Run the tests with coverage through Vitest:
pnpm vitest run
The project enforces 100% code coverage, counting only files the tests import.
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.
Releasing
Update the version in package.json, then push a version tag to create a draft release with notes generated by GitHub and the packed tarball attached. Review the draft on GitHub, edit the notes if needed, and publish it when it's ready.
To also publish to the npm registry, add an npm access token with publish rights as the NPM_TOKEN repository secret. Publishing the draft then stages the same tarball on npm, where you approve it to make it public.
Once the package exists on npm, you can replace the token with trusted publishing: add a trusted publisher on npm for your repository and publish.yaml, then delete the NPM_TOKEN secret after a release has staged through it.
If your project isn't published to npm, remove .github/workflows/publish.yaml.
Framework-Specific Templates
For a more opinionated starting point in a specific framework: