Production-ready GitHub template for Node.js library/package projects with enterprise-grade CI/CD pipelines, security scanning, and automated release management.
-
Update
package.json:- Change
nameto your package name - Update
description,author,repository,homepage - Adjust
keywords
- Change
-
Choose your bundler (see Bundler Configuration):
- Keep tsdown (default, recommended)
- Or switch to pkgroll (simpler)
- Or keep both (compare outputs)
-
Trusted Publishers (for automated releases):
- Configure NPM Trusted Publishers for secure publishing
- No manual token management required
-
Configure repository settings (recommended):
Pull Request Settings (Settings β General β Pull Requests):
- β Always suggest updating pull request branches
- β Allow auto-merge
- β Automatically delete head branches
- β Auto-close issues with merged linked pull requests
- β Allow squash merging + Default to pull request title
β οΈ Disable merge commits (for cleaner history)
GitHub Actions (Settings β Actions β General β Workflow permissions):
- β Allow GitHub Actions to create and approve pull requests
- β Default GITHUB_TOKEN: Read-only (least privilege)
- β Fork workflows: Require approval for first-time contributors
Security Settings (Settings β Code security and analysis):
- β Dependabot alerts (vulnerability notifications)
- β Dependabot security updates (auto PRs for security issues)
- β Dependabot version updates - DISABLE (use Renovate instead)
- β Secret scanning + Push protection
- β Code scanning (CodeQL)
- β Private vulnerability reporting
Renovate Setup (Dependency Management):
- Install: https://github.com/apps/renovate
- Config in
/renovate.json: auto-merge patch updates + minor devDeps - Why Renovate? Better grouping, scheduling, automerge than Dependabot
- Validate:
npx -p renovate -c 'renovate-config-validator'
Repository Features (Settings β General β Features):
- β Issues
- β Wikis (use
docs/instead) β οΈ Projects, Discussions, Sponsorships (optional)
-
Configure branch protection (recommended):
Settings β Branches β Add rule for
mainEssential (Solo Developer):
- β Require status checks to pass
- β Restrict force pushes
- β Restrict deletions
Recommended (Best Practice):
- β
Require pull request before merging
- Required approvals: 1
- Dismiss stale approvals
- β
Require status checks to pass
- Require branches up to date
- β Require conversation resolution
- β Require linear history
- β Lock branch
- β Restrict force pushes
- β Restrict deletions
Optional:
β οΈ Require signed commits (enhanced security)β οΈ Require Code Owners review
Required Status Checks (must run workflows first):
test-summary- All tests passactionlint- Workflow validationdependency-review- Dependency securitynpm-audit- Security scan (conditional)
Verification:
git push origin main # Should fail git push --force origin main # Should fail
-
Start coding!:
- Write tests first (TDD methodology)
- Replace sample code in
src/index.ts - Update tests in
tests/index.test.ts
-
Automatic shebang handling (for CLI projects):
- pkgroll automatically adds
#!/usr/bin/env nodeto files inbinfield - tsdown requires manual configuration:
// tsdown.config.ts export default defineConfig({ outputOptions: { banner: '#!/usr/bin/env node\n' } })
- pkgroll automatically adds
-
pkgroll approach (zero-config):
{ "type": "module", "bin": { "mycli": "./dist/cli.js" }, "exports": { ".": { "import": "./dist/index.mjs" } } } -
tsdown approach (explicit config):
// tsdown.config.ts export default defineConfig({ entry: { cli: 'src/cli.ts', index: 'src/index.ts' }, format: ['esm'], shims: true })
-
Lazy loading subcommands (optional pattern):
const commands = { init: () => import('./commands/init.js'), build: () => import('./commands/build.js') } const [command] = process.argv.slice(2) const module = await commands[command]?.() await module?.run()
npm run dev # TypeScript watch mode (tsdown by default)
npm run build # Build with default bundler (tsdown)
npm run build:tsdown # Build with tsdown (fast, plugins, frameworks)
npm run build:pkgroll # Build with pkgroll (zero-config, tree-shaking)
npm test # Run Vitest tests
npm run test:watch # Run tests in watch mode
npm run test:ui # Interactive test UI
npm run coverage # Generate coverage report
npm run typecheck # TypeScript type checking
npm run check # Run BiomeJS check (lint + format)
npm run format # Format code with BiomeJS
npm run lint # Lint code with BiomeJSWe follow Test-Driven Development (TDD):
- Write test first (Red) - Write failing test
- Implement code (Green) - Make test pass
- Refactor (Refactor) - Improve while tests stay green
See CONTRIBUTING.md for detailed TDD workflow examples.
Pre-commit:
- BiomeJS formatting and linting (auto-fix)
- Package lock validation
Pre-push:
- TypeScript type checking
- All tests
- Build verification
Use conventional commit format for automated changelog:
git commit -m "feat: add new feature"
git commit -m "fix: resolve bug in validation"
git commit -m "docs: update API documentation"Types: feat, fix, docs, refactor, perf, test, build, ci, chore
- CONTRIBUTING.md - How to contribute (includes TDD guide)
- SECURITY.md - Security policy and vulnerability reporting
Fully automated with release-please:
- Make changes with conventional commits
- Merge to main - release-please creates/updates release PR
- Review release PR - check version bump and changelog
- Merge release PR - automatic:
- NPM publish with provenance
- GitHub release creation
- SLSA attestation generation
No manual versioning or changelog needed!
Note: Release workflow is disabled on the template repository and activates automatically when you use the template.
This template achieves SLSA Level 3 compliance through:
- Build provenance attestations
- NPM provenance enabled
- Signed commits support
- Daily security scans
- Dependency vulnerability blocking
Verify package integrity:
npm audit signaturesSee SECURITY.md for vulnerability reporting.
- Vitest for fast unit testing
- @fast-check for property-based testing (fuzz testing)
- 80% coverage threshold enforced
- Automated CI testing on Linux Node 22
Run tests:
npm test # Run all tests
npm run test:watch # Watch mode
npm run test:ui # Interactive UI
npm run coverage # Coverage reportThis project is licensed under the MIT License - see the LICENSE file for details.