Skip to content
cccskills
FreePublished on GitHub

npm-patterns

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.).

The English summary is being prepared. Showing the original description.

See how to install

Files included (1)

  • SKILL.md7.2 KB

SKILL.md (original)

Review the instructions the agent will receive before you install.

npm / yarn / pnpm Patterns (stack-agnostic)

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.

Detect the package manager

Look at the lockfile in the project root:

Lockfile presentUse
package-lock.jsonnpm
yarn.lockyarn
pnpm-lock.yamlpnpm
bun.lockb / bun.lockbun (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": "pnpm@8.6.0") — when present, it overrides lockfile inference.

Map common commands:

Actionnpmyarnpnpm
Install allnpm installyarn installpnpm install
Add runtime depnpm install pkgyarn add pkgpnpm add pkg
Add dev depnpm install -D pkgyarn add -D pkgpnpm add -D pkg
Run scriptnpm run xyarn xpnpm x
Update lockfilenpm installyarn installpnpm install

Always run the install command after editing package.json — never edit the lockfile by hand.

Dependency fields

FieldUse for
dependenciesRuntime — what the production app needs to run (express, react, pinia, axios).
devDependenciesDev tooling — bundlers, test runners, linters, type definitions, dev servers.
peerDependenciesLibrary authors only — declares what host app must provide (e.g., react for a React component library).
optionalDependenciesRare — install failure should not break install (native binaries with fallbacks).
bundledDependenciesRare — 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.

Semver discipline

RangeMeaningWhen 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.3ExactWhen you've debugged a specific version (rare)
>=1.2.3Any version >=1.2.3Almost never — too loose
* or latestAnythingNEVER. Reproducible builds matter.
git+https://...Git refOnly as last resort; pin to commit SHA.

Default: ^x.y.z. Lockfile pins exact versions for reproducibility — that's what makes ^ safe.

scripts conventions

Common script names (be consistent — these are de-facto standard):

ScriptPurpose
startProduction entry: node dist/index.js (Node) or static server (frontend)
devDev entry: nodemon / tsx watch / vite / next dev / ng serve
buildCompile/bundle: tsc, vite build, next build, ng build, esbuild, webpack
testTest runner: jest, vitest, mocha, ng test
test:watchWatch-mode tests
test:coverageCoverage report
test:e2eE2E tests (Playwright/Cypress/Detox)
linteslint .
lint:fixeslint . --fix
formatprettier --write .
format:checkprettier --check .
typechecktsc --noEmit (or vue-tsc --noEmit for Vue)
cleanRemove dist/, coverage/, .next/, out/
prepareAuto-runs after install (husky setup, etc.)

Don't invent new names without a reason. CI configs and other tools assume these.

Lockfile policy

  • Always commit the lockfile to git.
  • Never edit by hand. Always regenerate via the package manager.
  • Match the package manager: don't commit yarn.lock and package-lock.json simultaneously.
  • Resolve conflicts by accepting one side, then running <pm> install to regenerate.
  • For library packages published to npm, lockfile is committed but not published (it's in .npmignore by default).

engines field

Pin 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.
  • Absent or "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.

Workspaces (monorepos)

For monorepos:

// Root package.json
{
  "name": "my-monorepo",
  "private": true,
  "workspaces": ["apps/*", "packages/*"]
}
  • pnpm: uses pnpm-workspace.yaml instead.
  • yarn: same workspaces field; berry vs classic differ in detail.
  • Monorepo runners (Nx, Turborepo, Lerna): override default install/build/test orchestration. Match what's installed.

Per-app package.json files declare app-specific deps; root-only deps go in root.

Dependency hygiene

  • Run npm audit (or equivalent) when adding deps; fix Critical/High before committing.
  • Avoid --force resolution unless you know what you're overriding and document it.
  • Don't add deps for trivial utilities you can write in 5 lines (e.g., is-odd, padleft) — supply chain risk.
  • Watch for typo-squatting: lodash vs lodahs, chalk vs chal-k.
  • For frontend: bundle size matters — measure before adding heavy deps (use bundlephobia.com as a quick gauge).

Anti-patterns

  • ❌ npm install --force without justification.
  • ❌ Editing package-lock.json / yarn.lock / pnpm-lock.yaml by hand.
  • ❌ Using * or latest as a version range.
  • ❌ Adding the same package to both dependencies and devDependencies.
  • ❌ Committing node_modules/.
  • ❌ Mixing package managers (lockfile from one, install via another).
  • ❌ Adding engines.node without testing on the lower bound.
  • ❌ For frontend: putting build-time tools in dependencies (bloats npm ci for production-only installs).

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

Angular 18-21 project structure, standalone components vs NgModule, control flow (@if/@for/@switch + *ngIf/*ngFor legacy), decorators, dependency injection (inject() function), lifecycle hooks, pipes, Angular Universal SSR pointer. Use this skill to: - Detect project style (standalone vs NgModule) and apply matching patterns. - Pick correct decorators and DI approach. - Use modern control flow (@if/@for/@switch) in Angular 17+ projects. - Apply `inject()` function over constructor injection where appropriate. - Wire bootstrap correctly (bootstrapApplication for standalone, AppModule for legacy). Do NOT use this skill for: - State management (see angular-state-and-rx). - Routing (see angular-routing). - Forms (see angular-forms). - Testing (see angular-testing).

The English summary is being prepared. Showing the original description.

AratKruglik/claude-sdlc42Updated Oct 17, 2026

Angular forms: Reactive Forms (preferred — typed FormGroup/FormControl since Angular 14, FormBuilder, custom + async validators, FormArray, multi-step) and Template-driven (`[(ngModel)]` + FormsModule). Validation strategies, server error mapping, accessibility. Use this skill to: - Build Reactive Forms with typed FormGroup/FormControl. - Use FormBuilder для concise syntax. - Implement custom synchronous and async validators. - Wire FormArray for dynamic field lists. - Map server errors back to form fields. - Pick Reactive vs Template-driven (prefer Reactive). Do NOT use this skill for: - General conventions (see angular-conventions). - State management beyond forms (see angular-state-and-rx). - Routing (see angular-routing). - Testing forms (see angular-testing).

The English summary is being prepared. Showing the original description.

AratKruglik/claude-sdlc42Updated Oct 17, 2026

Angular Router (built-in `@angular/router`) — route configuration for standalone and NgModule projects, functional guards (Angular 14.1+), lazy loading, route resolvers, typed params via signals/observables, programmatic navigation, route data and meta. Use this skill to: - Configure routes (standalone-style or NgModule-style). - Use functional guards (canActivate as function, preferred over class-based in 17+). - Lazy-load components or feature modules. - Implement auth guards via route meta + functional guards. - Read params/queries via `inject(ActivatedRoute)` + signals or RxJS. Do NOT use this skill for: - General conventions (see angular-conventions). - State management (see angular-state-and-rx). - Forms (see angular-forms). - Testing routes (see angular-testing).

The English summary is being prepared. Showing the original description.

AratKruglik/claude-sdlc42Updated Oct 17, 2026

State management for Angular 18-21: signals (signal/computed/effect), services-as-state, NgRx Store + Effects + Selectors, NgRx Component Store, NgRx Signals (newer signal-based store). RxJS essentials — operators, async pipe, takeUntilDestroyed, signal/observable interop. Use this skill to: - Pick the right state tool (signals / services / NgRx variant / vue-query equivalent). - Use signals correctly (signal/computed/effect — when each). - Build a Pinia-style service-as-state singleton. - Set up NgRx Store + Effects + Selectors. - Use RxJS without leaking subscriptions (async pipe, takeUntilDestroyed, Subject patterns). - Bridge signals ↔ observables via toSignal / toObservable. Do NOT use this skill for: - General Angular conventions (see angular-conventions). - Routing state (see angular-routing). - Form state (see angular-forms). - Testing state (see angular-testing).

The English summary is being prepared. Showing the original description.

AratKruglik/claude-sdlc42Updated Oct 17, 2026

Testing Angular 18-21: TestBed, component harnesses (@angular/cdk/testing), Karma+Jasmine (default historical) vs Jest (jest-preset-angular, modern), Angular Testing Library (RTL-style). HttpClient mocking via HttpTestingController. NgRx Effects testing. Cypress / Playwright e2e. Use this skill to: - Detect runner (Karma+Jasmine vs Jest) and configure correctly. - Write component tests with TestBed. - Use component harnesses for Material / custom UI components. - Mock HttpClient via provideHttpClientTesting + HttpTestingController. - Test signal-based inputs with componentRef.setInput(). - Test NgRx Effects with provideMockActions. Do NOT use this skill for: - General Angular conventions (see angular-conventions). - Routing patterns broadly (see angular-routing — covers testing routes briefly). - Form patterns broadly (see angular-forms).

The English summary is being prepared. Showing the original description.

AratKruglik/claude-sdlc42Updated Oct 17, 2026

Shared conventions for every SDLC development-phase architect agent: hard rules, code quality bar, workflow steps (superpowers invocation, spec reading, codebase exploration, verification), and the report/compact-summary contract. Architects load this skill first, then apply their stack-specific instructions on top.

The English summary is being prepared. Showing the original description.

AratKruglik/claude-sdlc42Updated Oct 17, 2026

See all skills by AratKruglik

Report a problem with this skill