CLAUDE.md
Project Overview
<!-- TODO: Describe what this package does and who it's for -->[FILL IN: Brief description of the package, its purpose, and target consumers]
Package Configuration
Ensure package.json includes proper entry points:
{
"name": "[FILL IN: package-name or @scope/package-name]",
"version": "0.0.0",
"main": "./dist/index.cjs", // CommonJS entry
"module": "./dist/index.js", // ESM entry
"types": "./dist/index.d.ts", // TypeScript declarations
"exports": {
".": {
"import": "./dist/index.js",
"require": "./dist/index.cjs",
"types": "./dist/index.d.ts"
}
},
"files": ["dist", "README.md", "LICENSE"]
}
- Always define
exportsfor explicit subpath control - Include
typescondition in exports for TypeScript consumers - Keep
filesarray minimal — only ship what consumers need
Bundling Setup
<!-- TODO: Choose your bundler and fill in details -->- Bundler: [FILL IN: tsup / rollup / unbundled (tsc only)]
- Output formats: ESM + CJS (dual package)
- Target: [FILL IN: e.g., ES2020, Node 18+]
If using tsup (recommended for most packages):
// tsup.config.ts
import { defineConfig } from "tsup";
export default defineConfig({
entry: ["src/index.ts"],
format: ["cjs", "esm"],
dts: true,
clean: true,
sourcemap: true,
});
Versioning Strategy
- Follow semver strictly:
- patch — bug fixes, no API changes
- minor — new features, backward-compatible
- major — breaking changes
- Tool: [FILL IN: changesets / standard-version / manual]
Publishing Workflow
- Pre-publish checks:
prepublishOnlyscript should run build + tests - Publish command:
npm publish(ornpm publish --access publicfor scoped packages) - Dry run first: Always verify with
npm publish --dry-runbefore publishing - Tag releases: Use
npm version patch|minor|majoror your versioning tool to tag
// Recommended package.json scripts
{
"scripts": {
"build": "[FILL IN]",
"test": "[FILL IN]",
"prepublishOnly": "npm run build && npm test",
"release": "[FILL IN: e.g., npx changeset publish]"
}
}
Peer Dependency Strategy
- Declare frameworks and large shared libraries as
peerDependencies(e.g.,react,vue,angular) - Provide a wide peer range to maximize compatibility (e.g.,
"react": "^17.0.0 || ^18.0.0 || ^19.0.0") - Add the same packages to
devDependenciesfor local development and testing - Only use
dependenciesfor packages your library bundles or directly requires at runtime - Document required peer dependencies clearly in README
Testing Approach
- Write unit tests for all exported functions and public API surface
- Test both ESM and CJS entry points to catch module resolution issues
- Use [FILL IN: vitest / jest] as the test runner
- Test edge cases: invalid inputs, boundary values, error conditions
- For packages with types, verify type exports with
tsdorattw - Run tests against the built output (not just source) before publishing
Development Commands
- Build:
[FILL IN] - Test:
[FILL IN] - Test watch:
[FILL IN] - Lint:
[FILL IN] - Type check:
tsc --noEmit - Publish dry run:
npm publish --dry-run