fix-broken-major-upgrade
Skill542 starsChanged 8 months agoMITView on GitHub
Process a major Dependabot PR: research breaking changes, apply fixes, validate CI
- Commits and pushes
In this repository5 other files it gives its agents.
The file
Show its rules and text
We split this skill into the rules it gives an agent
45 rules. About 0 are common, 22 are distinctive, and 23 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈22
Distinctive · estimate
This author's own choices. Worth a look.
23
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 18
Before launching any subagents, set up an isolated worktree so this workflow doesn't disturb the main repo checkout.
- Very specific: line 21
Run gh pr view <number> --json state,headRefName,statusCheckRollup,mergeable to get the PR state, branch name, CI status, and mergeability.
- Very specific: line 22
If the PR state is not OPEN, stop immediately — report that the PR is already merged/closed and there is nothing to do.
- Very specific: line 35
All subsequent phases must operate within WORKTREE.
- Distinctive: line 39
All subagents MUST follow these rules to avoid unnecessary permission prompts:
- Very specific: line 42
For git: Use git -C WORKTREE <subcommand> instead of cd WORKTREE && git <subcommand>.
- Very specific: line 43
For pnpm: Use pnpm --dir WORKTREE <subcommand> instead of cd WORKTREE && pnpm <subcommand>.
- Very specific: line 44
For npx: Use npx --prefix WORKTREE <subcommand>.
- Very specific: line 45
For file listing: Use ls WORKTREE/path (absolute path) instead of cd WORKTREE && ls path.
- Very specific: line 46
For all other commands: Always pass absolute paths to the command rather than cd-ing first.
- Very specific: line 47
For reading files: Prefer the Read tool over cat.
- Very specific: line 48
Keep commands simple: Run one command per Bash call.
- Very specific: line 58
Use the Task tool with subagent_type: "general-purpose" and max_turns: 30 to run a Planner agent.
- Very specific: line 69
Run git merge-base --is-ancestor origin/main HEAD to check if the branch includes the latest main.
- Very specific: line 70
Check the PR's mergeable status from step 1.
- Distinctive: line 73
If logs are expired/unavailable (common on old PRs), note this — CI will be re-run after the Implementer pushes changes.
- Distinctive: line 96
After the Planner completes, check the plan for merge conflicts.
- Distinctive: line 101
If the merge completes cleanly, proceed to the breaking change gate.
- Very specific: line 102
If there are conflicts, use the Task tool with subagent_type: "general-purpose" and max_turns: 30 to run a Conflict Resolver agent.
- Distinctive: line 111
Verify the merge completed cleanly with git status
- Distinctive: line 112
If the Conflict Resolver cannot resolve a conflict (e.g., deeply intertwined changes that require human judgment), it should report which …
- Distinctive: line 113
If unresolvable conflicts remain, skip to the Final Output section and report as FAILED with details of which conflicts could not be …
- Distinctive: line 115
If the branch is clean (no conflicts) or conflicts were successfully resolved, proceed to the breaking change gate.
- Distinctive: line 121
After the Planner completes, review the plan yourself.
- Very specific: line 126
Use the AskUserQuestion tool to ask the user how they want to proceed.
- Distinctive: line 130
Only proceed to Phase 2 once the user has explicitly approved the approach.
- Distinctive: line 132
If the upgrade can be completed with no consumer-facing breaking changes, proceed directly to Phase 2.
- Distinctive: line 143
Update API usage for breaking changes
- Distinctive: line 144
Update type signatures if needed
- Distinctive: line 145
Update configuration files if needed
- Very specific: line 151
If no packages in this monorepo are directly affected (e.g., a dev/CI-only dependency), use empty frontmatter (---\n---)
- Very specific: line 152
Look at existing .changeset/dependabot-*.md files for reference on the format
- Very specific: line 156
Run pnpm install to ensure dependencies resolve.
- Very specific: line 157
Run pnpm build (or whatever build command is used — check package.json scripts).
- Very specific: line 158
Run type checking if applicable (pnpm typecheck or pnpm tsc).
- Very specific: line 159
Run pnpm lint to catch linting issues.
- Very specific: line 160
Run pnpm test to run the test suite.
- Distinctive: line 161
If any local checks fail, fix the issue and retry.
- Distinctive: line 175
Commit with an appropriate message, push, and wait for CI again
- Distinctive: line 176
Repeat up to 3 total push+CI cycles: After 3 failures, stop and report the remaining failures with your analysis.
- Distinctive: line 207
After all phases complete (or if the upgrade was skipped/failed at a gate), present a summary.
- Distinctive: line 241
COMPLETED: All phases ran, CI passes, QA approved.
- Distinctive: line 245
If anything needs manual attention, clearly call it out.
- Distinctive: line 251
After all phases complete (regardless of status), remove the worktree to free disk space:
- Very specific: line 258
If the worktree removal fails (e.g., due to uncommitted changes), use git worktree remove --force /tmp/dependabot-upgrade-pr-<number>.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Dependency Upgrade Workflow
You are orchestrating a major dependency upgrade from a Dependabot PR. The PR URL is:
$ARGUMENTS
Phase 0: Worktree Setup
Before launching any subagents, set up an isolated worktree so this workflow doesn't disturb the main repo checkout. This enables running multiple upgrade workflows in parallel across different terminal tabs.
- Verify the PR is actionable:
- Run
gh pr view <number> --json state,headRefName,statusCheckRollup,mergeableto get the PR state, branch name, CI status, and mergeability. - If the PR
stateis notOPEN, stop immediately — report that the PR is already merged/closed and there is nothing to do. - If all CI checks are passing, stop immediately — report that CI is already green and there is nothing to do. Skip to the Final Output section and report as COMPLETED with a note that no changes were needed. To determine this: look only at checks from the "CI" workflowName in
statusCheckRollup(ignoreChangelog,Contributor License Agreement (CLA), andDependabot auto-mergeworkflows). CI is passing if every CI workflow check hasconclusionofSUCCESSorSKIPPED.
- Run
- Fetch the branch from origin:
git fetch origin <branch> main - Create a worktree (referred to as
WORKTREEhereafter) at/tmp/dependabot-upgrade-pr-<number>:
Thegit worktree add /tmp/dependabot-upgrade-pr-<number> -B <branch> origin/<branch>-Bflag resets the local branch to matchorigin/<branch>, which handles re-runs cleanly. - Install dependencies:
pnpm --dir WORKTREE install
All subsequent phases must operate within WORKTREE. Pass this path to every subagent.
IMPORTANT: Command patterns for subagents
All subagents MUST follow these rules to avoid unnecessary permission prompts:
- Never use
cd <dir> && command. Claude Code is shell-operator aware and will not auto-approve compound commands joined by&&,||,;, or|. - For git: Use
git -C WORKTREE <subcommand>instead ofcd WORKTREE && git <subcommand>. - For pnpm: Use
pnpm --dir WORKTREE <subcommand>instead ofcd WORKTREE && pnpm <subcommand>. - For npx: Use
npx --prefix WORKTREE <subcommand>. - For file listing: Use
ls WORKTREE/path(absolute path) instead ofcd WORKTREE && ls path. - For all other commands: Always pass absolute paths to the command rather than
cd-ing first. - For reading files: Prefer the
Readtool overcat. Prefer theGreptool over shellgrep/rg. Prefer theGlobtool over shellfind/lsfor file searching. - Keep commands simple: Run one command per Bash call. Avoid chaining with
&&,||, or pipes where possible. If you need multiple pieces of information, make multiple parallel tool calls.
Execute this workflow in 3 phases using specialized subagents. An optional Conflict Resolver agent may also be needed between Phase 1 and Phase 2. Each phase must complete before the next begins.
Phase 1: PLANNER (Research & Analysis)
Use the Task tool with subagent_type: "general-purpose" and max_turns: 30 to run a Planner agent. Pass it WORKTREE and the mission below.
- Fetch PR details using
gh pr view <number> --json title,body,files,headRefName,baseRefName,statusCheckRollup,commits,mergeableandgh pr diff <number>. - Identify the dependency being upgraded (name, old version, new version).
- Fetch the changelog/release notes for the dependency. Try these sources in order:
- The dependency's GitHub releases page (use
gh apiorWebFetchonhttps://github.com/<owner>/<repo>/releases) - The CHANGELOG.md in the dependency's repo
- The dependency's MIGRATION.md or upgrade guide, if one exists
- The npm page for the package
- The dependency's GitHub releases page (use
- Identify breaking changes from the changelog between the old and new versions.
- Check branch freshness (requires
origin/mainto be up to date — Phase 0 already fetched it):- Run
git merge-base --is-ancestor origin/main HEADto check if the branch includes the latest main. If not, note how far behind it is. - Check the PR's
mergeablestatus from step 1. If it'sCONFLICTING, note that the branch has merge conflicts with main that will need to be resolved before code changes.
- Run
- Check CI status on the PR using
gh pr checks <number>. If checks failed:- Fetch the failed workflow run logs using
gh run view <run-id> --log-failed - If logs are expired/unavailable (common on old PRs), note this — CI will be re-run after the Implementer pushes changes.
- Summarize what failed and why (if determinable)
- Fetch the failed workflow run logs using
- Analyze which packages in this monorepo are affected by looking at the PR diff and searching for imports/usage of the upgraded dependency across the codebase.
- Assess consumer impact. For each breaking change, classify it as:
- Internal-only: Can be fully absorbed within this repo's code (e.g., updating internal API calls, fixing private type usage). These are safe to proceed with.
- Consumer-facing: Would require consumers of these packages to change their code, configuration, or types (e.g., changed public API signatures, removed exports, changed behavior of public functions, new required peer dependencies). These must be avoided if at all reasonably possible.
- Produce a structured upgrade plan that includes:
- Dependency name and version change
- Branch freshness: up to date / behind by N commits / has merge conflicts
- Summary of breaking changes relevant to this codebase
- For each breaking change: whether it is internal-only or consumer-facing
- List of files/packages that need changes
- Specific code changes needed (with file paths and descriptions)
- Any new peer dependencies or configuration changes required
- Risk assessment (high/medium/low)
- Explicit statement of whether the upgrade can be completed without any consumer-facing breaking changes
The planner should NOT make any code changes. Research only.
Merge Conflict Resolution
After the Planner completes, check the plan for merge conflicts.
If the branch has merge conflicts with main, resolve them before proceeding:
- Fetch
origin mainand rungit merge origin/maininWORKTREE. - If the merge completes cleanly, proceed to the breaking change gate.
- If there are conflicts, use the Task tool with
subagent_type: "general-purpose"andmax_turns: 30to run a Conflict Resolver agent. Pass itWORKTREEand the Planner's analysis for context. Instruct it to:- List all conflicted files
- Open each conflicted file and resolve the conflict markers by understanding both sides:
- For dependency version conflicts (package.json): keep the Dependabot version bump while incorporating any unrelated changes from main
- For lock files (pnpm-lock.yaml): after resolving package.json, delete the lock file and run
pnpm installto regenerate it - For source code conflicts: merge both sides logically, preserving the intent of both the Dependabot change and the main branch changes
- For changeset or config conflicts: incorporate changes from both sides
- Stage all resolved files with
git add - Complete the merge with
git commit --no-edit - Verify the merge completed cleanly with
git status
- If the Conflict Resolver cannot resolve a conflict (e.g., deeply intertwined changes that require human judgment), it should report which files and conflicts remain unresolved.
- If unresolvable conflicts remain, skip to the Final Output section and report as FAILED with details of which conflicts could not be resolved.
If the branch is clean (no conflicts) or conflicts were successfully resolved, proceed to the breaking change gate.
Consumer-Facing Breaking Change Gate
After the Planner completes, review the plan yourself.
If the plan identifies any consumer-facing breaking changes, do NOT proceed to Phase 2. Instead:
- Present the consumer-facing breaking changes to the user, clearly explaining what would break for consumers and why it cannot be easily avoided.
- Use the
AskUserQuestiontool to ask the user how they want to proceed. Offer options such as:- Proceed with the consumer-facing breaking changes (and note what downstream changes consumers will need)
- Skip the upgrade entirely
- Attempt an alternative approach (if one was identified)
- Only proceed to Phase 2 once the user has explicitly approved the approach.
If the upgrade can be completed with no consumer-facing breaking changes, proceed directly to Phase 2.
Phase 2: IMPLEMENTER (Code, Test & Iterate)
After passing the gates above, use the Task tool with subagent_type: "general-purpose" and max_turns: 75 to run an Implementer agent. Pass it WORKTREE and the complete plan from Phase 1. The Implementer handles coding, testing, and fixing — all in a single agent context so it can react to test failures with full knowledge of what it changed and why.
Step 1: Apply code changes
- Apply all code changes identified in the plan:
- Update API usage for breaking changes
- Update type signatures if needed
- Update configuration files if needed
- Fix any imports that changed
- Do NOT change any public-facing APIs, exported types, or package interfaces unless the user has explicitly approved consumer-facing breaking changes in the gate above
- Write a changeset file at
.changeset/dependabot-<PR_NUMBER>.mdfollowing the existing format in this repo. If this file already exists (from a previous run), overwrite it. The file should contain:- Frontmatter listing each affected package with bump type (
patchfor internal-only dependency updates,minorormajoronly if consumer-facing changes were approved) - A short description of the dependency update (e.g., "Updated
dependency-namefrom v2 to v3") - If no packages in this monorepo are directly affected (e.g., a dev/CI-only dependency), use empty frontmatter (
---\n---) - Look at existing
.changeset/dependabot-*.mdfiles for reference on the format
- Frontmatter listing each affected package with bump type (
Step 2: Local validation (fast feedback)
- Run
pnpm installto ensure dependencies resolve. - Run
pnpm build(or whatever build command is used — checkpackage.jsonscripts). - Run type checking if applicable (
pnpm typecheckorpnpm tsc). - Run
pnpm lintto catch linting issues. - Run
pnpm testto run the test suite. - If any local checks fail, fix the issue and retry. This inner loop should be fast — no need to push for local-only failures.
Step 3: Push and validate with real CI
Once local validation passes:
- Commit all changes (including the changeset file) with a message like:
fix: apply breaking changes for <dep> v<version> upgrade - Push to the PR branch (
git push origin HEAD) - Wait for CI using
gh pr checks <PR_NUMBER> --watch --fail-level all. Run this with a 10-minute Bash timeout (timeout: 600000). If it times out before CI finishes, re-run the same command to continue waiting. Repeat until CI completes or fails. - If CI passes: Report success with a summary of all changes made.
- If CI fails:
- Fetch the failed run logs using
gh run view <run-id> --log-failed - Analyze the failures
- Fix the code
- Commit with an appropriate message, push, and wait for CI again
- Repeat up to 3 total push+CI cycles. After 3 failures, stop and report the remaining failures with your analysis.
- Fetch the failed run logs using
Important: The Implementer should stick to the plan. If it discovers something unexpected, it should note it but still complete the planned changes. If tests reveal issues not covered in the plan, it should fix them using its own judgment while staying within the scope of the upgrade.
Phase 3: QA REVIEWER (Final Review)
Once the Implementer reports success (CI passing), use the Task tool with subagent_type: "general-purpose" and max_turns: 30 to run a QA Reviewer agent. Give it:
WORKTREEso it can read files- The original plan from Phase 1
- The list of all changes made by the Implementer
- The final CI results
The QA Reviewer should:
- Read every changed file and verify the changes match the plan.
- Verify no unintended consumer-facing breaking changes — check that no public APIs, exported types, or package interfaces were changed unless explicitly approved by the user. This is the highest priority check.
- Check for regressions — did any changes inadvertently break something unrelated?
- Check for completeness — were all breaking changes from the changelog addressed?
- Check code quality — do the changes follow existing patterns in the codebase?
- Produce a final report:
- PASS/FAIL verdict
- List of changes with assessment
- Any concerns or follow-up items
- Recommendation: ready to merge, needs manual review, or needs more work
Final Output
After all phases complete (or if the upgrade was skipped/failed at a gate), present a summary. Use exactly this structured format so that batch tooling can parse the output:
## UPGRADE SUMMARY
- **Status**: COMPLETED | SKIPPED | FAILED
- **PR**: #<number>
- **Dependency**: <name> <old_version> → <new_version>
- **Risk**: high | medium | low
- **Consumer-facing breaking changes**: yes | no
- **Changeset written**: yes | no
### Breaking changes addressed
- <bullet list, or "None">
### Breaking changes requiring attention
- <bullet list, or "None">
### Consumer-facing breaking changes (if SKIPPED)
- <bullet list explaining what would break for consumers and why>
### Files modified
- <file path>: <brief description>
### Test results
- <pass/fail summary, or "Not run" if skipped>
### QA verdict
- <reviewer assessment, or "Not run" if skipped>
### Next steps
- <what the user should do>Status meanings:
- COMPLETED: All phases ran, CI passes, QA approved. Ready for human review.
- SKIPPED: Stopped at the breaking change gate due to consumer-facing changes. No code changes were made. Requires human decision.
- FAILED: Attempted the upgrade but CI still fails after max iterations, merge conflicts could not be resolved, or an error occurred.
If anything needs manual attention, clearly call it out.
Cleanup
After all phases complete (regardless of status), remove the worktree to free disk space:
git worktree remove /tmp/dependabot-upgrade-pr-<number>
git worktree pruneIf the worktree removal fails (e.g., due to uncommitted changes), use git worktree remove --force /tmp/dependabot-upgrade-pr-<number>.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

