$npx -y skills add pulumi/agent-skills --skill pulumi-upgrade-providerAutomate Pulumi provider repo upgrades with the upgrade-provider tool. Use when upgrading a pulumi provider repository to a new upstream version, running upgrade-provider, and addressing its common failure modes like patch conflicts or missing module mappings.
| 1 | # Pulumi Upgrade Provider |
| 2 | |
| 3 | ## Overview |
| 4 | |
| 5 | Run `upgrade-provider --no-submit`, fix known failures, and rerun until success. During the run loop, the tool owns branch and generated-commit state but does not push or mutate GitHub. After success, review and correct the local result before submitting it using the plan printed by the tool. |
| 6 | |
| 7 | ## Preflight |
| 8 | |
| 9 | 1. Record existing changes as the pre-upgrade baseline: |
| 10 | |
| 11 | ```bash |
| 12 | baseline_file="${TMPDIR:-/tmp}/upgrade-provider-$(basename "$PWD")-baseline.txt" |
| 13 | git status --short --untracked-files=all | tee "$baseline_file" |
| 14 | ``` |
| 15 | |
| 16 | Existing changes do not block the upgrade, but the tool stages broadly and may include them in generated commits. If practical, isolate clearly unrelated work in another branch or worktree, move local-only files, or add untracked local artifacts to `.git/info/exclude`. Otherwise proceed and carry this baseline into the final review. Do not add a repository `.gitignore` rule unless the path should be ignored for all contributors. |
| 17 | |
| 18 | 2. Keep the run log outside the repository so the tool cannot stage it. |
| 19 | |
| 20 | ## Run Loop |
| 21 | |
| 22 | 1. Run from repo root: |
| 23 | |
| 24 | ```bash |
| 25 | log_file="${TMPDIR:-/tmp}/upgrade-provider-$(basename "$PWD").log" |
| 26 | upgrade-provider $ORG/$REPO --repo-path . --no-submit > "$log_file" 2> /dev/null |
| 27 | ``` |
| 28 | |
| 29 | Preserve `--no-submit` on every retry. |
| 30 | |
| 31 | 2. Wait for completion (can take up to 10 minutes). |
| 32 | 3. Check for errors by scanning the log for lines starting with `error: `: |
| 33 | |
| 34 | ```bash |
| 35 | if command -v rg >/dev/null 2>&1; then |
| 36 | rg -n '^error: ' "$log_file" || true |
| 37 | else |
| 38 | grep -n '^error: ' "$log_file" || true |
| 39 | fi |
| 40 | ``` |
| 41 | |
| 42 | 4. On a successful exit, first check whether the tool found that no upgrade was required: |
| 43 | |
| 44 | ```bash |
| 45 | if grep -Fq 'No actions needed' "$log_file"; then |
| 46 | echo 'No actions needed' |
| 47 | fi |
| 48 | ``` |
| 49 | |
| 50 | If present, report that the provider is already current or the requested target is not an upgrade, then stop successfully. There is no local upgrade to review or submit. |
| 51 | |
| 52 | 5. Otherwise, extract and read the complete local-completion report from the captured stdout: |
| 53 | |
| 54 | ```bash |
| 55 | awk '/^Upgrade completed locally;/{found=1} found' "$log_file" |
| 56 | ``` |
| 57 | |
| 58 | This includes the proposed PR body and metadata, review commands, and every skipped submission action. |
| 59 | |
| 60 | 6. If failed, fix using this skill's `references/upgrade-provider-errors.md` (from the skill folder, not the repo), then rerun with `--no-submit`. If upstream migrated from Terraform Plugin SDKv2 to Plugin Framework, use the migration-guide routing in that reference instead of treating the framework change alone as an architectural blocker. For upstream `go get` failures involving ignored `replace` directives or `unknown revision v0.0.0`, rerun with `--target-version` after applying the documented `provider/go.mod` replacements; preserve the original major/non-major intent and add `--major` only for actual major version upgrades. |
| 61 | 7. If a fix requires creating/amending/removing/rebasing patches, use the `upstream-patches` skill for the patch workflow. Interrupted patch workflows must be checked in before rerunning. |
| 62 | 8. If you fixed a conflict, report exact edits (file paths + concrete changes or preserved intent). |
| 63 | 9. Repeat until the tool prints `No actions needed` or the local-completion report and proposed PR plan. This run must not push or mutate GitHub; a branch or PR from an earlier run may already exist. |
| 64 | |
| 65 | ## When to Stop and Report Failure |
| 66 | |
| 67 | Stop iterating and report failure if any of these conditions are met: |
| 68 | |
| 69 | 1. **Command not found (exit code 127)**: The `upgrade-provider` tool is not in PATH. |
| 70 | 2. **Same error 3 times**: You've attempted to fix the same error 3 times without success. |
| 71 | 3. **Unknown error pattern**: The error is not covered in `references/upgrade-provider-errors.md` and you cannot determine a safe fix. |
| 72 | 4. **Ambiguous patch state**: You cannot prove that every patch was applied and the target rebase completed. |
| 73 | 5. **Requires human judgment**: The fix needs user input, such as choosing between multiple valid implementation approaches or making an architectural decision about module organization. Upstream breaking changes, deprecations, or framework migrations do not by themselves require stopping; stop only when implementing the upgrade presents an unresolved choice. |
| 74 | |
| 75 | When stopping, report: |
| 76 | 1. The error(s) encountered. |
| 77 | 2. What fixes were attempted (with file paths and changes). |
| 78 | 3. Why human intervention is needed. |
| 79 | 4. Any partial progress. |
| 80 | |
| 81 | ## Review the Local Upgrade |
| 82 | |
| 83 | Use the tool's final report as the source of truth for the base branch, working branch, proposed PR title/body/metadata, and skipped submission actions. |
| 84 | |
| 85 | 1. Review a bounded summary first: |
| 86 | |
| 87 | ```bash |
| 88 | default_branch=$(gh repo view --json defaultBranchRef -- |