Create a new shared package in this pnpm + Turborepo workspace with the correct `packages/<name>` layout, `@repo/<name>` naming, catalog/workspace dependency policy, TypeScript + ESLint setup, docs updates, and validation commands. Trigger when a user asks to add, scaffold, generate, or bootstrap a package under `packages/` or introduces a new `@repo/*` internal library.
Follow this workflow to add a package that matches this repository's standards.
Decide these before creating files:
packages/<name>@repo/<name>node-lib (default for shared runtime utilities)react-library (for UI/shared React code)config-only (for config exports like eslint/tsconfig packages)If any of these are unclear, ask the user before writing files.
Default to a TypeScript library unless the user explicitly wants config-only.
Create:
packages/<name>/package.jsonpackages/<name>/tsconfig.json (skip for config-only if not needed)packages/<name>/eslint.config.js (for TS/JS source packages)packages/<name>/src/index.ts (for source packages)packages/<name>/README.mdUse this baseline for standard shared libraries:
{
"name": "@repo/<name>",
"version": "1.0.0",
"description": "<description>",
"private": true,
"type": "module",
"packageManager": "[email protected]",
"engines": { "node": ">=24" },
"exports": {
".": {
"import": "./dist/index.js",
"types": "./dist/index.d.ts"
}
},
"types": "./dist/index.d.ts",
"files": ["dist", "README.md", "LICENSE"],
"scripts": {
"build": "tsc -p tsconfig.json",
"dev": "tsc -w -p tsconfig.json",
"lint": "eslint . --max-warnings 0",
"check-types": "tsc -p tsconfig.json --noEmit"
},
"dependencies": {},
"devDependencies": {
"@repo/eslint-config": "workspace:*",
"@repo/typescript-config": "workspace:*",
"@types/node": "catalog:",
"eslint": "catalog:",
"typescript": "catalog:"
}
}
Use this baseline tsconfig.json:
{
"extends": "@repo/typescript-config/node-lib.json",
"compilerOptions": {
"outDir": "dist",
"rootDir": "src",
"types": ["node"],
"verbatimModuleSyntax": true
},
"include": ["src"],
"exclude": ["node_modules", "dist", "test", "**/*.test.ts"]
}
For React libraries, switch to:
"extends": "@repo/typescript-config/react-library.json"Use this eslint.config.js for source packages:
import { config as base } from '@repo/eslint-config/base';
export default [...base];
For config-only packages, follow the nearest existing pattern in:
packages/eslint-configpackages/typescript-configDo not force a dist build pipeline if the package only exports static config files.
Follow these rules exactly:
pnpm only.workspace:* for internal packages (@repo/*).catalog: for external dependencies already listed in pnpm-workspace.yaml.pnpm-workspace.yaml first, then reference it with catalog:.pnpm-lock.yaml only when dependency graph changes.packages/<name>.@repo/* package imports.../../packages/...).After adding a new package, update:
packages/README.md package tableREADME.md)If release metadata is involved, keep CHANGELOG.md synchronized.
Run at minimum:
pnpm format
pnpm lint
pnpm check-types
Run package-level checks when scripts exist:
pnpm -C packages/<name> lint
pnpm -C packages/<name> check-types
pnpm -C packages/<name> build
Run affected tests if the changed area has test coverage.
Before finishing, confirm:
packages/<name> and named @repo/<name>workspace:* and catalog: policy.turbo/**)