ts-starter
A personal starter template for TypeScript libraries built to hold my own work to an unreasonable standard.
Source: README on GitHub
A personal starter template for TypeScript libraries built for strictness: nothing merges without passing every gate. 100% coverage, tiny bundles, automated releases, signed publishes. Designed for my own projects. You are welcome to use it too, but I built it to hold my own work to an unreasonable standard.
Customization
Every step below calls out the file and field you need to change. Do not skip anything — the configs reference the package name, repo path, or version directly, and placeholders will break CI.
cp -r ts-starter my-library && cd my-library
rm -rf .git && git init
rm CHANGELOG.md 2>/dev/null # will be generated by Release Please
2. package.json
| Field | What to change |
|---|---|
name | Your npm package name (e.g. @scope/my-lib). Update this and the npm badge URL in the README. |
version | Start at 0.0.0. Release Please manages this from the first merged PR on. |
description | A one-line summary of what the library does. |
exports | Update any sub-path exports if your entry structure changes. The ts-starter reference in attw output comes from name. |
engines.node | Adjust the minimum Node version if needed. |
size-limit[].limit | After your first pnpm build, run pnpm size to see actual sizes, then set realistic limits here. |
packageManager | Should match pnpm --version. Update if you use a different locked pnpm version. |
3. README.md
- Replace every
OWNER/REPOwith your GitHub handle and repo name (badges, endpoint URLs, links). - Replace the npm version badge URL (
ts-starter) with your package name. - Rewrite the description and stack badges to match your project.
4. Source code
- Delete
src/math.ts,src/math.test.ts,src/result.ts, andsrc/result.test.ts. - Delete the
@/imports fromsrc/index.tsor rewrite it as your own barrel. - Write your library. Keep test files alongside source (
src/foo.test.ts). The@alias (@/) resolves tosrc/.
5. Biome (optional)
- Review
biome.jsonrule overrides. The preset isrecommendedwith 48 additional strict rules. Tune anything that does not match your style. Rules that are too opinionated can be set to"off".
6. Size Limit
- Update
size-limitentries inpackage.jsonto match your exported symbols. Theimportfield should use the actual named exports your consumers will tree-shake.
pnpm install
pnpm preflight
Everything should be green before you push your first commit. If preflight fails, fix the issue before continuing — the same gates run in CI.
git add -A
git commit -m "chore: initialize from ts-starter template"
git branch -M main
git remote add origin git@github.com:OWNER/REPO.git
git push -u origin main
9. GitHub repository settings
- Secrets: add
NPM_TOKEN(an npm automation token from npmjs.com). If you use npm OIDC instead, you can drop the token and configureid-token: writeinpublish.ymlto use the built-inGITHUB_TOKEN. - Actions permissions: under Settings > Actions > General, set Allow all actions and reusable workflows, enable Read and write permissions, and check Allow GitHub Actions to create and approve pull requests. Without this last one, Release Please cannot open release PRs.
- Branch protection (optional but recommended): require the
cistatus check to pass before merging tomain.
10. npm publishing
- If you published the package namespace before, make sure the name in
package.jsonis available on npm (npm view <name>should 404). - The first Release Please PR will bump
0.0.0to1.0.0. Merge it and the package publishes. - You can also publish manually: tag a commit with
v1.0.0, push the tag, andpublish.ymlhandles the rest.
Scripts
| Script | What it does |
|---|---|
pnpm build | Build ESM + CJS with tsup, then emit declarations with tsc |
pnpm dev | Watch mode for development |
pnpm check | Biome lint and format check |
pnpm check:fix | Auto-fix lint and format issues |
pnpm typecheck | Type-check both tsconfigs with TypeScript 7 |
pnpm test | Run tests |
pnpm test:coverage | Run tests with coverage (100% per-file enforced) |
pnpm test:watch | Watch mode for tests |
pnpm size | Check bundle sizes against budget |
pnpm knip | Find dead code and unused dependencies |
pnpm run audit | Security audit (fails on high or critical) |
pnpm pubcheck | Validate package exports and types (publint + attw) |
pnpm preflight | Run everything. If this is green, it ships. |
How a Release Works
- Write Conventional Commits (
feat:,fix:, etc.) - Open a PR to
main. CI runs lint, types, tests, coverage, build, size, dead code, audit, and package checks. - Merge the PR. Release Please opens or updates a Release PR with the next version and a changelog.
- When you are ready to ship, merge the Release PR. Release Please bumps the version, updates
CHANGELOG.md, creates a Git tag, and publishes a GitHub Release. - The tag dispatches
publish.yml: it checks out the tag, verifies the version matchespackage.json, builds, and runspnpm publish --provenance.
You can also publish manually by pushing a v* tag or running the publish.yml workflow dispatch from the Actions tab.