Manage major dependency version upgrades with compatibility analysis, staged rollout, and comprehensive testing. Use when upgrading framework versions, updating major dependencies, or managing breaking changes in libraries.
Add this skill
npx mdskills install sickn33/dependency-upgradeComprehensive guide covering staged upgrades, compatibility matrices, testing, and automation with actionable commands
1---2name: dependency-upgrade3description: Manage major dependency version upgrades with compatibility analysis, staged rollout, and comprehensive testing. Use when upgrading framework versions, updating major dependencies, or managing breaking changes in libraries.4---56# Dependency Upgrade78Master major dependency version upgrades, compatibility analysis, staged upgrade strategies, and comprehensive testing approaches.910## Do not use this skill when1112- The task is unrelated to dependency upgrade13- You need a different domain or tool outside this scope1415## Instructions1617- Clarify goals, constraints, and required inputs.18- Apply relevant best practices and validate outcomes.19- Provide actionable steps and verification.20- If detailed examples are required, open `resources/implementation-playbook.md`.2122## Use this skill when2324- Upgrading major framework versions25- Updating security-vulnerable dependencies26- Modernizing legacy dependencies27- Resolving dependency conflicts28- Planning incremental upgrade paths29- Testing compatibility matrices30- Automating dependency updates3132## Semantic Versioning Review3334```35MAJOR.MINOR.PATCH (e.g., 2.3.1)3637MAJOR: Breaking changes38MINOR: New features, backward compatible39PATCH: Bug fixes, backward compatible4041^2.3.1 = >=2.3.1 <3.0.0 (minor updates)42~2.3.1 = >=2.3.1 <2.4.0 (patch updates)432.3.1 = exact version44```4546## Dependency Analysis4748### Audit Dependencies49```bash50# npm51npm outdated52npm audit53npm audit fix5455# yarn56yarn outdated57yarn audit5859# Check for major updates60npx npm-check-updates61npx npm-check-updates -u # Update package.json62```6364### Analyze Dependency Tree65```bash66# See why a package is installed67npm ls package-name68yarn why package-name6970# Find duplicate packages71npm dedupe72yarn dedupe7374# Visualize dependencies75npx madge --image graph.png src/76```7778## Compatibility Matrix7980```javascript81// compatibility-matrix.js82const compatibilityMatrix = {83 'react': {84 '16.x': {85 'react-dom': '^16.0.0',86 'react-router-dom': '^5.0.0',87 '@testing-library/react': '^11.0.0'88 },89 '17.x': {90 'react-dom': '^17.0.0',91 'react-router-dom': '^5.0.0 || ^6.0.0',92 '@testing-library/react': '^12.0.0'93 },94 '18.x': {95 'react-dom': '^18.0.0',96 'react-router-dom': '^6.0.0',97 '@testing-library/react': '^13.0.0'98 }99 }100};101102function checkCompatibility(packages) {103 // Validate package versions against matrix104}105```106107## Staged Upgrade Strategy108109### Phase 1: Planning110```bash111# 1. Identify current versions112npm list --depth=0113114# 2. Check for breaking changes115# Read CHANGELOG.md and MIGRATION.md116117# 3. Create upgrade plan118echo "Upgrade order:1191. TypeScript1202. React1213. React Router1224. Testing libraries1235. Build tools" > UPGRADE_PLAN.md124```125126### Phase 2: Incremental Updates127```bash128# Don't upgrade everything at once!129130# Step 1: Update TypeScript131npm install typescript@latest132133# Test134npm run test135npm run build136137# Step 2: Update React (one major version at a time)138npm install react@17 react-dom@17139140# Test again141npm run test142143# Step 3: Continue with other packages144npm install react-router-dom@6145146# And so on...147```148149### Phase 3: Validation150```javascript151// tests/compatibility.test.js152describe('Dependency Compatibility', () => {153 it('should have compatible React versions', () => {154 const reactVersion = require('react/package.json').version;155 const reactDomVersion = require('react-dom/package.json').version;156157 expect(reactVersion).toBe(reactDomVersion);158 });159160 it('should not have peer dependency warnings', () => {161 // Run npm ls and check for warnings162 });163});164```165166## Breaking Change Handling167168### Identifying Breaking Changes169```bash170# Use changelog parsers171npx changelog-parser react 16.0.0 17.0.0172173# Or manually check174curl https://raw.githubusercontent.com/facebook/react/main/CHANGELOG.md175```176177### Codemod for Automated Fixes178```bash179# React upgrade codemods180npx react-codeshift <transform> <path>181182# Example: Update lifecycle methods183npx react-codeshift \184 --parser tsx \185 --transform react-codeshift/transforms/rename-unsafe-lifecycles.js \186 src/187```188189### Custom Migration Script190```javascript191// migration-script.js192const fs = require('fs');193const glob = require('glob');194195glob('src/**/*.tsx', (err, files) => {196 files.forEach(file => {197 let content = fs.readFileSync(file, 'utf8');198199 // Replace old API with new API200 content = content.replace(201 /componentWillMount/g,202 'UNSAFE_componentWillMount'203 );204205 // Update imports206 content = content.replace(207 /import { Component } from 'react'/g,208 "import React, { Component } from 'react'"209 );210211 fs.writeFileSync(file, content);212 });213});214```215216## Testing Strategy217218### Unit Tests219```javascript220// Ensure tests pass before and after upgrade221npm run test222223// Update test utilities if needed224npm install @testing-library/react@latest225```226227### Integration Tests228```javascript229// tests/integration/app.test.js230describe('App Integration', () => {231 it('should render without crashing', () => {232 render(<App />);233 });234235 it('should handle navigation', () => {236 const { getByText } = render(<App />);237 fireEvent.click(getByText('Navigate'));238 expect(screen.getByText('New Page')).toBeInTheDocument();239 });240});241```242243### Visual Regression Tests244```javascript245// visual-regression.test.js246describe('Visual Regression', () => {247 it('should match snapshot', () => {248 const { container } = render(<App />);249 expect(container.firstChild).toMatchSnapshot();250 });251});252```253254### E2E Tests255```javascript256// cypress/e2e/app.cy.js257describe('E2E Tests', () => {258 it('should complete user flow', () => {259 cy.visit('/');260 cy.get('[data-testid="login"]').click();261 cy.get('input[name="email"]').type('user@example.com');262 cy.get('button[type="submit"]').click();263 cy.url().should('include', '/dashboard');264 });265});266```267268## Automated Dependency Updates269270### Renovate Configuration271```json272// renovate.json273{274 "extends": ["config:base"],275 "packageRules": [276 {277 "matchUpdateTypes": ["minor", "patch"],278 "automerge": true279 },280 {281 "matchUpdateTypes": ["major"],282 "automerge": false,283 "labels": ["major-update"]284 }285 ],286 "schedule": ["before 3am on Monday"],287 "timezone": "America/New_York"288}289```290291### Dependabot Configuration292```yaml293# .github/dependabot.yml294version: 2295updates:296 - package-ecosystem: "npm"297 directory: "/"298 schedule:299 interval: "weekly"300 open-pull-requests-limit: 5301 reviewers:302 - "team-leads"303 commit-message:304 prefix: "chore"305 include: "scope"306```307308## Rollback Plan309310```javascript311// rollback.sh312#!/bin/bash313314# Save current state315git stash316git checkout -b upgrade-branch317318# Attempt upgrade319npm install package@latest320321# Run tests322if npm run test; then323 echo "Upgrade successful"324 git add package.json package-lock.json325 git commit -m "chore: upgrade package"326else327 echo "Upgrade failed, rolling back"328 git checkout main329 git branch -D upgrade-branch330 npm install # Restore from package-lock.json331fi332```333334## Common Upgrade Patterns335336### Lock File Management337```bash338# npm339npm install --package-lock-only # Update lock file only340npm ci # Clean install from lock file341342# yarn343yarn install --frozen-lockfile # CI mode344yarn upgrade-interactive # Interactive upgrades345```346347### Peer Dependency Resolution348```bash349# npm 7+: strict peer dependencies350npm install --legacy-peer-deps # Ignore peer deps351352# npm 8+: override peer dependencies353npm install --force354```355356### Workspace Upgrades357```bash358# Update all workspace packages359npm install --workspaces360361# Update specific workspace362npm install package@latest --workspace=packages/app363```364365## Resources366367- **references/semver.md**: Semantic versioning guide368- **references/compatibility-matrix.md**: Common compatibility issues369- **references/staged-upgrades.md**: Incremental upgrade strategies370- **references/testing-strategy.md**: Comprehensive testing approaches371- **assets/upgrade-checklist.md**: Step-by-step checklist372- **assets/compatibility-matrix.csv**: Version compatibility table373- **scripts/audit-dependencies.sh**: Dependency audit script374375## Best Practices3763771. **Read Changelogs**: Understand what changed3782. **Upgrade Incrementally**: One major version at a time3793. **Test Thoroughly**: Unit, integration, E2E tests3804. **Check Peer Dependencies**: Resolve conflicts early3815. **Use Lock Files**: Ensure reproducible installs3826. **Automate Updates**: Use Renovate or Dependabot3837. **Monitor**: Watch for runtime errors post-upgrade3848. **Document**: Keep upgrade notes385386## Upgrade Checklist387388```markdown389Pre-Upgrade:390- [ ] Review current dependency versions391- [ ] Read changelogs for breaking changes392- [ ] Create feature branch393- [ ] Backup current state (git tag)394- [ ] Run full test suite (baseline)395396During Upgrade:397- [ ] Upgrade one dependency at a time398- [ ] Update peer dependencies399- [ ] Fix TypeScript errors400- [ ] Update tests if needed401- [ ] Run test suite after each upgrade402- [ ] Check bundle size impact403404Post-Upgrade:405- [ ] Full regression testing406- [ ] Performance testing407- [ ] Update documentation408- [ ] Deploy to staging409- [ ] Monitor for errors410- [ ] Deploy to production411```412413## Common Pitfalls414415- Upgrading all dependencies at once416- Not testing after each upgrade417- Ignoring peer dependency warnings418- Forgetting to update lock file419- Not reading breaking change notes420- Skipping major versions421- Not having rollback plan422
Full transparency — inspect the skill content before installing.