PR Merge Safety Assessment
Before merging a PR (especially to production), assess what could go wrong. This is NOT a code review — it's a risk assessment.
Input: "$ARGUMENTS"
Workflow
1. Identify the PR
- If a PR URL or number is provided, use it
- Otherwise detect from current branch:
gh pr view --json number,url,headRefName,baseRefName,state
- If the PR is closed or merged, stop
2. Understand the Change
Gather context in parallel:
# What files changed and how much
gh pr diff <number> --name-only
gh pr view <number> --json additions,deletions,changedFiles,title,body
# Full diff
gh pr diff <number>
# What checks passed/failed
gh pr checks <number>
# Git history for changed files (is this area fragile?)
gh api "repos/<owner>/<repo>/commits?path=<file>&per_page=10" \
--jq '.[] | "\(.sha[0:7]) \(.commit.author.date[0:10]) \(.commit.message | split("\n")[0][0:80])"'
Read the changed files in full (not just the diff) to understand the surrounding context.
3. Check for Related PRs
Look for other open PRs that touch the same files or are part of the same initiative:
# Other open PRs
gh pr list --state open --json number,title,headRefName --limit 20
If related PRs exist, note them — merging order may matter, or they may conflict.
4. Assess Risk Dimensions
For each dimension, rate LOW / MEDIUM / HIGH with a one-line justification:
Blast Radius
- How many users/systems are affected?
- Is this a hot path or a rarely-hit edge case?
- Does this touch shared infrastructure (database, auth, payments, queues)?
Regression Potential
- Could this break existing behavior?
- Are there implicit dependencies that might not be obvious from the diff?
- Does the change modify a function signature, API contract, or data shape that others consume?
- Check the git history — has this area been fragile or frequently changed?
Data Safety
- Does this change database schema, migrations, or data access patterns?
- Could this cause data loss, corruption, or inconsistency?
- Are there irreversible data operations (deletes, truncates, column drops)?
Rollback Difficulty
- If this goes wrong, how hard is it to revert?
- Are there database migrations that can't be rolled back?
- Does this change state in external systems (Stripe, accounting platforms, third-party APIs)?
- Would reverting the code leave data in an inconsistent state?
Dependency Risk
- Does this add/upgrade/remove dependencies?
- Are there version conflicts or breaking changes in upgraded packages?
- Does this change environment variables or config that deploys depend on?
Concurrency & Timing
- Could this create race conditions under production load?
- Are there operations that assume sequential execution but might run concurrently?
- Does this interact with queues, workers, or scheduled jobs?
5. Check for Red Flags
Explicitly look for:
6. Post the Assessment
Post the assessment as a PR comment using gh pr comment <number> --body "...".
Use this format:
### Merge Safety Assessment
**Overall Risk: [LOW / MEDIUM / HIGH]**
[One sentence summary of the biggest concern]
#### Risk Breakdown
| Dimension | Risk | Why |
|---|---|---|
| Blast Radius | LOW | Only affects admin dashboard settings page |
| Regression | MEDIUM | Modifies shared utility used by 3 services |
| Data Safety | LOW | Read-only query changes |
| Rollback | LOW | No migrations, pure code change |
| Dependencies | LOW | No dependency changes |
| Concurrency | HIGH | New async handler doesn't lock shared resource |
#### Related PRs
- PR #465: [title] — touches same area, merge order matters
- (or "None found")
#### Red Flags
- [Any red flags found, or "None found"]
#### What Could Go Wrong
1. [Specific scenario] — [likelihood] — [impact if it happens]
2. ...
#### Recommended Before Merging
- [Specific actions: "run the sync integration tests", "verify staging handles X", etc.]
- [Or: "Safe to merge — no action needed"]
#### Safe to Merge?
[YES / YES WITH CONDITIONS / HOLD — with reasoning]
🤖 Safety assessment by Claude Code
If --no-post was passed, display the assessment in the conversation instead of posting.
Rules
- Be specific, not generic. "Something might break" is useless. "The retry logic in syncWorkflow.ts:L142 now retries 5x instead of 3x, which could cause rate limiting with the upstream API" is useful.
- If the PR is trivial (typo fix, comment update, dev tooling only), say so immediately — post a short "Low risk, trivial change" comment and skip the full assessment.
- Don't fabricate risks. If the change is genuinely safe, say so.
- Always check git history for changed files — frequent recent changes signal an area in flux.
- Always check for related open PRs — merge conflicts and ordering issues are a real risk.
1---2name: pr-safety3description: Assess the risk of merging a PR: what could go wrong, regressions, blast radius, rollback difficulty. Posts assessment as a PR comment.4---56# PR Merge Safety Assessment78Before merging a PR (especially to production), assess what could go wrong. This is NOT a code review — it's a risk assessment.910**Input:** "$ARGUMENTS"1112## Workflow1314### 1. Identify the PR1516- If a PR URL or number is provided, use it17- Otherwise detect from current branch: `gh pr view --json number,url,headRefName,baseRefName,state`18- If the PR is closed or merged, stop1920### 2. Understand the Change2122Gather context in parallel:2324```bash25# What files changed and how much26gh pr diff <number> --name-only27gh pr view <number> --json additions,deletions,changedFiles,title,body2829# Full diff30gh pr diff <number>3132# What checks passed/failed33gh pr checks <number>3435# Git history for changed files (is this area fragile?)36gh api "repos/<owner>/<repo>/commits?path=<file>&per_page=10" \37 --jq '.[] | "\(.sha[0:7]) \(.commit.author.date[0:10]) \(.commit.message | split("\n")[0][0:80])"'38```3940Read the changed files in full (not just the diff) to understand the surrounding context.4142### 3. Check for Related PRs4344Look for other open PRs that touch the same files or are part of the same initiative:4546```bash47# Other open PRs48gh pr list --state open --json number,title,headRefName --limit 2049```5051If related PRs exist, note them — merging order may matter, or they may conflict.5253### 4. Assess Risk Dimensions5455For each dimension, rate **LOW / MEDIUM / HIGH** with a one-line justification:5657**Blast Radius**58- How many users/systems are affected?59- Is this a hot path or a rarely-hit edge case?60- Does this touch shared infrastructure (database, auth, payments, queues)?6162**Regression Potential**63- Could this break existing behavior?64- Are there implicit dependencies that might not be obvious from the diff?65- Does the change modify a function signature, API contract, or data shape that others consume?66- Check the git history — has this area been fragile or frequently changed?6768**Data Safety**69- Does this change database schema, migrations, or data access patterns?70- Could this cause data loss, corruption, or inconsistency?71- Are there irreversible data operations (deletes, truncates, column drops)?7273**Rollback Difficulty**74- If this goes wrong, how hard is it to revert?75- Are there database migrations that can't be rolled back?76- Does this change state in external systems (Stripe, accounting platforms, third-party APIs)?77- Would reverting the code leave data in an inconsistent state?7879**Dependency Risk**80- Does this add/upgrade/remove dependencies?81- Are there version conflicts or breaking changes in upgraded packages?82- Does this change environment variables or config that deploys depend on?8384**Concurrency & Timing**85- Could this create race conditions under production load?86- Are there operations that assume sequential execution but might run concurrently?87- Does this interact with queues, workers, or scheduled jobs?8889### 5. Check for Red Flags9091Explicitly look for:92- [ ] Database migrations without a rollback path93- [ ] Removed or changed API endpoints that clients depend on94- [ ] Changes to auth/permissions logic95- [ ] Modified payment or billing code96- [ ] Hard-coded values that differ between environments97- [ ] Console.log or debug code left in98- [ ] Environment-specific config changes99- [ ] Changes to retry/timeout behavior100- [ ] Race conditions in async operations101102### 6. Post the Assessment103104Post the assessment as a PR comment using `gh pr comment <number> --body "..."`.105106Use this format:107108```109### Merge Safety Assessment110111**Overall Risk: [LOW / MEDIUM / HIGH]**112[One sentence summary of the biggest concern]113114#### Risk Breakdown115116| Dimension | Risk | Why |117|---|---|---|118| Blast Radius | LOW | Only affects admin dashboard settings page |119| Regression | MEDIUM | Modifies shared utility used by 3 services |120| Data Safety | LOW | Read-only query changes |121| Rollback | LOW | No migrations, pure code change |122| Dependencies | LOW | No dependency changes |123| Concurrency | HIGH | New async handler doesn't lock shared resource |124125#### Related PRs126- PR #465: [title] — touches same area, merge order matters127- (or "None found")128129#### Red Flags130- [Any red flags found, or "None found"]131132#### What Could Go Wrong1331. [Specific scenario] — [likelihood] — [impact if it happens]1342. ...135136#### Recommended Before Merging137- [Specific actions: "run the sync integration tests", "verify staging handles X", etc.]138- [Or: "Safe to merge — no action needed"]139140#### Safe to Merge?141[YES / YES WITH CONDITIONS / HOLD — with reasoning]142143🤖 Safety assessment by Claude Code144```145146**If `--no-post` was passed, display the assessment in the conversation instead of posting.**147148## Rules149150- Be specific, not generic. "Something might break" is useless. "The retry logic in syncWorkflow.ts:L142 now retries 5x instead of 3x, which could cause rate limiting with the upstream API" is useful.151- If the PR is trivial (typo fix, comment update, dev tooling only), say so immediately — post a short "Low risk, trivial change" comment and skip the full assessment.152- Don't fabricate risks. If the change is genuinely safe, say so.153- Always check git history for changed files — frequent recent changes signal an area in flux.154- Always check for related open PRs — merge conflicts and ordering issues are a real risk.