Upgrade frontend deps

From tam159/next-role · View interactive version

Upgrade frontend deps is an AI agent skill from the GitHub repository tam159/next-role. Upgrade the Next.js frontend's pnpm dependencies to their latest versions in verified waves. Inventories with `pnpm outdated`, removes verified-unused deps, batches safe minor/patch bumps, handles the @langchain/react + langgraph-sdk lockstep pair, takes majors one commit at a time with registry pee

How to use this skill

Skill file

Upgrade the frontend's pnpm dependencies in revertable waves, preserving exact-pin style and the single-resolved-version invariant, with browser verification against a pre-upgrade baseline.

Ground rules

Workflow

1. Inventory

pnpm --dir frontend outdated --format json

Exits 1 when anything is outdated — that's data, not an error. Split the list into: patch/minor (wave 3), majors (waves 5–7), and the LangChain pair (wave 4). For every major, check compatibility before planning:

pnpm view "pkg@<target>" peerDependencies   # quote the spec; zsh doesn't word-split vars

Gate examples that have mattered: typescript-eslint's typescript: <X upper bound gates TS majors; eslint plugins' eslint peer range gates eslint majors. A major whose peers don't fit gets held back, not forced.

Read release notes for the auth/database libraries even below a major, patches included: better-auth 1.7.0 (a minor) added a NOT NULL account.issuer column with a required backfill, and 1.7.3 (a patch) reverted it — databases that ran 1.7.0–1.7.2 must relax that column before 1.7.3+ can sign anyone up (README, frontend/scripts/better-auth-1.7.3-relax-account-issuer.sql). A schema migration is not a wave; hold the package (~ range, or an exact pin when the problem is a patch) and leave the bump to its own PR that also updates the README migration steps. Verify such a bump with the pinned CLI's read-only auth check schema.

2. Branch + baseline

git switch -c chore/upgrade-frontend-deps
cd frontend && pnpm install --frozen-lockfile   # host node_modules current (pre-commit hooks need it)
pnpm type-check && pnpm lint && pnpm test && pnpm build   # "Gate G" — must be green BEFORE touching anything

Record the current lint warning count — you'll need to distinguish pre-existing warnings from upgrade fallout later.

Then capture a browser baseline with agent-browser (agent-browser skills get core for the workflow):

cat <<'EOF' | agent-browser eval --stdin
{
  const el = document.querySelector('textarea');
  const set = Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype, 'value').set;
  set.call(el, `multi
line
prompt`);
  el.dispatchEvent(new Event('input', { bubbles: true }));
}
EOF
agent-browser find role button click --name "Send"

3. Wave: removals, then minor/patch batch

If any dep looks unused, verify empirically (grep imports across src/ AND config files — a dep can be config-only like a tailwind plugin), confirm with the user if it wasn't already agreed, remove, and commit separately.

Then bump all patch/minors in one command with the new versions as explicit floors, exact pins via -E:

pnpm --dir frontend add pkgA@^x.y.z pkgB@^x.y.z ...
pnpm --dir frontend add -E react@x.y.z react-dom@x.y.z
pnpm --dir frontend add -D devPkg@^x.y.z ...

Gate G + restart + a quick browser smoke (page loads, open an existing thread). Commit.

4. Wave: @langchain/react + langgraph-sdk lockstep

Follow the protocol in frontend/AGENTS.md exactly: bump @langchain/react first, read its pinned SDK version (pnpm view "@langchain/react@<ver>" dependencies), then pnpm --dir frontend add -E @langchain/langgraph-sdk@<that-version>, then:

pnpm --dir frontend run check:sdk-sync   # must print "single copy"

This wave touches the streaming layer — run the full E2E (not just a smoke): streaming tokens, subagent cards populating live, then reload the idle thread and submit again (catches replay/resume regressions). Commit.

5. Wave: independent majors, one commit each, cheapest first

For each major: read the changelog/release notes, but treat the installed package's .d.ts as ground truth for API shape — and verify semantics empirically when the types are ambiguous. Real example: react-resizable-panels v4's d.ts doesn't say bare numeric sizes became pixels (v3: percent); only a browser check caught panels collapsing to 30px. Research can be wrong in both directions — a claim that "numbers still mean %" survived two reviews here.

Per package: pnpm add, make any source edits, Gate G, targeted browser check of the surfaces that package owns (markdown → chat bubbles + dialogs; highlighter → code blocks light/dark; icons → render pass; panels → drag, reload-persistence, sidebar toggle, console clean), commit. One restart at wave end is fine if no package needed an interactive check earlier.

6. Wave: toolchain (eslint / typescript)

Dev-only but loud. Expect new findings, not breakage: new eslint core rules and react-hooks compiler rules flag pre-existing patterns. Policy: fix trivial ones; downgrade noisy new rules to "warn" in eslint.config.js with a comment — do not refactor app logic inside a deps PR. For TS majors, check tsconfig fallout (TS 6 dropped auto-inclusion of node_modules/@types → needed "types": ["node"]). Gate G, commit.

7. Wave: coupled/risky majors last (own commits = revert lever)

Anything that rewires a build pipeline (CSS framework, bundler plugin) goes last, in two commits: codemod output, then manual fixes. Two lessons that generalize:

Full visual checklist vs baseline (light + dark, dialogs, selects, hover, print page), plus a cold-build check: rm -rf frontend/.next && pnpm --dir frontend build and grep the emitted CSS.

8. Finalize

pnpm --dir frontend dedupe
pnpm --dir frontend run check:sdk-sync          # dedupe must not split the SDK copy
pnpm --dir frontend outdated                    # expect: empty, or only documented hold-backs
cd frontend && pnpm quality && pnpm test && pnpm build
docker compose restart frontend
pnpm --dir frontend why clsx react react-dom @langchain/langgraph-sdk   # one version each

Run the full E2E one last time on the final state, then commit the dedupe diff if any.

9. PR

Push using gh or git push (already uses the right SSH identity), open the PR with mcp__github__create_pull_request (owner tam159, repo next-role, base main). Body follows the PR #15/#16 format: Summary / Upgraded table (old → new, mark exact pins) / Removed / Held back (with reasons) / Migration notes / Test plan. Watch code-quality + backend-tests; fix failures in the same PR. Leave merging to the user.

10. Report

Gotchas

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.