Package Hygiene & Metadata Quality
This guide documents the metadata, packaging rules, and validation checks that
keep chatline high-quality, predictable, and easy to consume.
Objectives
- Accurate and complete metadata on npm (discoverability, support, funding)
- Minimal, intentional publish surface (small tarball, no leaks)
- Strong type metadata with validation
- Automated checks in CI prior to releases
package.json essentials
We follow npm guidance for top-level metadata fields:
name,version,descriptionrepository,bugs,homepagelicense,author,fundingkeywordstype: modulewithexportsandtypesbinfor CLIenginesandpublishConfig(with provenance)fileswhitelist andsideEffects: false
Current config includes:
exportswith ESM andtypesfor.files: onlydist/**,README.md,LICENSE,CHANGELOG.mdsideEffects: falsefor better tree-shakingpublishConfig.provenance: truefor npm OIDC provenance
Validation tools
- publint: Lints publish configuration for cross-env compatibility
- arethetypeswrong (attw): Validates type exports and TypeScript metadata
Local usage
pnpm build
pnpm hygiene # runs publint + attw
pnpm pack:dry # creates tarball in ./.pack and lists its contents
CI workflow
.github/workflows/package-hygiene.yml runs on PRs and manual dispatch:
- Harden-Runner (audit mode)
- Install, build
- publint + attw
- pnpm pack with artifact upload
Checklist before publishing
- All public entrypoints defined in
exports -
typespoints to generated.d.tsindist -
fileswhitelist contains only what consumers need -
README,LICENSE,CHANGELOG.mdincluded -
binpoints at built CLI with shebang -
engines.nodematches supported versions -
repository,bugs,homepage,fundingset - publint passes
- attw passes (no red flags)
Tarball size and contents
We prefer small, predictable tarballs. Use pnpm pack:dry to inspect the exact
contents. If extra files slip in, tighten files or add .npmignore (subdirs
only).
Types guidance
- Emit
.d.tsfiles todistand reference via top-leveltypesandexports["."].types. - Validate with
attw --packto simulate the published tarball’s types. - Avoid unnecessary
typesVersionsunless targeting older TS versions.
Security & provenance
- Stable release workflow generates SBOM and publishes with OIDC provenance.
- See
docs/security-supply-chain.mdfor details and controls.
References
- npm package.json docs (description, repository, bugs, homepage, files, exports)
- publint (publint.dev)
- AreTheTypesWrong (arethetypeswrong.github.io)
Future enhancements
- SBOM parity in hygiene workflow (optional) to mirror stable release scans
- Tarball size gating: compute size and fail if exceeding a budget (e.g., 500 KB)
- License scanning against an allowlist using the generated SBOM
- Strict publint settings once baseline is green; treat as blocking in CI
- Types quality: add a type test project to assert public API types compile
- OpenSSF Scorecard check for repository hygiene signals
- Log strategy: Use
logs/(or hidden.logs/for local-only dev traces) ignored via.gitignore; prefer structured rotating files (e.g.pipeline-YYYYMMDD.log). Avoid committing transient logs—commit only curated audit data when explicitly needed.