Skip to content

Commit dca77e9

Browse files
fix package versions
1 parent 08fa0d1 commit dca77e9

3 files changed

Lines changed: 116 additions & 227 deletions

File tree

.claude/skills/upgrade-packages/SKILL.md

Lines changed: 61 additions & 218 deletions
Original file line numberDiff line numberDiff line change
@@ -7,254 +7,97 @@ argument-hint: "[--check-only] [--major] [package-name]"
77

88
# Upgrade Packages
99

10-
Upgrade all project dependencies to their latest compatible (or latest major, if `--major`) versions.
10+
Upgrade all project dependencies to their latest compatible versions (or latest major with `--major`), then drive known vulnerabilities to zero.
1111

1212
## Arguments
1313

14-
- `--check-only`List outdated packages without upgrading. Stop after Step 2.
15-
- `--major`Include major version bumps (breaking changes). Without this flag, stay within semver-compatible ranges.
16-
- Any other argument is treated as a specific package name to upgrade (instead of all packages).
14+
- `--check-only`list outdated packages and stop after Step 2.
15+
- `--major`allow major-version bumps; otherwise stay within semver-compatible ranges.
16+
- Any other argument is treated as a single package name to upgrade.
1717

18-
## Step 1 — Detect language and package manager
18+
## Ecosystem command reference
1919

20-
Inspect the repo root and subdirectories for manifest files. Identify ALL that apply:
20+
Look up the detected ecosystem(s) in this table and use the matching commands in each step below. Process every ecosystem present.
2121

22-
| Manifest file | Language | Package manager |
23-
|---|---|---|
24-
| `Cargo.toml` | Rust | cargo |
25-
| `package.json` | Node.js / TypeScript | npm / yarn / pnpm (check lockfile) |
26-
| `pyproject.toml` | Python | pip / uv / poetry (check `[build-system]` or `[tool.poetry]`) |
27-
| `requirements.txt` | Python | pip |
28-
| `setup.py` / `setup.cfg` | Python | pip |
29-
| `pubspec.yaml` | Dart / Flutter | pub |
30-
| `*.csproj` / `*.fsproj` / `*.sln` | C# / F# | NuGet (dotnet) |
31-
| `Directory.Build.props` | C# / F# | NuGet (dotnet) |
32-
| `go.mod` | Go | go modules |
33-
| `Gemfile` | Ruby | bundler |
34-
| `composer.json` | PHP | composer |
35-
| `build.gradle` / `build.gradle.kts` | Java / Kotlin | gradle |
36-
| `pom.xml` | Java | maven |
22+
| Manifest | Ecosystem | Outdated | Upgrade (semver) | Upgrade (`--major`) | Audit | Override mechanism |
23+
|---|---|---|---|---|---|---|
24+
| `package.json` (npm) | Node | `npm outdated` | `npm update` | `npx npm-check-updates -u && npm install` | `npm audit --json` | `"overrides"` in package.json |
25+
| `package.json` (pnpm) | Node | `pnpm outdated` | `pnpm update` | `pnpm update --latest` | `pnpm audit --json` | `"pnpm.overrides"` |
26+
| `package.json` (yarn) | Node | `yarn outdated` | `yarn up` | `yarn up -R '**'` | `yarn npm audit --json` | `"resolutions"` |
27+
| `Cargo.toml` | Rust | `cargo outdated` | `cargo update` | `cargo update --breaking` | `cargo audit` | `[patch.crates-io]` in Cargo.toml |
28+
| `pyproject.toml` / `requirements.txt` | Python (pip/uv/poetry) | `pip list --outdated` · `uv pip list --outdated` · `poetry show --outdated` | `pip install -U -r requirements.txt` · `uv lock --upgrade` · `poetry update` | edit specifiers · `uv lock --upgrade` · `poetry update --latest` | `pip-audit --strict` | pin in `requirements.txt` / `constraints.txt` / `>=` in pyproject |
29+
| `*.csproj` / `Directory.Build.props` | .NET (NuGet) | `dotnet list package --outdated --include-transitive` | `dotnet add <proj> package <Name>` (per package) or `dotnet outdated --upgrade` | same | `dotnet list package --vulnerable --include-transitive` | explicit `<PackageReference Version>` in consuming project, or `<PackageVersion>` in `Directory.Packages.props` |
30+
| `go.mod` | Go | `go list -m -u all` | `go get -u ./... && go mod tidy` | same | `govulncheck ./...` | `replace` directive in go.mod |
31+
| `Gemfile` | Ruby | `bundle outdated` | `bundle update` | edit Gemfile constraints then `bundle update` | `bundle audit check --update` | explicit version constraint in Gemfile |
32+
| `composer.json` | PHP | `composer outdated` | `composer update` | edit constraints then `composer update` | `composer audit` | explicit version in composer.json |
33+
| `pubspec.yaml` | Dart/Flutter | `dart pub outdated` | `dart pub upgrade` | `dart pub upgrade --major-versions` | `dart pub deps` + check https://osv.dev | explicit version in pubspec.yaml |
34+
| `build.gradle(.kts)` | Gradle | `./gradlew dependencyUpdates` | edit versions then `./gradlew dependencies` | same | `./gradlew dependencyCheckAnalyze` (OWASP) | version catalog entry |
35+
| `pom.xml` | Maven | `mvn versions:display-dependency-updates` | `mvn versions:use-latest-releases && mvn versions:commit` | same | OWASP `dependency-check` | explicit `<version>` in pom.xml |
3736

38-
If multiple languages are present, process each one in order.
37+
Install scanner binaries if missing (`cargo install cargo-audit`, `pip install pip-audit`, `go install golang.org/x/vuln/cmd/govulncheck@latest`, `gem install bundler-audit`). Do not skip a scan because the tool is missing.
3938

40-
**If you cannot detect any manifest file, stop and tell the user.**
39+
Authoritative upgrade docs (fetch with WebFetch before running anything non-obvious): [npm](https://docs.npmjs.com/cli/v10/commands/npm-update), [pnpm](https://pnpm.io/cli/update), [yarn](https://yarnpkg.com/cli/up), [cargo](https://doc.rust-lang.org/cargo/commands/cargo-update.html), [pip](https://pip.pypa.io/en/stable/cli/pip_install/), [uv](https://docs.astral.sh/uv/reference/cli/), [poetry](https://python-poetry.org/docs/cli/#update), [dotnet](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-add-package), [go](https://go.dev/ref/mod#go-get), [bundler](https://bundler.io/man/bundle-update.1.html), [composer](https://getcomposer.org/doc/03-cli.md#update-u-upgrade), [pub](https://dart.dev/tools/pub/cmd/pub-outdated), [gradle](https://docs.gradle.org/current/userguide/dependency_management.html), [maven](https://www.mojohaus.org/versions/versions-maven-plugin/).
4140

42-
## Step 2 — List outdated packages
43-
44-
Run the appropriate command to list what's outdated BEFORE upgrading anything. Show the user what will change.
45-
46-
### Rust
47-
```bash
48-
cargo outdated # install: cargo install cargo-outdated
49-
cargo update --dry-run
50-
```
51-
**Read the docs:** https://doc.rust-lang.org/cargo/commands/cargo-update.html
52-
53-
### Node.js (npm)
54-
```bash
55-
npm outdated
56-
```
57-
If using yarn: `yarn outdated`. If using pnpm: `pnpm outdated`.
58-
59-
**Read the docs:**
60-
- npm: https://docs.npmjs.com/cli/v10/commands/npm-update
61-
- yarn: https://yarnpkg.com/cli/up
62-
- pnpm: https://pnpm.io/cli/update
63-
64-
### Python (pip)
65-
```bash
66-
pip list --outdated
67-
```
68-
If using uv: `uv pip list --outdated`. If using poetry: `poetry show --outdated`.
69-
70-
**Read the docs:**
71-
- pip: https://pip.pypa.io/en/stable/cli/pip_install/#cmdoption-U
72-
- uv: https://docs.astral.sh/uv/reference/cli/#uv-pip-install
73-
- poetry: https://python-poetry.org/docs/cli/#update
74-
75-
### Dart / Flutter
76-
```bash
77-
dart pub outdated
78-
# or for Flutter projects:
79-
flutter pub outdated
80-
```
81-
**Read the docs:** https://dart.dev/tools/pub/cmd/pub-outdated
82-
83-
### C# / F# (NuGet)
84-
```bash
85-
dotnet list package --outdated
86-
```
87-
For transitive dependencies too: `dotnet list package --outdated --include-transitive`
88-
89-
**Read the docs:** https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-list-package
90-
91-
### Go
92-
```bash
93-
go list -m -u all
94-
```
95-
**Read the docs:** https://go.dev/ref/mod#go-get
96-
97-
### Ruby (Bundler)
98-
```bash
99-
bundle outdated
100-
```
101-
**Read the docs:** https://bundler.io/man/bundle-update.1.html
41+
## Step 1 — Detect ecosystems
10242

103-
### PHP (Composer)
104-
```bash
105-
composer outdated
106-
```
107-
**Read the docs:** https://getcomposer.org/doc/03-cli.md#update-u-upgrade
43+
Scan repo root and subdirectories for manifest files listed above. If none, stop and tell the user.
10844

109-
### Java / Kotlin (Gradle)
110-
```bash
111-
./gradlew dependencyUpdates # requires ben-manes/gradle-versions-plugin
112-
```
113-
**Read the docs:** https://docs.gradle.org/current/userguide/dependency_management.html
114-
115-
### Java (Maven)
116-
```bash
117-
mvn versions:display-dependency-updates
118-
```
119-
**Read the docs:** https://www.mojohaus.org/versions/versions-maven-plugin/display-dependency-updates-mojo.html
120-
121-
If `--check-only` was passed, **stop here** and report the outdated list.
122-
123-
## Step 3 — Read the official upgrade docs
124-
125-
**Before running any upgrade command, you MUST fetch and read the official documentation URL listed above for the detected package manager.** Use WebFetch to retrieve the page. This ensures you use the correct flags and understand the behavior. Do not guess at flags or options from memory.
126-
127-
## Step 4 — Upgrade packages
128-
129-
Run the upgrade. If a specific package name was given as an argument, upgrade only that package.
130-
131-
### Rust
132-
```bash
133-
cargo update # semver-compatible updates
134-
# --major flag:
135-
cargo update --breaking # major version bumps (cargo 1.84+)
136-
```
137-
For workspace members, run from workspace root.
138-
139-
### Node.js (npm)
140-
```bash
141-
npm update # semver-compatible (within package.json ranges)
142-
# --major flag:
143-
npx npm-check-updates -u && npm install # bump package.json to latest majors
144-
```
145-
If using yarn: `yarn up` / `yarn up -R '**'`. If using pnpm: `pnpm update` / `pnpm update --latest`.
146-
147-
### Python (pip)
148-
For `requirements.txt`:
149-
```bash
150-
pip install --upgrade -r requirements.txt
151-
pip freeze > requirements.txt # pin new versions
152-
```
153-
For `pyproject.toml` with pip: update version specifiers manually, then `pip install -e ".[dev]"`.
154-
For uv: `uv pip install --upgrade -r requirements.txt` or `uv lock --upgrade`.
155-
For poetry: `poetry update` / `poetry update --latest` (with `--major` flag).
156-
157-
### Dart / Flutter
158-
```bash
159-
dart pub upgrade # semver-compatible
160-
# --major flag:
161-
dart pub upgrade --major-versions # bump to latest majors
162-
```
163-
For Flutter: replace `dart` with `flutter`.
45+
## Step 2 — List outdated packages
16446

165-
### C# / F# (NuGet)
166-
There is NO single `dotnet upgrade-all` command. You must upgrade each package individually:
167-
```bash
168-
# For each outdated package from Step 2:
169-
dotnet add <project.csproj> package <PackageName> # upgrades to latest
170-
# Or with specific version:
171-
dotnet add <project.csproj> package <PackageName> --version <version>
172-
```
173-
For `Directory.Build.props`, edit the version numbers directly in the XML.
47+
Run the "Outdated" column command for each detected ecosystem and show the diff to the user. If `--check-only`, stop here.
17448

175-
**Read the docs:** https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-add-package
49+
## Step 3 — Upgrade
17650

177-
Alternatively, use the dotnet-outdated global tool:
178-
```bash
179-
dotnet tool install --global dotnet-outdated-tool
180-
dotnet outdated --upgrade
181-
```
182-
**Read the docs:** https://github.com/dotnet-outdated/dotnet-outdated
51+
Run the "Upgrade (semver)" column, or "Upgrade (`--major`)" if `--major` was passed. If a package name argument was given, scope the upgrade to that package.
18352

184-
### Go
185-
```bash
186-
go get -u ./... # update all dependencies
187-
go mod tidy # clean up go.sum
188-
```
189-
For a specific package: `go get -u <module>@latest`.
53+
## Step 4 — Build & test
19054

191-
### Ruby (Bundler)
192-
```bash
193-
bundle update # all gems
194-
# specific gem:
195-
bundle update <gem-name>
196-
```
55+
Run `make ci` (or the project's build/test commands from the Makefile, CI workflow, or CLAUDE.md). Fix any breakage using release notes / migration guides. If stuck after 3 attempts on the same failure, stop and report.
19756

198-
### PHP (Composer)
199-
```bash
200-
composer update # all packages
201-
# specific package:
202-
composer update <vendor/package>
203-
```
204-
With `--major`: edit `composer.json` version constraints first, then `composer update`.
57+
## Step 5 — Vulnerability scan (MANDATORY)
20558

206-
### Java / Kotlin (Gradle)
207-
Edit version numbers in `build.gradle` / `build.gradle.kts` / version catalogs (`libs.versions.toml`), then:
208-
```bash
209-
./gradlew dependencies # verify resolution
210-
```
59+
Upgrading top-level deps does NOT guarantee transitive deps are clean. Drive the count to **zero**.
21160

212-
### Java (Maven)
213-
```bash
214-
mvn versions:use-latest-releases # update pom.xml to latest releases
215-
mvn versions:commit # remove backup pom
216-
```
61+
**5a. Scan** — run the "Audit" column for each ecosystem.
21762

218-
## Step 5 — Verify the upgrade
63+
**5b. Read runtime constraints** — before pinning anything:
64+
- npm: `engines.node` + `.github/workflows/*.yml` `node-version:` + `.nvmrc`
65+
- Python: `requires-python` / `.python-version`
66+
- .NET: `<TargetFramework(s)>` in every project
67+
- Go: `go` directive in `go.mod`
68+
- Rust: `rust-version` in `Cargo.toml`
69+
- Ruby: `.ruby-version` / `ruby` directive in Gemfile
21970

220-
After upgrading, run the project's build and test suite to confirm nothing broke:
71+
**5c. For each advisory, pick the highest compatible fix:**
72+
1. Look up the fixed-version range (scanner output, else [osv.dev](https://osv.dev) or [github.com/advisories](https://github.com/advisories)).
73+
2. List published versions newest-first (`npm view <pkg> versions`, `pip index versions <pkg>`, `cargo search <pkg>`, `dotnet package search <pkg>`, `gem info <pkg>`).
74+
3. Pick the newest version that is both in the fix range AND satisfies 5b's runtime floor. Prefer a major jump only when no lower major has a fix.
22175

222-
```bash
223-
make ci
224-
```
76+
**5d. Apply via the "Override mechanism" column.** Scope narrowly when consumers disagree on major (e.g. `eslint``ajv@6` vs `secretlint``ajv@8`: override to `"parent > pkg"` not top-level).
22577

226-
If `make ci` is not available, run whatever build/test commands the project uses (check the Makefile, CI workflow, or CLAUDE.md).
78+
**5e. Re-install, re-scan, iterate.** Loop 5c–5e until zero. If a previous override broke Step 4, re-scope and re-run Step 4.
22779

228-
If tests fail:
229-
1. Read the failure output carefully
230-
2. Check the changelog / migration guide for the upgraded packages (fetch the release notes URL if available)
231-
3. Fix breaking changes in the code
232-
4. Re-run tests
233-
5. If stuck after 3 attempts on the same failure, report it to the user with the error details and the package that caused it
80+
**5f. If zero is impossible** (no fix exists, or only fix needs an unauthorised runtime bump): list each residual advisory with package, installed version, advisory ID, severity, available fix version, reason not applied, recommended action. Do NOT suppress via `--omit=dev`, `audit.level`, allowlists, `--ignore-vuln`, etc.
23481

23582
## Step 6 — Report
23683

237-
Provide a summary:
238-
239-
- Packages upgraded (old version -> new version)
240-
- Packages skipped (and why, e.g., major version bump without `--major` flag)
241-
- Build/test result after upgrade
242-
- Any breaking changes that were fixed
243-
- Any packages that could not be upgraded (with error details)
84+
- Packages upgraded (old → new)
85+
- Packages skipped (and why — major without `--major`, etc.)
86+
- Transitive overrides applied for security (package, version, scope, advisory IDs fixed)
87+
- Residual advisories with justification (from 5f), if any
88+
- Build/test result
24489

24590
## Rules
24691

247-
- **Always list outdated packages first** before upgrading anything
248-
- **Always read the official docs** for the package manager before running upgrade commands
249-
- **Always run tests after upgrading** to catch breakage immediately
250-
- **Never remove packages** unless they were explicitly deprecated and replaced
251-
- **Never downgrade packages** unless rolling back a broken upgrade
252-
- **Never modify lockfiles manually** (package-lock.json, yarn.lock, Cargo.lock, etc.) — let the package manager regenerate them
253-
- **Commit nothing** — leave changes in the working tree for the user to review
92+
- List outdated first. Run tests after upgrading. Run the Step 5 scan — mandatory.
93+
- Never remove packages unless deprecated and replaced. Never modify lockfiles manually — let the package manager regenerate.
94+
- Never downgrade except to roll back a broken upgrade, or to pin a transitive via override for a security fix (Step 5d).
95+
- Never suppress vulnerability reports (`--omit=dev`, `audit.level`, `.audit-ci.json`, `--ignore-vuln`, etc.) — fix them.
96+
- Commit nothing — leave changes in the working tree.
25497

25598
## Success criteria
25699

257-
- All outdated packages upgraded to latest compatible (or latest major if `--major`)
258-
- Build passes
259-
- Tests pass
260-
- User has a clear summary of what changed
100+
- Outdated packages upgraded to latest compatible (or latest major if `--major`).
101+
- Build and tests pass.
102+
- Vulnerability scanner reports **zero** advisories, or every residual one is listed and justified per 5f.
103+
- Report includes any transitive overrides applied for security.

0 commit comments

Comments
 (0)