Paths: File paths (shared/, references/, ../ln-*) are relative to skills repo root. If not found at CWD, locate this SKILL.md directory and go up one level for repo root.
ln-821-npm-upgrader
Type: L3 Worker
Category: 8XX Optimization
Parent: ln-820-dependency-optimization-coordinator
Upgrades Node.js dependencies using npm, yarn, or pnpm with automatic breaking change detection and migration.
Overview
| Aspect |
Details |
| Input |
Project path, package manager type |
| Output |
Updated package.json, lock file, migration report |
| Supports |
npm, yarn (classic & berry), pnpm |
Workflow
Phases: Pre-flight → Analyze → Security Audit → Check Outdated → Identify Breaking → Apply Upgrades → Apply Migrations → Verify Build → Report
Phase 0: Pre-flight Checks
| Check |
Required |
Action if Missing |
| Lock file (package-lock.json, yarn.lock, pnpm-lock.yaml) |
Yes |
Warn and run npm install first |
| package.json |
Yes |
Block upgrade |
| Git clean state |
Yes |
Block (need clean baseline for revert) |
Workers assume coordinator (ln-820) already verified git state and created backup.
Worktree & Branch Isolation
MANDATORY READ: Load shared/references/git_worktree_fallback.md — use ln-821 row.
Phase 1: Analyze Dependencies
Read package.json and categorize dependencies for upgrade priority.
Dependency Categories
| Category |
Examples |
Priority |
| framework |
react, vue, angular |
2 (after peer deps) |
| build |
vite, webpack, esbuild |
3 |
| ui |
@radix-ui/*, tailwindcss |
4 |
| state |
@tanstack/react-query, zustand |
5 |
| utils |
lodash, date-fns |
6 |
| dev |
eslint, prettier, typescript |
7 |
| peer |
@types/*, typescript |
1 (first) |
Phase 2: Security Audit
Commands
| Manager |
Command |
| npm |
npm audit --audit-level=high |
| yarn |
yarn audit --level high |
| pnpm |
pnpm audit --audit-level high |
Actions
| Severity |
Action |
| Critical |
Block upgrade, report |
| High |
Warn, continue |
| Moderate/Low |
Log only |
Phase 3: Check Outdated
Commands
| Manager |
Command |
| npm |
npm outdated --json |
| yarn |
yarn outdated --json |
| pnpm |
pnpm outdated --json |
Phase 4: Identify Breaking Changes
Detection
MANDATORY READ: Load breaking_changes_patterns.md for full patterns.
- Compare current vs latest major versions
- Check breaking_changes_patterns.md for known patterns
- Query Context7/Ref for migration guides
Common Breaking Changes
| Package |
Breaking Version |
Key Changes |
| react |
18 → 19 |
JSX Transform, ref as prop |
| vite |
5 → 6 |
ESM only, Node 18+ |
| eslint |
8 → 9 |
Flat config required |
| tailwindcss |
3 → 4 |
CSS-based config |
| typescript |
5.4 → 5.5+ |
Stricter inference |
Phase 5: Apply Upgrades
Upgrade Order
- Peer dependencies (TypeScript, @types/*)
- Framework packages (React, Vue core)
- Build tools (Vite, webpack)
- UI libraries (after framework)
- Utilities (lodash, date-fns)
- Dev dependencies (testing, linting)
Commands
| Manager |
Command |
| npm |
npm install <package>@latest --save |
| yarn |
yarn add <package>@latest |
| pnpm |
pnpm add <package>@latest |
Peer Dependency Conflicts
| Situation |
Solution |
| ERESOLVE error |
npm install --legacy-peer-deps |
| Still fails |
npm install --force (last resort) |
MCP Tools for Migration Search
Priority Order (Fallback Strategy)
| Priority |
Tool |
When to Use |
| 1 |
mcp__context7__query-docs |
First choice for library docs |
| 2 |
mcp__Ref__ref_search_documentation |
Official docs and GitHub |
| 3 |
WebSearch |
Latest info, community solutions |
Context7 Usage
| Step |
Tool |
Parameters |
| 1. Find library |
mcp__context7__resolve-library-id |
libraryName: "react", query: "migration guide" |
| 2. Query docs |
mcp__context7__query-docs |
libraryId: "/facebook/react", query: "react 18 to 19 migration" |
MCP Ref Usage
| Action |
Tool |
Query Example |
| Search |
mcp__Ref__ref_search_documentation |
"react 19 migration guide breaking changes" |
| Read |
mcp__Ref__ref_read_url |
URL from search results |
WebSearch Fallback
Use when Context7/Ref return no results:
"<package> <version> breaking changes migration {current_year}"
"<package> <error message> fix stackoverflow"
Phase 6: Apply Migrations
Process
- Use MCP tools (see section above) to find migration guide
- Apply automated code transforms via Edit tool
- Log manual migration steps for user
Do NOT apply hardcoded migrations. Always fetch current guides via MCP tools.
Phase 7: Verify Build
Commands
| Check |
Command |
| TypeScript |
npm run check or npx tsc --noEmit |
| Build |
npm run build |
| Tests |
npm test (if available) |
On Failure
- Identify failing package from error
- Search Context7/Ref for fix
- If unresolved: rollback package, continue with others
Phase 8: Report Results
Report Schema
| Field |
Description |
| project |
Project path |
| packageManager |
npm, yarn, or pnpm |
| duration |
Total time |
| upgrades.major[] |
Breaking changes applied |
| upgrades.minor[] |
Feature updates |
| upgrades.patch[] |
Bug fixes |
| migrations[] |
Applied migrations |
| skipped[] |
Already latest |
| buildVerification |
PASSED or FAILED |
| warnings[] |
Non-blocking issues |
Configuration
Options:
# Upgrade scope
upgradeType: major # major | minor | patch
# Breaking changes
allowBreaking: true
autoMigrate: true
queryMigrationGuides: true # Use Context7/Ref
# Security
auditLevel: high # none | low | moderate | high | critical
minimumReleaseAge: 14 # days
# Peer dependencies
legacyPeerDeps: false
force: false
# Verification
runBuild: true
runTests: false
runTypeCheck: true
# Rollback
createBackup: true
rollbackOnFailure: true
Error Handling
| Error |
Cause |
Solution |
| ERESOLVE |
Peer dep conflict |
--legacy-peer-deps |
| ENOENT |
Missing lock file |
npm install first |
| Build fail |
Breaking change |
Apply migration via Context7 |
| Type errors |
Version mismatch |
Update @types/* |
Rollback
Restore package.json and lock file from git, then run clean install to restore previous state.
References
Definition of Done
- Lock file and package.json verified present
- Dependencies categorized and prioritized (peer deps first)
- Security audit completed (critical blocks upgrade)
- Outdated packages identified via
npm/yarn/pnpm outdated
- Breaking changes detected via breaking_changes_patterns.md and MCP tools
- Upgrades applied in priority order with rollback on failure
- Build and type checks pass after upgrades
- Report returned with major/minor/patch counts, migrations, and build status
Version: 1.1.0
Last Updated: 2026-01-10
1---2name: ln-821-npm-upgrader3description: Upgrades npm/yarn/pnpm dependencies with breaking change handling4license: MIT5---67> **Paths:** File paths (`shared/`, `references/`, `../ln-*`) are relative to skills repo root. If not found at CWD, locate this SKILL.md directory and go up one level for repo root.89# ln-821-npm-upgrader1011**Type:** L3 Worker12**Category:** 8XX Optimization13**Parent:** ln-820-dependency-optimization-coordinator1415Upgrades Node.js dependencies using npm, yarn, or pnpm with automatic breaking change detection and migration.1617---1819## Overview2021| Aspect | Details |22|--------|---------|23| **Input** | Project path, package manager type |24| **Output** | Updated package.json, lock file, migration report |25| **Supports** | npm, yarn (classic & berry), pnpm |2627---2829## Workflow3031**Phases:** Pre-flight → Analyze → Security Audit → Check Outdated → Identify Breaking → Apply Upgrades → Apply Migrations → Verify Build → Report3233---3435## Phase 0: Pre-flight Checks3637| Check | Required | Action if Missing |38|-------|----------|-------------------|39| Lock file (package-lock.json, yarn.lock, pnpm-lock.yaml) | Yes | Warn and run `npm install` first |40| package.json | Yes | Block upgrade |41| Git clean state | Yes | Block (need clean baseline for revert) |4243> Workers assume coordinator (ln-820) already verified git state and created backup.4445### Worktree & Branch Isolation4647**MANDATORY READ:** Load `shared/references/git_worktree_fallback.md` — use ln-821 row.4849---5051## Phase 1: Analyze Dependencies5253Read package.json and categorize dependencies for upgrade priority.5455### Dependency Categories5657| Category | Examples | Priority |58|----------|----------|----------|59| framework | react, vue, angular | 2 (after peer deps) |60| build | vite, webpack, esbuild | 3 |61| ui | @radix-ui/*, tailwindcss | 4 |62| state | @tanstack/react-query, zustand | 5 |63| utils | lodash, date-fns | 6 |64| dev | eslint, prettier, typescript | 7 |65| peer | @types/*, typescript | 1 (first) |6667---6869## Phase 2: Security Audit7071### Commands7273| Manager | Command |74|---------|---------|75| npm | `npm audit --audit-level=high` |76| yarn | `yarn audit --level high` |77| pnpm | `pnpm audit --audit-level high` |7879### Actions8081| Severity | Action |82|----------|--------|83| Critical | Block upgrade, report |84| High | Warn, continue |85| Moderate/Low | Log only |8687---8889## Phase 3: Check Outdated9091### Commands9293| Manager | Command |94|---------|---------|95| npm | `npm outdated --json` |96| yarn | `yarn outdated --json` |97| pnpm | `pnpm outdated --json` |9899---100101## Phase 4: Identify Breaking Changes102103### Detection104105**MANDATORY READ:** Load [breaking_changes_patterns.md](../ln-820-dependency-optimization-coordinator/references/breaking_changes_patterns.md) for full patterns.1061071. Compare current vs latest major versions1082. Check breaking_changes_patterns.md for known patterns1093. Query Context7/Ref for migration guides110111### Common Breaking Changes112113| Package | Breaking Version | Key Changes |114|---------|------------------|-------------|115| react | 18 → 19 | JSX Transform, ref as prop |116| vite | 5 → 6 | ESM only, Node 18+ |117| eslint | 8 → 9 | Flat config required |118| tailwindcss | 3 → 4 | CSS-based config |119| typescript | 5.4 → 5.5+ | Stricter inference |120121---122123## Phase 5: Apply Upgrades124125### Upgrade Order1261271. **Peer dependencies** (TypeScript, @types/*)1282. **Framework packages** (React, Vue core)1293. **Build tools** (Vite, webpack)1304. **UI libraries** (after framework)1315. **Utilities** (lodash, date-fns)1326. **Dev dependencies** (testing, linting)133134### Commands135136| Manager | Command |137|---------|---------|138| npm | `npm install <package>@latest --save` |139| yarn | `yarn add <package>@latest` |140| pnpm | `pnpm add <package>@latest` |141142### Peer Dependency Conflicts143144| Situation | Solution |145|-----------|----------|146| ERESOLVE error | `npm install --legacy-peer-deps` |147| Still fails | `npm install --force` (last resort) |148149---150151## MCP Tools for Migration Search152153### Priority Order (Fallback Strategy)154155| Priority | Tool | When to Use |156|----------|------|-------------|157| 1 | mcp__context7__query-docs | First choice for library docs |158| 2 | mcp__Ref__ref_search_documentation | Official docs and GitHub |159| 3 | WebSearch | Latest info, community solutions |160161### Context7 Usage162163| Step | Tool | Parameters |164|------|------|------------|165| 1. Find library | mcp__context7__resolve-library-id | libraryName: "react", query: "migration guide" |166| 2. Query docs | mcp__context7__query-docs | libraryId: "/facebook/react", query: "react 18 to 19 migration" |167168### MCP Ref Usage169170| Action | Tool | Query Example |171|--------|------|---------------|172| Search | mcp__Ref__ref_search_documentation | "react 19 migration guide breaking changes" |173| Read | mcp__Ref__ref_read_url | URL from search results |174175### WebSearch Fallback176177Use when Context7/Ref return no results:178- `"<package> <version> breaking changes migration {current_year}"`179- `"<package> <error message> fix stackoverflow"`180181---182183## Phase 6: Apply Migrations184185### Process1861871. Use MCP tools (see section above) to find migration guide1882. Apply automated code transforms via Edit tool1893. Log manual migration steps for user190191> Do NOT apply hardcoded migrations. Always fetch current guides via MCP tools.192193---194195## Phase 7: Verify Build196197### Commands198199| Check | Command |200|-------|---------|201| TypeScript | `npm run check` or `npx tsc --noEmit` |202| Build | `npm run build` |203| Tests | `npm test` (if available) |204205### On Failure2062071. Identify failing package from error2082. Search Context7/Ref for fix2093. If unresolved: rollback package, continue with others210211---212213## Phase 8: Report Results214215### Report Schema216217| Field | Description |218|-------|-------------|219| project | Project path |220| packageManager | npm, yarn, or pnpm |221| duration | Total time |222| upgrades.major[] | Breaking changes applied |223| upgrades.minor[] | Feature updates |224| upgrades.patch[] | Bug fixes |225| migrations[] | Applied migrations |226| skipped[] | Already latest |227| buildVerification | PASSED or FAILED |228| warnings[] | Non-blocking issues |229230---231232## Configuration233234```yaml235Options:236 # Upgrade scope237 upgradeType: major # major | minor | patch238239 # Breaking changes240 allowBreaking: true241 autoMigrate: true242 queryMigrationGuides: true # Use Context7/Ref243244 # Security245 auditLevel: high # none | low | moderate | high | critical246 minimumReleaseAge: 14 # days247248 # Peer dependencies249 legacyPeerDeps: false250 force: false251252 # Verification253 runBuild: true254 runTests: false255 runTypeCheck: true256257 # Rollback258 createBackup: true259 rollbackOnFailure: true260```261262---263264## Error Handling265266| Error | Cause | Solution |267|-------|-------|----------|268| ERESOLVE | Peer dep conflict | --legacy-peer-deps |269| ENOENT | Missing lock file | npm install first |270| Build fail | Breaking change | Apply migration via Context7 |271| Type errors | Version mismatch | Update @types/* |272273### Rollback274275Restore package.json and lock file from git, then run clean install to restore previous state.276277---278279## References280281- [breaking_changes_patterns.md](../ln-820-dependency-optimization-coordinator/references/breaking_changes_patterns.md)282- [npm_peer_resolution.md](references/npm_peer_resolution.md)283284---285286## Definition of Done287288- Lock file and package.json verified present289- Dependencies categorized and prioritized (peer deps first)290- Security audit completed (critical blocks upgrade)291- Outdated packages identified via `npm/yarn/pnpm outdated`292- Breaking changes detected via breaking_changes_patterns.md and MCP tools293- Upgrades applied in priority order with rollback on failure294- Build and type checks pass after upgrades295- Report returned with major/minor/patch counts, migrations, and build status296297---298299**Version:** 1.1.0300**Last Updated:** 2026-01-10