pr-health-check
Scannednpx machina-cli add skill JacobPEvans/ai-assistant-instructions/pr-health-check --openclawPR Health Check
<!-- markdownlint-disable-file MD013 -->Standardized patterns for validating PR health, merge-readiness, and determining if a PR can proceed through its workflow.
Purpose
Provides a single source of truth for PR status validation. All commands that need to verify PR readiness should use these patterns instead of duplicating health check logic.
Merge-Readiness Criteria
A PR is ready to merge when ALL of the following are true:
- State:
OPEN(not draft, closed, or merged) - Mergeable:
MERGEABLE(no conflicts) - Status Checks: ALL must be
SUCCESS(no failures, no pending) - Reviews: All required reviews must be
APPROVED - Conversations: ALL review threads must be
isResolved: true(use the pr-thread-resolution-enforcement skill)
Quick Health Check Query
Get comprehensive PR status:
gh pr view <PR_NUMBER> --json state,mergeable,statusCheckRollup,reviews,reviewDecision
Interpretation:
| Field | Values | Meaning |
|---|---|---|
state | OPEN, CLOSED, MERGED | Current state; must be OPEN |
mergeable | MERGEABLE, CONFLICTING, UNKNOWN | Merge conflict status; must be MERGEABLE |
statusCheckRollup | Array with status and conclusion | CI status; all must be SUCCESS |
reviewDecision | APPROVED, CHANGES_REQUESTED, REVIEW_REQUIRED, null | Review status |
Detailed Health Check Pattern
For comprehensive validation before merge attempts:
# Get full PR details
gh pr view <PR_NUMBER> --json state,mergeable,statusCheckRollup,reviews,reviewDecision,comments
# Verify each criterion:
# 1. State check: output should show "state": "OPEN"
# 2. Mergeable: output should show "mergeable": "MERGEABLE"
# 3. Status rollup: all items should have "conclusion": "SUCCESS"
# 4. Reviews: should show "reviewDecision": "APPROVED"
# 5. Conversations: use PR Thread Resolution Enforcement Skill verification query
Status Check Rollup Understanding
The statusCheckRollup field contains an array of check results:
{
"state": "SUCCESS|FAILURE|PENDING",
"contexts": [
{"context": "Check Name", "state": "SUCCESS|FAILURE|PENDING"}
]
}
Interpretation:
state: SUCCESS- All checks passedstate: FAILURE- One or more checks failedstate: PENDING- One or more checks still running
Actions:
- SUCCESS: Proceed if other criteria met
- FAILURE: Must fix before merge (see
/finalize-prcommand) - PENDING: Must wait for checks to complete (use
gh pr checks <PR_NUMBER> --watch)
PR Filtering Logic
Identify Healthy PRs
Use this logic to filter PRs that are merge-ready:
# List all open PRs
gh pr list --state open --json number,title,state,mergeable,statusCheckRollup,reviewDecision
# Filter for healthy PRs:
# - state == OPEN
# - mergeable == MERGEABLE
# - statusCheckRollup.state == SUCCESS
# - reviewDecision == APPROVED (for repos requiring reviews)
Identify PRs Needing Attention
Use this logic to find PRs with issues:
# List all PRs with issues
gh pr list --state open --json number,title,state,mergeable,statusCheckRollup
# Filter for unhealthy PRs:
# - state != OPEN (unusual, but check)
# - mergeable == CONFLICTING or UNKNOWN
# - statusCheckRollup.state != SUCCESS
# - Reviews not approved
Common Health Check Scenarios
Scenario 1: PR Ready to Merge
state: OPEN ✓mergeable: MERGEABLE ✓statusCheckRollup.state: SUCCESS ✓reviewDecision: APPROVED ✓- Action: Proceed with merge
Scenario 2: PR Has Merge Conflict
mergeable: CONFLICTING ✗- Action: Run
/sync-mainor manually resolve conflict
Scenario 3: CI Checks Failing
statusCheckRollup.state: FAILURE ✗- Action: Run
/finalize-prto diagnose and fix
Scenario 4: Checks Still Running
statusCheckRollup.state: PENDING ⏳- Action: Wait using
gh pr checks <PR_NUMBER> --watch
Scenario 5: Missing Approvals
reviewDecision: CHANGES_REQUESTED or REVIEW_REQUIRED ✗- Action: Address feedback using
/resolve-pr-threads
Commands Using This Skill
/finalize-pr- Phase 2.1 (PR Health Check) and CI diagnosis for a single PR/finalize-prs- To filter which PRs need fixing and verify PRs are healthy before merge- Any workflow needing PR status validation
Related Resources
- github-graphql skill - Detailed GraphQL queries for PR fields
- pr-thread-resolution-enforcement skill - Review conversation validation
Integration Points
With /finalize-pr
In /finalize-pr Phase 2.1, use this skill to determine next action:
# Get health status
gh pr view <PR_NUMBER> --json state,mergeable,statusCheckRollup,reviews,reviewDecision
# Determine action:
if mergeable != MERGEABLE: → /sync-main (conflict resolution)
if statusCheckRollup != SUCCESS: → /finalize-pr (CI fixes)
if reviewDecision != APPROVED: → /resolve-pr-threads (review feedback)
if all healthy: → Proceed to Phase 3
With /finalize-prs
Use PR health check to prioritize which PRs to fix:
# Get all PRs with failing checks
gh pr list --state open --json number,statusCheckRollup
# Filter where statusCheckRollup.state == FAILURE
# These PRs are candidates for /finalize-pr
Troubleshooting
Issue: statusCheckRollup returns null
Cause: PR checks haven't started yet
Solution: Wait a few seconds and retry, or use gh pr checks <PR_NUMBER>
Issue: mergeable returns UNKNOWN
Cause: GitHub is still calculating merge status
Solution: Wait 10-30 seconds and retry
Issue: Check shows SUCCESS but merge fails
Cause: Different checks ran since last query (rare race condition)
Solution: Re-run health check immediately before merge
Best Practices
- Always check before merge - Use full health check even if PR "looks ready"
- Interpret reviewDecision carefully - May differ from individual review states
- Monitor pending checks - Use
--watchflag to block until complete - Fix conflicts early - CONFLICTING status blocks everything else
- Respect required reviews - Some repos require explicit approvals
- Use skill queries verbatim - Exact same query each time ensures consistency
Source
git clone https://github.com/JacobPEvans/ai-assistant-instructions/blob/main/agentsmd/skills/pr-health-check/SKILL.mdView on GitHub Overview
PR Health Check provides standardized patterns to validate PR readiness for merging. It defines explicit criteria for merge-readiness and helps teams determine when a PR can proceed through its workflow, ensuring consistency across repos.
How This Skill Works
It retrieves PR details using gh pr view and inspects key fields: state, mergeable, statusCheckRollup, reviews, and reviewDecision. It then evaluates these against the merge-readiness criteria and guides actions based on the results.
When to Use It
- Before merging a PR in a collaborative repo to ensure all conditions are satisfied.
- When a PR has conflicts or non mergeable status that blocks merging.
- When CI checks are failing or still pending and not all status checks are successful.
- When there are unresolved review threads or pending conversations that affect merge decisions.
- When prioritizing healthy PRs by filtering open PRs that meet the criteria.
Quick Start
- Step 1: Run gh pr view <PR_NUMBER> --json state,mergeable,statusCheckRollup,reviews,reviewDecision
- Step 2: Verify that state is OPEN, mergeable is MERGEABLE, statusCheckRollup shows all successes, and reviews are APPROVED
- Step 3: Act based on results: merge the PR if healthy; fix conflicts or failing checks; or request changes for issues
Best Practices
- Always verify OPEN state and MERGEABLE before assessing readiness.
- Ensure every statusCheckRollup item reports SUCCESS and no pending checks.
- Confirm that required reviews are APPROVED if the repo requires them.
- Coordinate with the pr-thread-resolution-enforcement workflow to resolve conversations.
- Use the standardized PR health patterns rather than ad hoc checks to maintain consistency.
Example Use Cases
- PR #482 is ready to merge after all checks pass and approvals are in place.
- PR with CONFLICTING mergeable status requires conflict resolution before merging.
- PR has a failing CI check in statusCheckRollup; needs investigation and fix.
- PR has pending reviews; additional approvals are required to pass the health check.
- Healthy PRs are identified and prioritized by listing open PRs that meet all criteria.