From js-foundation
Package management discipline for any JavaScript/TypeScript project: dependency declaration, semver, scripts conventions, lockfile hygiene, package-manager detection (npm/yarn/pnpm). Stack-agnostic — referenced by every JS/TS framework plugin in the marketplace. Use this skill to: - Add a dependency correctly (right field, right semver range). - Pick the project's package manager from lockfile. - Define `scripts` entries that match conventions. - Avoid lockfile mistakes (manual edits, wrong commits). Do NOT use this skill for: - Code-level conventions (see the active framework plugin's conventions skill). - Framework-specific package patterns (NestJS modules, Angular schematics, Expo SDK choice etc.).
How this skill is triggered — by the user, by Claude, or both
Slash command
/js-foundation:npm-patternsThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
This skill consolidates package management idioms applicable to any JS/TS project — backend, frontend, mobile, library. Apply when modifying `package.json`, adding dependencies, or defining scripts.
This skill consolidates package management idioms applicable to any JS/TS project — backend, frontend, mobile, library. Apply when modifying package.json, adding dependencies, or defining scripts.
Look at the lockfile in the project root:
| Lockfile present | Use |
|---|---|
package-lock.json | npm |
yarn.lock | yarn |
pnpm-lock.yaml | pnpm |
bun.lockb / bun.lock | bun (rare; mostly drop-in for npm) |
| (none) | npm — but flag in DECISIONS that no lockfile is committed |
Also check package.json "packageManager" field (e.g. "packageManager": "[email protected]") — when present, it overrides lockfile inference.
Map common commands:
| Action | npm | yarn | pnpm |
|---|---|---|---|
| Install all | npm install | yarn install | pnpm install |
| Add runtime dep | npm install pkg | yarn add pkg | pnpm add pkg |
| Add dev dep | npm install -D pkg | yarn add -D pkg | pnpm add -D pkg |
| Run script | npm run x | yarn x | pnpm x |
| Update lockfile | npm install | yarn install | pnpm install |
Always run the install command after editing package.json — never edit the lockfile by hand.
| Field | Use for |
|---|---|
dependencies | Runtime — what the production app needs to run (express, react, pinia, axios). |
devDependencies | Dev tooling — bundlers, test runners, linters, type definitions, dev servers. |
peerDependencies | Library authors only — declares what host app must provide (e.g., react for a React component library). |
optionalDependencies | Rare — install failure should not break install (native binaries with fallbacks). |
bundledDependencies | Rare — packaged inside npm pack tarball. |
Rule of thumb: if the code is bundled into the production output for runtime use, it's a dependency. If it only runs during npm test / npm run build / lint, it's a devDependency.
Frontend nuance: bundlers (Vite/Webpack/esbuild) often tree-shake unused exports — but the package still belongs in dependencies if any production-rendered code imports it.
| Range | Meaning | When to use |
|---|---|---|
^1.2.3 | >=1.2.3 <2.0.0 (no breaking changes) | Default — most deps |
~1.2.3 | >=1.2.3 <1.3.0 (only patch) | Conservative — production-critical |
1.2.3 | Exact | When you've debugged a specific version (rare) |
>=1.2.3 | Any version >=1.2.3 | Almost never — too loose |
* or latest | Anything | NEVER. Reproducible builds matter. |
git+https://... | Git ref | Only as last resort; pin to commit SHA. |
Default: ^x.y.z. Lockfile pins exact versions for reproducibility — that's what makes ^ safe.
scripts conventionsCommon script names (be consistent — these are de-facto standard):
| Script | Purpose |
|---|---|
start | Production entry: node dist/index.js (Node) or static server (frontend) |
dev | Dev entry: nodemon / tsx watch / vite / next dev / ng serve |
build | Compile/bundle: tsc, vite build, next build, ng build, esbuild, webpack |
test | Test runner: jest, vitest, mocha, ng test |
test:watch | Watch-mode tests |
test:coverage | Coverage report |
test:e2e | E2E tests (Playwright/Cypress/Detox) |
lint | eslint . |
lint:fix | eslint . --fix |
format | prettier --write . |
format:check | prettier --check . |
typecheck | tsc --noEmit (or vue-tsc --noEmit for Vue) |
clean | Remove dist/, coverage/, .next/, out/ |
prepare | Auto-runs after install (husky setup, etc.) |
Don't invent new names without a reason. CI configs and other tools assume these.
yarn.lock and package-lock.json simultaneously.<pm> install to regenerate..npmignore by default).engines fieldPin Node version when it matters (e.g., uses node:test requires ≥18, or your bundler requires ≥20):
{
"engines": {
"node": ">=18.0.0"
}
}
Add engines.npm only if you need a specific npm major version.
package.json type field"type": "module" — files default to ESM. Use import/export. CJS files must use .cjs extension."type": "commonjs" — files default to CJS. Use require/module.exports. ESM files must use .mjs extension.Don't change this unless the BA spec explicitly asks; switching modes mid-project is invasive (especially for backend Node projects).
Frontend bundler-driven projects (Vite/Webpack/Next/Angular CLI) typically use "type": "module" regardless — bundler handles output.
For monorepos:
// Root package.json
{
"name": "my-monorepo",
"private": true,
"workspaces": ["apps/*", "packages/*"]
}
pnpm-workspace.yaml instead.workspaces field; berry vs classic differ in detail.Per-app package.json files declare app-specific deps; root-only deps go in root.
npm audit (or equivalent) when adding deps; fix Critical/High before committing.--force resolution unless you know what you're overriding and document it.lodash vs lodahs, chalk vs chal-k.bundlephobia.com as a quick gauge).npm install --force without justification.package-lock.json / yarn.lock / pnpm-lock.yaml by hand.* or latest as a version range.dependencies and devDependencies.node_modules/.engines.node without testing on the lower bound.dependencies (bloats npm ci for production-only installs).npx claudepluginhub aratkruglik/claude-sdlc --plugin js-foundationManages NPM packages, configures Node.js projects, handles dependencies, and troubleshoots issues using npm, yarn, or pnpm.
Applies Anthony Fu's opinionated tooling and conventions for JS/TS projects: project setup, ESLint/Prettier alternatives, monorepos, library publishing, and coding practices.
Applies Anthony Fu's opinionated tooling and conventions for JavaScript/TypeScript projects: ESLint/Prettier alternatives, monorepos, library publishing, and project setup.