add-package
Create a new shared TypeScript package under packages/. Use when code is needed by more than one app or service and no existing package is the right home for it.
SKILL.md.claude/skills/add-package/SKILL.md
GitHubAdd a shared package
First check the existing packages (packages/*/package.json descriptions): a helper
that fits one of them goes there. Code for one service stays in that service.
bun run gen:new package --args <name> "<one sentence: what it is for>", e.g.bun run gen:new package --args money "Formatting and arithmetic for amounts of money."It writespackages/<name>/(package.json: private,type: module, exports./src/index.ts,check-types/test/coveragescripts,@repo/typescript-configand@repo/vitest-config), formats, and runsbun installto link it.<name>is a commit scope at once (commitlint.config.tsreads the workspace folders).- Write the code in
src/, with a*.test.tsbeside each file. Every file is at 100% coverage (bun run test:coverage; docs/testing.md, "Coverage"). - Dependencies:
"catalog:"when the rootpackage.jsoncatalog has the package, otherwise a normal range. Node types: add@types/node("catalog:") and"compilerOptions": { "types": ["node"] }to itstsconfig.json, likepackages/logger. React code extends@repo/typescript-config/react-library.jsoninstead. - Consumers add
"@repo/<name>": "workspace:*"to theirpackage.json, thenbun install. Apps and mobile must not import server-only packages; if the new one is server-only, add it to theweb-has-no-backend-coderule in.dependency-cruiser.cjs. bun run lint(knip flags unused exports and undeclared dependencies),bun run check-types,bun run test.- The
revieweragent on the change.