From nx-migrate
Migrate an Nx monorepo to the latest Nx version. Runs nx migrate latest, applies migrations, resolves package conflicts, fixes lint/test/build errors, and opens a PR. Use when the user says "nx migrate", "update nx", or "upgrade nx".
How this skill is triggered — by the user, by Claude, or both
Slash command
/nx-migrate:nx-migrateThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Migrate the active Nx monorepo to the latest Nx version, resolve conflicts, fix errors, and open a PR.
Migrate the active Nx monorepo to the latest Nx version, resolve conflicts, fix errors, and open a PR.
Verify we're in an Nx workspace and on a clean branch:
# Confirm nx workspace
test -f nx.json || { echo "Not an Nx workspace"; exit 1; }
# Confirm clean git state
git status --short
If there are uncommitted changes, stop and ask the user to commit or stash them first.
Get current Nx version for the branch name:
node -e "console.log(require('./node_modules/nx/package.json').version)"
git checkout -b chore/nx-migrate-latest
npx nx@latest migrate latest 2>&1
This updates package.json and generates migrations.json if migrations exist.
npm install 2>&1
Resolve any peer dependency conflicts:
npm install fails with peer conflicts, try npm install --legacy-peer-depspackage.jsonnpm install againIf migrations.json was generated:
npx nx migrate --run-migrations 2>&1
If individual migrations fail, read the error, fix the underlying issue (usually a config file format change), and re-run.
After npm install, check if any dependency versions in sub-packages (libs/*/package.json, apps/*/package.json) are out of sync with the root package.json. In particular, peerDependencies and devDependencies in library packages must stay in sync with the versions in the root.
# Find all sub-package.json files
find libs apps -name "package.json" -not -path "*/node_modules/*" 2>/dev/null
For each sub-package found:
package.json using these mappings:
peerDependencies → root dependencies (libraries declare as peer what the app installs as prod dep)devDependencies → root devDependenciesdependencies → root dependenciestypescript, tslib, @angular/*, @nx/*, @angular/cdk, @angular/material)npm install again to update package-lock.jsonrm -f migrations.json
Run the project's validation commands. For this workspace, check CLAUDE.md for the project-specific commands. Default:
npm run lint 2>&1
npm run test 2>&1
npm run build 2>&1
For each failure:
// @ts-ignore or similar unless absolutely unavoidableRepeat until all three pass with exit code 0.
npm run e2e 2>&1
Fix any E2E failures the same way as above.
Stage all changes and commit:
git add package.json package-lock.json nx.json .nx/ tsconfig*.json
git add -u # stage any other modified tracked files
Commit message format:
chore(deps): migrate nx to vX.Y.Z
- Run nx migrate latest
- Apply generated migrations
- Resolve peer dependency conflicts (if any)
- Sync sub-package dependency versions (if any)
- Fix lint/test/build issues (list specific fixes if any)
git push -u origin chore/nx-migrate-latest
gh pr create --title "chore(deps): migrate nx to latest" --body "$(cat <<'EOF'
## Summary
- Migrated Nx workspace to vX.Y.Z
- Applied all generated migrations
- All lint, test, and build checks pass
## Test plan
- [ ] `npm run lint` passes
- [ ] `npm run test` passes
- [ ] `npm run build` passes
- [ ] `npm run e2e` passes
EOF
)"
nx migrate fails mid-run: Check if package.json was partially updated. Run git diff package.json to see what changed and fix manually.@angular/core and @angular/compiler changelogs.Provides a checklist for code reviews covering functionality, security, performance, maintainability, tests, and quality. Use for pull requests, audits, team standards, and developer training.
npx claudepluginhub tehw0lf/claude-skills --plugin nx-migrate