|
| 1 | +--- |
| 2 | +name: linea-dependency-maintenance |
| 3 | +description: Safely plan and execute JavaScript/TypeScript dependency maintenance across npm and pnpm repositories, including npm lockfiles, pnpm workspaces, catalogs, overrides, release-age policies, audits, CI validation, Dependabot boundaries, PRs, and GitHub tracking issues. Use whenever the user asks to update, bump, refresh, audit, clean, modernize, or review dependencies, reduce vulnerabilities, clean overrides, or prepare dependency PRs/issues. |
| 4 | +metadata: |
| 5 | + short-description: Safe npm/pnpm dependency maintenance |
| 6 | +--- |
| 7 | + |
| 8 | +# Dependency Maintenance |
| 9 | + |
| 10 | +Use this workflow to maximize safe dependency progress without changing the repository's package-manager contract or hiding remaining risk. |
| 11 | + |
| 12 | +## Preflight |
| 13 | + |
| 14 | +1. Read repo instructions first: `AGENTS.md`, `CLAUDE.md`, package-specific instructions, and `CONTRIBUTING.md`. |
| 15 | +2. Detect the package-manager contract from lockfiles, `packageManager`, CI, deploy config, and package-manager guard scripts: |
| 16 | + - npm repo: use npm, preserve `package-lock.json`, and validate with `npm ci`. |
| 17 | + - pnpm repo: use pnpm, preserve `pnpm-lock.yaml`, `pnpm-workspace.yaml`, catalogs, and overrides. |
| 18 | + - Do not introduce a different lockfile, workspace file, package-manager metadata, or install command. |
| 19 | +3. Check branch and worktree state with `git status --short --branch`. If unrelated changes are present, use an isolated worktree or avoid touching those files. |
| 20 | +4. Read `.nvmrc`, `.node-version`, `engines`, `.npmrc`, CI workflows, deploy config, and `dependabot.yml`. |
| 21 | +5. Capture the baseline: outdated report, audit report, lockfile state, and relevant validation commands. |
| 22 | + |
| 23 | +## Policy |
| 24 | + |
| 25 | +- Treat release-age and cooldown rules as hard gates. Compute exact cutoff timestamps before selecting versions. |
| 26 | +- In pnpm repos, `minimumReleaseAge` is a maturity window in minutes; respect `minimumReleaseAgeExclude` exactly. |
| 27 | +- Treat npm/pnpm dependency updates as owned by this skill. Do not re-enable Dependabot npm/pnpm package-ecosystem jobs unless the user explicitly asks; GitHub Actions, Docker, and other non-JavaScript ecosystems may remain under Dependabot. |
| 28 | +- Preserve version style: exact pins, ranges, `catalog:` references, `workspace:` references, and repo-specific package placement. |
| 29 | +- Default PR scope is eligible patch and minor updates. Major upgrades, risky transitive fixes, and broad migrations get tracking issues unless the user explicitly approves doing them now. |
| 30 | +- Prefer official migration guides, changelogs, package registry metadata, and advisory pages for decisions that affect risk. |
| 31 | + |
| 32 | +## Inventory |
| 33 | + |
| 34 | +Build an inventory from direct dependencies, dev dependencies, peer dependencies, optional dependencies, catalogs, overrides, lockfiles, and audit output. |
| 35 | + |
| 36 | +Use native commands first: |
| 37 | + |
| 38 | +```bash |
| 39 | +npm outdated --json || true |
| 40 | +npm audit --json || true |
| 41 | +npm explain <package> |
| 42 | +npm ls <package> |
| 43 | + |
| 44 | +pnpm outdated -r --format json || true |
| 45 | +pnpm audit --json || true |
| 46 | +pnpm why <package> -r |
| 47 | +``` |
| 48 | + |
| 49 | +When registry-age gates matter, use the bundled helper as a reproducible first pass: |
| 50 | + |
| 51 | +```bash |
| 52 | +node <skill-dir>/scripts/eligible-updates.mjs --manager auto --days 3 |
| 53 | +``` |
| 54 | + |
| 55 | +Replace `<skill-dir>` with the directory containing this `SKILL.md`. Adjust `--days` or `--minutes` to match the repo policy. |
| 56 | + |
| 57 | +## Triage |
| 58 | + |
| 59 | +Classify every candidate before changing files: |
| 60 | + |
| 61 | +- Safe now: patch/minor, older than cutoff, peer-compatible, and locally validatable. |
| 62 | +- Blocked non-major: too fresh, peer-conflicting, runtime-breaking, upstream-pinned, or requiring nontrivial code/config migration. |
| 63 | +- Major migration: semver-major or framework/toolchain migration that needs a dedicated issue. |
| 64 | +- Audit-only blocked: no patched version, incompatible transitive major, bundled dependency, or upstream package must move first. |
| 65 | +- Removable: unused dependency that should be deleted instead of bumped. |
| 66 | + |
| 67 | +Group tightly coupled packages together when separate bumps are likely to create peer, type, or runtime friction. |
| 68 | + |
| 69 | +## Apply |
| 70 | + |
| 71 | +- Update catalogs before workspace manifests when dependencies are shared through `catalog:`. |
| 72 | +- In npm repos, update `package.json` and regenerate `package-lock.json` with npm. Prefer lockfile-only install when appropriate, then validate with clean install. |
| 73 | +- In pnpm repos, regenerate `pnpm-lock.yaml` with normal pnpm install flow. Do not bypass `minimumReleaseAge`. |
| 74 | +- Preserve package-manager script safety settings such as `engine-strict`, `ignore-scripts`, LavaMoat allow-scripts, and `only-allow`. |
| 75 | +- Keep code/config changes minimal and only when required by the dependency update. |
| 76 | +- If a supposedly safe update breaks validation, revert just that candidate and document why it moved to blocked work. |
| 77 | + |
| 78 | +## Overrides |
| 79 | + |
| 80 | +Treat overrides as temporary exceptions: |
| 81 | + |
| 82 | +- Remove stale overrides after direct bumps when they no longer affect resolution or audit posture. |
| 83 | +- Keep or add only targeted overrides that are compatible with the dependent package and materially improve security or toolchain behavior. |
| 84 | +- Avoid broad overrides for transitive major jumps unless upstream compatibility is proven. |
| 85 | +- Document every kept override with package path, advisory or compatibility reason, current resolution, target resolution, and remaining risk. |
| 86 | + |
| 87 | +## Validation |
| 88 | + |
| 89 | +Run the narrowest meaningful checks first, then broaden by blast radius: |
| 90 | + |
| 91 | +- install or clean install |
| 92 | +- audit after changes |
| 93 | +- lint, typecheck, build, and tests |
| 94 | +- repo-specific checks such as Docusaurus prebuild/build, Turbo filters, Prisma generate, Playwright/Storybook browsers, Docker builds, Foundry/forge, subgraph codegen/tests, or generated-doc checks |
| 95 | + |
| 96 | +If a command cannot run, report why. If CI fails, inspect the actual logs and classify the failure as introduced by the update, exposed baseline debt, or external/non-actionable. |
| 97 | + |
| 98 | +## Tracking |
| 99 | + |
| 100 | +Open one draft PR for safe updates unless the user asks otherwise. Include: |
| 101 | + |
| 102 | +- updated packages and grouped stacks |
| 103 | +- release-age cutoff and skipped versions with publish timestamps |
| 104 | +- audit before/after summary |
| 105 | +- overrides removed, kept, added, or narrowed |
| 106 | +- blocked non-major updates and remaining advisories |
| 107 | +- major or blocked migration issue links |
| 108 | +- validation commands and caveats |
| 109 | + |
| 110 | +Open English `chore(deps): ...` issues for deferred major upgrades or blocked migration streams. Each issue should include official docs, current and target versions, expected code areas, migration plan, validation, rollout risk, and rollback notes. |
| 111 | + |
| 112 | +## Stop And Ask |
| 113 | + |
| 114 | +Pause before contract deployments, public API breakage, package-manager migration, broad refactors, invalid override trees, or CI failures that suggest a cross-cutting regression. |
| 115 | + |
| 116 | +## Additional Resources |
| 117 | + |
| 118 | +- For npm/package-lock repositories, read `references/npm.md`. |
| 119 | +- For pnpm workspace/catalog/override repositories, read `references/pnpm.md`. |
| 120 | +- For reproducible release-age inventory, run `scripts/eligible-updates.mjs`. |
0 commit comments