Install, upgrade, pin, remove and inspect npm packages with the right command (npm ci vs install, update vs @latest) and verify package.json, lockfile and tests.
--- name: npm-package-manager description: Adds, upgrades, removes and inspects npm dependencies in a Node.js project with the correct npm commands, keeping package.json and the lockfile consistent and checking the result with npm ls and the project's tests. Use when asked to install, update, uninstall or check the version of an npm package, fix a lockfile, or choose between npm install and npm ci. Detects pnpm/yarn/bun projects and defers to their commands. compatibility: Requires Node.js and npm on PATH and network access to the configured npm registry. metadata: version: "1.0.0" category: "Development Tools" --- # NPM Package Manager ## First, identify the package manager - `package-lock.json` → npm (this skill). - `pnpm-lock.yaml`, `yarn.lock` or `bun.lock`/`bun.lockb` → use that tool; mixing managers creates a second lockfile. Respect the `packageManager` field in package.json if present. - No lockfile → npm will create one on the first install; mention it. ## Command map | Request | Command | Notes | |---|---|---| | Install everything for a clean, reproducible build | `npm ci` | Needs a lockfile in sync with package.json; deletes node_modules first; never edits package.json | | Install everything while developing | `npm install` | May update the lockfile | | Add a runtime dependency | `npm install <pkg>@<range>` | Saves to dependencies with a caret range by default | | Add a dev dependency | `npm install -D <pkg>` | | | Add an exact pin | `npm install <pkg>@<version> --save-exact` | | | Upgrade within the allowed range | `npm update <pkg>` | Does not cross the semver range in package.json | | Upgrade across a major | `npm install <pkg>@latest` (or `@<major>`) | Read the changelog first; it is a breaking change | | Remove | `npm uninstall <pkg>` | Also removes it from package.json and the lockfile | | What is installed | `npm ls <pkg>` / `npm ls --depth=0` | Shows why a transitive package is present | | Latest published version | `npm view <pkg> version` | Use `npm view <pkg> versions --json` for all | | Outdated packages | `npm outdated` | | | Runtime versions | `node -v`, `npm -v` | `npm view node version` shows the npm package called "node", not your runtime | | Read or set package.json fields | `npm pkg get <field>`, `npm pkg set <field>=<value>` | | ## Workflow 1. Read package.json, the lockfile and `engines`; confirm the package name is right (check `npm view <pkg> name repository.url` to avoid look-alike packages). 2. Choose the command from the table. For anything that removes a package or crosses a major version, show the command and the expected impact and wait for approval. 3. Run it. Use `--ignore-scripts` when you only need the lockfile updated or the package is unfamiliar; tell the user that install scripts did not run. 4. Verify: `npm ls <pkg>` shows the expected version without `invalid`/`missing`; `git diff package.json package-lock.json` shows only the intended change; run the project's test or build script. 5. Report the before/after versions and anything left for the user (for example peer-dependency warnings). ## Safety - Do not delete `package-lock.json` to "fix" an install unless the user agrees; it changes every transitive version. - Do not run `npm audit fix --force` or `npm update` across the whole project when one package was requested. - Never put registry tokens in package.json or commit `.npmrc` files that contain them. ## Example Request: "Upgrade ms to 2.1.3 and pin it exactly." Good result: `npm install ms@2.1.3 --save-exact` → package.json shows `"ms": "2.1.3"`, the lockfile entry `node_modules/ms` shows version 2.1.3, `npm ls ms` prints `ms@2.1.3`, tests run, and the diff touches only those two files.
Generate a GitHub Actions (or other CI) pipeline from the repo's real scripts, with least-privilege permissions, caching, concurrency and a gated deploy.
Generate a compose.yaml for your app, database and cache with health-checked startup, named volumes and secrets in .env, validated with docker compose config.
Automate notifications and alerts
Illustrative input and expected result. This example is a verification guide, not a recorded model run.
Content reviewed .
A Node project that uses npm (package-lock.json present) needs one dependency moved to an exact version without disturbing anything else.
Upgrade ms to 2.1.3 and pin it exactly. Don't touch other packages.
The agent confirms npm is the manager from package-lock.json and runs `npm install ms@2.1.3 --save-exact`. Then package.json reads "ms": "2.1.3", the lockfile's node_modules/ms entry is 2.1.3, `npm ls ms` prints ms@2.1.3, and the project's test script runs. `git diff` shows only package.json and package-lock.json changed. No lockfile deletion and no project-wide update.
AI Agent Skills are reusable workflow packages that extend your AI coding assistant with multi-step capabilities. Install NPM Package Manager by following these steps.
SKILL.md inside, in the location documented by your client. Do not assume every AI application reads the same directory.Requires an Agent Skills-compatible client; supported locations and activation vary by version. Read the SKILL.md setup guide. MCP connects tools and data and does not, by itself, install a skill.
Generate a GitHub Actions (or other CI) pipeline from the repo's real scripts, with least-privilege permissions, caching, concurrency and a gated deploy.
Generate a compose.yaml for your app, database and cache with health-checked startup, named volumes and secrets in .env, validated with docker compose config.
Automate notifications and alerts