9.7 KiB
allowed-tools, argument-hint, description
| allowed-tools | argument-hint | description |
|---|---|---|
| Read, Grep, Glob, Bash, TodoWrite, Bash(npx), Bash(npm), Bash(git add .), Bash(git status), Bash(git commit), AskUserQuestion, WebSearch, WebFetch | [--target <patch|minor|major>] [--package <name>] [--safe] [--skip <pkg1,pkg2,...>] | Continuously updates NPM packages one at a time, verifies each update, and commits them until no more updates are available or user stops the process. |
/update-npm-packages — Continuously update NPM packages one by one
Purpose
Automate your "one-package-at-a-time" update flow with minimal risk. Continuously selects and applies eligible updates (preferring PATCH, then MINOR, optionally MAJOR), records changelog summaries, runs basic checks, and commits each update automatically. The process continues until no more updates are available or the user interrupts it.
Usage
/update-npm-packages /update-npm-packages --target patch /update-npm-packages --target minor /update-npm-packages --target major /update-npm-packages --package /update-npm-packages --safe /update-npm-packages --skip react,eslint,chalk /update-npm-packages --audit-level high /update-npm-packages --safe --audit-level critical
Flags
--target <patch|minor|major> Specify update level: PATCH (default), MINOR, or MAJOR. Default behavior: patch→minor fallback (no major unless explicitly specified) --package Update ONLY this specific package and exit (no loop, no other packages) --safe Enable interactive mode - pause before each update for user approval after showing changelog research --skip <pkg1,pkg2,...> Comma-separated list of package names to skip (e.g., "react,eslint,chalk"). Packages in this list will be excluded from updates --audit-level <low|moderate|high|critical> Set the audit severity threshold for blocking updates (default: moderate). Updates introducing vulnerabilities at or above this level will require user approval
What This Command Does
This command runs in a LOOP until no more updates are available or the user stops it.
Initial Setup (Once per run)
-
Check git working directory
- Run
git status --porcelainto check for uncommitted changes - If working directory is NOT clean (has uncommitted changes):
- Display the current status to the user
- Use
AskUserQuestionto ask: "Your working directory has uncommitted changes. Would you like to: (1) stash changes and continue, (2) commit changes first, or (3) abort?" - Responses:
stashor1- Rungit stash push -m "Auto-stash before package updates"and continuecommitor2- Stop and ask user to commit manually firstabortor3- Exit the command immediately
- If working directory is clean: Proceed to next step
- Run
-
Confirm auto-update mode (only if --safe flag is NOT present)
- If
--safeflag is NOT present: UseAskUserQuestiontool to confirm automatic updates - Question: "This will automatically update packages without manual approval. Continue?"
- Options:
["yes", "no"] - Responses:
yes- Proceed with automatic updatesno- Exit the command immediately
- If
--safeflag is present: Skip this confirmation (user will approve each update individually)
- If
-
Determine ticket
- Try
.claude/scripts/find-ticket-from-branch.shto get ticket ID from branch
- Try
For Each Package (Repeats automatically)
-
Select ONE eligible update (STEP 1)
- If
--packageis provided: Use ONLY that specific package, ignore skip list, ignore target preference- After processing this package, exit immediately (do not continue loop)
- If the package is not available for update, report this and exit
- Otherwise (no
--packageflag):- Apply skip list: If
--skipflag is provided, use that comma-separated list (e.g.,react,eslint,chalk). Usenpx ncu --rejectwith the skip list to exclude these packages - If no
--skipflag is provided: No packages are skipped (no default skip list) - If
--target majoris specified: Runnpx ncu -t major(with--rejectif skip list exists). If none found, exit loop: "All updates completed" - If
--target minoris specified: Runnpx ncu -t minor(with--rejectif skip list exists). If none found, exit loop: "All updates completed" - If
--target patchis specified or no target: Runnpx ncu -t patch(with--rejectif skip list exists). If none found, runnpx ncu -t minor. If none, exit loop: "All updates completed" - Choose exactly ONE package per iteration
- Apply skip list: If
- If
-
Quick research (STEP 2, ≤2 minutes)
- Look up the package changelog on npm/GitHub
- Always display a short summary of key changes to the user (breaking changes, new features, bug fixes)
- Always append the summary to
package-updates-changelog.mdat repo root (create if missing) - If info is hard to find within ~2 minutes, write/display a brief general note and proceed
-
User approval (STEP 2a, only with --safe flag)
- If
--safeflag is present: Display the research findings to the user - Show: package name, current version, target version, and changelog summary
- Use
AskUserQuestiontool to ask: "Proceed with this update? (yes/no/skip-all)" - Responses:
yes- Continue with this updateno- Skip this package and move to next oneskip-all- Stop the loop entirely
- If
--safeflag is NOT present: Skip this step and proceed automatically
-
Apply the update (STEP 3)
- Always run:
npm install <pkg>@<targetVersion>(e.g.,npm install inquirer@12.6.3) - No dry-run mode - this command actually applies updates
- Always run:
-
Verify basics + Security audit (STEP 4)
- Security audit check:
- Run
npm audit --audit-level=moderate --jsonto check for vulnerabilities - Parse the JSON output to count vulnerabilities by severity (critical, high, moderate, low)
- If new critical or high vulnerabilities are introduced (compare with pre-update baseline if available):
- Display the vulnerability details to the user (package name, severity, description)
- Use
AskUserQuestionto ask: "This update introduces critical/high security vulnerabilities. Would you like to: (1) revert this update, (2) continue anyway, (3) try npm audit fix, or (4) view detailed audit report?" - Responses:
revertor1- Revert the update (git reset --hard HEAD~1 && npm install) and stop the loopcontinueor2- Proceed with the update despite vulnerabilities (log warning in changelog)fixor3- Runnpm audit fixand re-verify, then ask for confirmation again if issues remainreportor4- Runnpm audit(human-readable format) and display full report, then ask again
- If moderate or low vulnerabilities: Log them in the changelog but continue (non-blocking)
- Run
- Unless
--no-verify, run:npm install && npx tsc --noEmit(always, if TypeScript is present)- Conditionally run:
npm run storybook/npm run eslint/npm run test/npm run build(only if relevant scripts exist in package.json)
- If verification scripts are not available or fail to run: Use
AskUserQuestionto ask the user:- "Verification script(s) not available or failed. Would you like to: (1) skip verification and continue, (2) suggest alternative verification steps, or (3) stop the update process?"
- On errors: attempt quick fixes or revert (
git reset --hard HEAD~1 && npm install) and stop the loop
- Security audit check:
-
Commit the update (STEP 5)
- Stage:
git add package.json package-lock.json - Auto-commit with conventional format:
<TICKET> chore: update <package> from <oldVersion> to <newVersion> - Keep first line ≤72 chars; imperative mood; accurate, concise
- Stage:
-
Continue to next package
- If
--packagewas specified: Exit immediately after committing (single package mode) - Otherwise: Automatically return to STEP 1 and process the next package
- Loop continues until no more updates or user interrupts
Important Notes
- Continuous operation: Processes ALL available updates automatically, one package at a time (unless
--packageis specified) - Single package mode: Use
--package <name>to update only one specific package and exit immediately - Prefer PATCH over MINOR: Default behavior checks patch updates first; only moves to minor if no patches available (unless specific
--targetis used) - MAJOR version updates: Use
--target majorto explicitly enable MAJOR version updates. By default, MAJOR updates are NOT processed due to potential breaking changes - Custom skip list: Use
--skip pkg1,pkg2,pkg3to exclude specific packages from updates. No default skip list (unless--packageis used - then skip list is ignored) - Security audit: Each update is automatically checked for security vulnerabilities using
npm audit. Critical/high vulnerabilities require user approval before proceeding - Audit level control: Use
--audit-level <low|moderate|high|critical>to set the severity threshold for blocking updates (default: moderate) - Auto-commit each update: Every successful update gets its own commit immediately
- Follow conventional commits: Format is
TICKET chore: update <package> from <old> to <new> - Stop on errors: If verification fails, revert the update and stop the loop (don't continue to next package)
- User can interrupt: Press Ctrl+C or stop the command at any time to halt the process
- Automatic changelog tracking: All update summaries are automatically written to
package-updates-changelog.md, including any security vulnerability notes - Safe mode: Use
--safeflag for interactive approval before each update - ideal for teams that want manual review