|
| 1 | +--- |
| 2 | +name: review-dependency-bump |
| 3 | +description: Use when dependabot PRs need safety assessment before merging, when asked to review automated dependency updates, or when determining merge risk for version bumps |
| 4 | +argument-hint: [pr-number-or-url] |
| 5 | +--- |
| 6 | + |
| 7 | +# Evaluating Dependency Bump PRs |
| 8 | + |
| 9 | +## Overview |
| 10 | + |
| 11 | +Systematic approach to evaluating dependency bump PRs for breaking changes and merge safety. Examines semantic versioning implications, release notes, commit messages, and codebase impact before providing merge recommendations. |
| 12 | + |
| 13 | +Works in two modes: |
| 14 | +- **Single PR mode**: evaluate one specific dependency bump PR (from dependabot or human-authored) |
| 15 | +- **All dependabot PRs mode**: list and evaluate all open dependabot PRs in the repo |
| 16 | + |
| 17 | +**Integration with code review:** This methodology applies to any PR that modifies dependency files (`go.mod`, `package.json`, `Cargo.toml`, etc.), not just dependabot PRs. When reviewing a PR via `/review-pr` that includes dependency changes, invoke `/review-dependency-bump` to perform this analysis. |
| 18 | + |
| 19 | +## Determine Mode |
| 20 | + |
| 21 | +Parse `$ARGUMENTS` to decide the mode: |
| 22 | + |
| 23 | +### Single PR mode |
| 24 | + |
| 25 | +Activated when `$ARGUMENTS` is provided. |
| 26 | + |
| 27 | +- If arguments contain `REPO:` and `PR_NUMBER:` (CI mode), extract those values. Set output to **GitHub comment mode**. |
| 28 | +- If the argument is a GitHub URL (starts with `https://github.com/`), extract `owner/repo` and the PR number from it. Set output to **local mode**. |
| 29 | +- If the argument is just a number, use the current repo from `gh repo view --json nameWithOwner -q .nameWithOwner`. Set output to **local mode**. |
| 30 | + |
| 31 | +Then skip to **Gather PR Details** (step 2). |
| 32 | + |
| 33 | +### All dependabot PRs mode |
| 34 | + |
| 35 | +Activated when `$ARGUMENTS` is empty. Output is always **local mode**. |
| 36 | + |
| 37 | +Start from **List All Dependabot PRs** (step 1). |
| 38 | + |
| 39 | +## Methodology |
| 40 | + |
| 41 | +### 1. List All Dependabot PRs (all PRs mode only) |
| 42 | + |
| 43 | +```bash |
| 44 | +gh pr list --author "app/dependabot" --state open --json number,title,headRefName,url |
| 45 | +``` |
| 46 | + |
| 47 | +Create TodoWrite list tracking analysis of each PR. |
| 48 | + |
| 49 | +### 2. Gather PR Details |
| 50 | + |
| 51 | +For each PR, fetch details in parallel: |
| 52 | + |
| 53 | +```bash |
| 54 | +gh pr view <number> --repo <owner/repo> --json body,title,files,statusCheckRollup |
| 55 | +``` |
| 56 | + |
| 57 | +Extract from PR body: |
| 58 | +- Version change (old -> new) |
| 59 | +- Links to commits/release notes |
| 60 | +- Compatibility scores if present |
| 61 | + |
| 62 | +Check CI status from `statusCheckRollup`. If any required checks failed, the recommendation must not be SAFE TO MERGE regardless of other analysis. |
| 63 | + |
| 64 | +### 3. Analyze Semantic Versioning (Heuristic Only) |
| 65 | + |
| 66 | +Identify the bump type (patch, minor, major). Use this as an initial signal to prioritize review depth — not as a substitute for thorough analysis. Many projects don't follow semver strictly, and even patch bumps can introduce behavioral changes. |
| 67 | + |
| 68 | +Always perform steps 4–8 regardless of bump type. |
| 69 | + |
| 70 | +**Signals that warrant extra scrutiny:** |
| 71 | +- Major version bumps (X.0.0) - breaking changes likely |
| 72 | +- Pre-1.0 versions (0.x.y) - minor bumps may break |
| 73 | +- Multiple version jumps (1.2.0 -> 1.5.0) - review all intermediate releases |
| 74 | +- Projects with no stated semver policy |
| 75 | + |
| 76 | +### 4. Examine Release Notes |
| 77 | + |
| 78 | +From the PR body fetched in step 2, extract links to release notes or changelogs. |
| 79 | + |
| 80 | +If the PR body links to a GitHub releases page, use the WebFetch tool to fetch it and extract release notes, breaking changes, and upgrade notes. |
| 81 | + |
| 82 | +**What to look for:** |
| 83 | +- "BREAKING CHANGE" or "Breaking:" sections |
| 84 | +- "Migration guide" or "Upgrade notes" |
| 85 | +- Deprecation warnings |
| 86 | +- Security fixes |
| 87 | +- Bug fixes that change behavior |
| 88 | + |
| 89 | +### 5. Examine Commit Messages (Fallback) |
| 90 | + |
| 91 | +If release notes unavailable, check commits from PR body links: |
| 92 | + |
| 93 | +**Look for patterns:** |
| 94 | +- `fix:` - bug fixes (usually safe) |
| 95 | +- `feat:` - new features (check if additive) |
| 96 | +- `BREAKING CHANGE:` - explicit breaking changes |
| 97 | +- `refactor:`, `perf:` - behavioral changes possible |
| 98 | +- Commit titles mentioning "breaking", "incompatible", "remove" |
| 99 | + |
| 100 | +### 6. Check Codebase Impact |
| 101 | + |
| 102 | +Search the codebase for patterns that might be affected using the Grep tool: |
| 103 | + |
| 104 | +- Search for function names, types, or constants mentioned in breaking changes or deprecation notices |
| 105 | +- Search for import paths of the updated dependency |
| 106 | +- Example: if release notes mention a credential signing change, search for `Transfer-Encoding`, `S3 Accelerate`, etc. |
| 107 | +- Example: if an API was deprecated or removed, search for `<affected-function-name>`, `<deprecated-api>` |
| 108 | + |
| 109 | +When the dependency source code is available locally, inspect it directly for a more reliable assessment: |
| 110 | + |
| 111 | +- **Go with vendoring:** The vendor directory is part of the PR diff. Read the changed files under `vendor/` to see exactly what changed in the dependency code. |
| 112 | +- **Node.js:** If `node_modules` is already present, inspect the dependency source directly to see what changed. |
| 113 | +- **Other ecosystems:** Check if the dependency source is committed or cached locally. |
| 114 | + |
| 115 | +This is more reliable than release notes alone — it shows the actual code changes affecting the project. |
| 116 | + |
| 117 | +**Key question:** Does this codebase use the features that changed? |
| 118 | + |
| 119 | +### 7. Assess Security Implications |
| 120 | + |
| 121 | +Evaluate the security impact of the dependency bump: |
| 122 | + |
| 123 | +- **Known vulnerabilities:** Check if the bump fixes CVEs or security advisories. Look for "Security" or "CVE" mentions in release notes and commit messages. |
| 124 | +- **New dependencies:** Check if the bump introduces new transitive dependencies that expand the attack surface. |
| 125 | +- **Sensitive code paths:** Pay special attention to changes in authentication, authorization, cryptography, network communication, input parsing, and serialization logic. |
| 126 | +- **Supply chain signals:** Look for maintainer changes, suspicious commits, or unusual release patterns (e.g., a long-dormant package suddenly publishing updates). |
| 127 | + |
| 128 | +If the dependency handles credentials, tokens, TLS, or request signing, flag this for human review regardless of semver bump type. |
| 129 | + |
| 130 | +**Source code security scan:** When the dependency source code is available locally (Go vendor directory, or pre-populated `node_modules`), dispatch an Explore sub-agent to scan **changed files in the dependency source code** for suspicious patterns: |
| 131 | + |
| 132 | +- Obfuscated or minified code where none existed before |
| 133 | +- `eval()`, `exec()`, `child_process`, `os/exec`, `net/http` calls introduced in unexpected places |
| 134 | +- Hardcoded IP addresses, URLs, or encoded strings |
| 135 | +- File system access, network calls, or environment variable reads that don't match the library's purpose |
| 136 | +- Install hooks (`postinstall`, `preinstall`) that download or execute external resources |
| 137 | + |
| 138 | +Scope the scan strictly to changed dependency files to avoid unbounded analysis. Report any findings with file paths and line numbers. |
| 139 | + |
| 140 | +### 8. Verify PR Authorship |
| 141 | + |
| 142 | +Before deciding whether to approve, check that every commit in the PR is authored by dependabot: |
| 143 | + |
| 144 | +```bash |
| 145 | +gh pr view <number> --repo <owner/repo> --json commits --jq '.commits[].authors[].login' |
| 146 | +``` |
| 147 | + |
| 148 | +If any commit author is not `dependabot[bot]`, **NEVER approve the PR** — post a comment instead, regardless of the recommendation. **Only pure dependabot PRs may be approved**. |
| 149 | + |
| 150 | +### 9. Provide Structured Recommendations |
| 151 | + |
| 152 | +Format depends on output mode determined earlier. |
| 153 | + |
| 154 | +#### Local mode |
| 155 | + |
| 156 | +For each PR, output: |
| 157 | + |
| 158 | +```markdown |
| 159 | +### PR #X: <title> |
| 160 | +**Version change:** <old> -> <new> |
| 161 | + |
| 162 | +**Changes:** |
| 163 | +- Key change 1 |
| 164 | +- Key change 2 |
| 165 | + |
| 166 | +**Breaking changes:** None | <description> |
| 167 | + |
| 168 | +**Security concerns:** None | <description> |
| 169 | + |
| 170 | +**Impact on codebase:** <verified usage patterns> |
| 171 | + |
| 172 | +**Recommendation:** SAFE TO MERGE | REVIEW REQUIRED | BREAKING CHANGES |
| 173 | + |
| 174 | +**Notes:** <specific risks or considerations> |
| 175 | +``` |
| 176 | + |
| 177 | +#### GitHub comment mode (CI) |
| 178 | + |
| 179 | +**The command must stay on a single bash line.** Use `$'...'` quoting with `\n` for line breaks. Escape single quotes as `\'`. |
| 180 | + |
| 181 | +**Duplicate prevention:** Before posting, check for an existing evaluation comment by searching for the `— Claude Code` marker: |
| 182 | + |
| 183 | +```bash |
| 184 | +gh pr view <number> --repo <owner/repo> --json comments --jq '.comments[] | select(.body | contains("— Claude Code")) | .url' |
| 185 | +``` |
| 186 | + |
| 187 | +If a previous evaluation exists, edit it instead of creating a new comment. If the recommendation changed from a previous comment to SAFE TO MERGE, delete the old comment and approve instead. |
| 188 | + |
| 189 | +Choose one of the following based on the recommendation: |
| 190 | + |
| 191 | +##### SAFE TO MERGE: approve the PR with the evaluation as the review body |
| 192 | + |
| 193 | +Only if the authorship check (step 8) confirmed all commits are by dependabot. Otherwise, post a comment instead. |
| 194 | + |
| 195 | +Do NOT post a separate comment. The approval review body carries the evaluation. |
| 196 | + |
| 197 | +```bash |
| 198 | +gh pr review <number> --repo <owner/repo> --approve --body $'## Dependency Bump Evaluation\n\n**Version change:** <old> -> <new> (patch|minor)\n**Breaking changes:** None\n**Security concerns:** None\n**Impact on codebase:** No affected patterns found\n**Recommendation:** SAFE TO MERGE\n\n— Claude Code' |
| 199 | +``` |
| 200 | + |
| 201 | +##### REVIEW REQUIRED or BREAKING CHANGES: post a comment (do NOT approve) |
| 202 | + |
| 203 | +```bash |
| 204 | +gh pr comment <number> --repo <owner/repo> --body $'## Dependency Bump Evaluation\n\n**Version change:** <old> -> <new>\n**Semver bump type:** patch | minor | major\n\n**Changes:**\n- Key change 1\n- Key change 2\n\n**Breaking changes:** None | <description>\n\n**Security concerns:** None | <description>\n\n**Impact on codebase:** <verified usage patterns>\n\n**Recommendation:** REVIEW REQUIRED | BREAKING CHANGES\n\n**Notes:** <specific risks or considerations>\n\n— Claude Code' |
| 205 | +``` |
| 206 | + |
| 207 | +### 10. Suggest Merge Order (all PRs mode only) |
| 208 | + |
| 209 | +For multiple PRs with dependencies: |
| 210 | + |
| 211 | +1. Lowest-level dependencies first (config, utils, core libs) |
| 212 | +2. Mid-level dependencies (auth, API clients) |
| 213 | +3. Highest-level dependencies (service-specific SDKs) |
| 214 | + |
| 215 | +**Example:** |
| 216 | +``` |
| 217 | +1. PR #64 (config) - lowest level |
| 218 | +2. PR #65 (credentials) - depends on config |
| 219 | +3. PR #66 (S3 service) - depends on both |
| 220 | +``` |
| 221 | + |
| 222 | +## Monorepo / Scoped Package Dependencies |
| 223 | + |
| 224 | +When multiple dependabot PRs update packages from the same ecosystem (e.g., `@aws-sdk/*`, `@babel/*`, `@types/*`): |
| 225 | + |
| 226 | +1. **Identify related PRs** - group PRs by package scope/org |
| 227 | +2. **Check for shared changelog** - monorepo packages often share a single changelog or release notes page |
| 228 | +3. **Evaluate together** - breaking changes in a core package may affect all scoped packages |
| 229 | +4. **Merge as a batch** - related scoped packages should typically be merged together to avoid version mismatches |
| 230 | + |
| 231 | +## Risk Assessment Matrix |
| 232 | + |
| 233 | +| Scenario | Risk | Action | |
| 234 | +|----------|------|--------| |
| 235 | +| Patch bump + bug fixes only | Low | Review release notes, merge after CI passes | |
| 236 | +| Minor bump + additive features | Low-Medium | Review release notes, verify no deprecated API usage | |
| 237 | +| Major bump | High | Review breaking changes, update code | |
| 238 | +| Security fix in any version | Critical | Merge promptly after verification | |
| 239 | +| Multiple version jumps | Medium | Review all intermediate releases | |
| 240 | +| Codebase uses affected features | High | Test thoroughly, may need changes | |
| 241 | +| Codebase doesn't use affected features | Low | Safe to merge | |
| 242 | +| CI checks failing | High | Do not merge until CI is green | |
| 243 | + |
| 244 | +## Common Mistakes |
| 245 | + |
| 246 | +| Mistake | Fix | |
| 247 | +|---------|-----| |
| 248 | +| Trusting semver at face value | Semver is a heuristic; always examine release notes or commits | |
| 249 | +| Assuming patches are always safe | Patches can change behavior when fixing bugs | |
| 250 | +| Not verifying codebase impact | Search for affected functions/patterns | |
| 251 | +| Recommending "just test it" without analysis | Provide informed assessment first | |
| 252 | +| Ignoring security fixes | Prioritize security updates | |
| 253 | +| Missing dependency order | Consider merge order for related deps | |
| 254 | +| Skipping commit messages | When release notes unavailable, commits are critical | |
| 255 | +| Not reading breaking change sections | Look for "BREAKING", "Migration", "Upgrade" keywords | |
| 256 | + |
| 257 | +## Example Workflows |
| 258 | + |
| 259 | +### Single PR (local) |
| 260 | + |
| 261 | +``` |
| 262 | +User: "/review-dependency-bump 42" |
| 263 | +
|
| 264 | +1. Fetch PR #42 details |
| 265 | +2. Identify version bump type |
| 266 | +3. Fetch release notes or commits |
| 267 | +4. Search codebase for affected patterns |
| 268 | +5. Output structured recommendation as text |
| 269 | +``` |
| 270 | + |
| 271 | +### Single PR (CI) |
| 272 | + |
| 273 | +``` |
| 274 | +Arguments: "REPO: owner/repo PR_NUMBER: 42" |
| 275 | +
|
| 276 | +1. Fetch PR #42 details from owner/repo |
| 277 | +2. Identify version bump type |
| 278 | +3. Fetch release notes or commits |
| 279 | +4. Search codebase for affected patterns |
| 280 | +5. Post structured recommendation as GitHub comment |
| 281 | +``` |
| 282 | + |
| 283 | +### All dependabot PRs |
| 284 | + |
| 285 | +``` |
| 286 | +User: "/review-dependency-bump" |
| 287 | +
|
| 288 | +1. Use TodoWrite to create analysis checklist |
| 289 | +2. List all open dependabot PRs |
| 290 | +3. For each PR (in parallel): |
| 291 | + - Fetch PR details |
| 292 | + - Identify version bump type |
| 293 | + - Fetch release notes or commits |
| 294 | + - Search codebase for affected patterns |
| 295 | +4. Provide structured recommendations with risk levels |
| 296 | +5. Suggest merge order if applicable |
| 297 | +``` |
0 commit comments