/github-workflows:finalize-prfrom github-workflows
Automatically finalize pull requests for merge by resolving CodeQL violations, PR feedback, merge conflicts, and CI failures. Handles single PR (current branch or by number), all open PRs in the repo, or all open PRs across the org. Includes bot-authored PRs in all modes.
Ships in github-workflows. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
FULLY AUTOMATIC - Fully automates PR finalization: monitor, fix, prepare for merge. Assumes PR already exists.
No manual intervention required. For manual review-focused workflows, use /review-pr.
State warning: Automated reviewers (CodeQL, Copilot, AI reviews) post asynchronously. CI may have re-run. Merge conflicts may have appeared. Re-fetch live PR state from Step 1.
Goal: drive every targeted PR (single, all in-repo, or org) to
merge-ready without manual intervention — CI green, CodeQL clean, all PR
feedback answered, no conflicts, code simplified, metadata current — by
taking direct action on whatever blocks it, never by reporting the blocker
back.
Done when, for every targeted PR: Phase 3's live-API gate passes (re-run on
every invocation — "mergeable" means git-conflict-free only, not fully
unblocked); /resolve-pr-threads and /resolve-codeql found nothing left
to fix; /simplify ran once after all other fixes (Step 2.3.5 — pre-push
simplification is /ship's job, not this skill's); local linters and tests
pass; title/description/linked-issues were regenerated via a delegate (routing per core AGENTS.md)
before reporting ready; bot-authored PRs (dependabot, release-please,
claude, github-actions, etc.) were never filtered out; org mode never
crossed the org boundary the current repo implies; and, on a Git Flow repo,
the post-merge promotion of promote/<version> into main via
/promote-release was added
to the active session checklist as mandatory, not optional.
Steps 1.1–1.4 run sequentially.
| Argument | Mode | Target |
|---|---|---|
| (none) | Current branch | Single PR on current branch |
42 | Single PR | PR #42 |
all | Repo-wide | All open PRs in current repo |
org | Org-wide | All open PRs across all repos in current org |
all): List all open PRs (limit 50) with number, title, author, headRefName.org): Enumerate repos, list open PRs per repo (limit 50 each, 50 total cap), include repository field.Tag PRs where author.login ends with [bot] for reporting. Process identically to human PRs.
Display discovery list before proceeding. Verify working tree is clean (if dirty, ask user to commit/stash). Note current branch for restoration.
If invoked via /ship, a context brief is already in session context — skip this step.
If invoked standalone, build a lightweight brief from:
gh pr view <PR_NUMBER> --json body --jq '.body'BASE=$(gh pr view <PR_NUMBER> --json baseRefName --jq '.baseRefName') && git log --oneline origin/$BASE..HEADSynthesize purpose, key changes, and intentional patterns into a 5-10 line block.
This informs /resolve-pr-threads (Phase 2.2) when evaluating reviewer feedback.
Execution strategy: Start CI monitoring in the background (Step 2.1) and
fix all other issues in parallel while CI runs. Never block on CI when other
work is available. Pre-push simplification is handled by /ship; within this
skill, /simplify runs once at Step 2.3.5 after all fixes are applied.
For multi-PR modes, Phases 2-5 execute once per PR in sequence. Check out each PR branch at the
start of each iteration. For org-wide mode, use repository.nameWithOwner from Phase 1 as the
--repo argument when checking out.
Steps 2.1 and 2.2 start concurrently (2.1 is non-blocking). Steps 2.3 and 2.4 run sequentially after 2.2.
Launch CI monitoring in a background Task agent (run_in_background: true on the Task tool).
Monitor CI checks using --watch so the agent blocks until all complete.
Do NOT wait for the agent to finish — proceed to 2.2 immediately.
Run these checks simultaneously. Launch independent fixes in parallel via
Task agents when they touch different files. Use /agentops:orchestrate for dispatch.
Run the canonical code-scanning alert count from /gh-cli-patterns.
Replace <OWNER> and <REPO> per the placeholder convention in that skill.
If violations found: Invoke /resolve-codeql fix, validate locally.
Invoke /resolve-pr-threads to process all review feedback. It exits cleanly
when no unaddressed feedback items exist. See the PR feedback ledger.
After completion, validate locally.
If mergeStateStatus is BEHIND, follow the
Git Town rule
to sync the PR branch before continuing. For a promote/<version> → main promotion PR, use /promote-release.
Check if the PR has git conflicts (mergeable field). mergeable: MERGEABLE means no git
conflicts only — it does NOT mean the PR is fully ready to merge. If conflicts: sync the
PR branch using the Git Town rule above, resolve conflicts locally, and report any that remain.
After resolution, validate locally. Full
readiness verification (including mergeStateStatus, CI, CodeQL, review decision, threads) happens
in Phase 3.
Check background CI results from 2.1:
After all fixes from 2.2 and 2.3 are complete, invoke /simplify once on all
cumulative changes. This is the single /simplify pass within /finalize-pr —
it catches any code introduced by fix iterations (CodeQL fixes, CI fixes,
review thread implementations) that wasn't part of the original pre-push
simplification. If /simplify produces changes, validate locally, commit,
and push before proceeding to 2.4.
Verify final PR state, mergeability, and check status. If fixes introduced new issues, loop back to 2.2.
⛔ NO SHORT-CIRCUIT — EVERY INVOCATION, EVERY TIME. Run this gate against live API state now, even if this PR was verified 30 seconds ago. Subagent self-reports and prior in-session messages are historical snapshots, not current truth. The world changes: CodeQL completes async, required reviewers post async, Renovate force-pushes, branch protection re-evaluates. Re-run every query below.
Run the canonical PR-readiness gate against
<PR_NUMBER>. Replace <OWNER>, <REPO>, <PR_NUMBER> per the placeholder convention in
that skill.
Required values — if any fail, return to Phase 2:
| Field | Required | Abort message |
|---|---|---|
state | OPEN | "PR is not open" |
mergeable | MERGEABLE | "PR has git conflicts — rebase/merge in Phase 2" |
mergeStateStatus | CLEAN or HAS_HOOKS | "PR merge state is {value} — update a BEHIND branch in Phase 2; repair other blockers" |
isDraft | false | "PR is a draft — mark ready for review first" |
reviewDecision | APPROVED or null | "Review decision is {value} — changes requested or required" |
statusCheckRollup.state | SUCCESS | "CI rollup is {state} — fix failures in Phase 2" |
| PR feedback ledger | Zero unaddressed feedback items | "Unaddressed PR feedback — run /resolve-pr-threads" |
| Required status-check contexts | Every required context was reported in statusCheckRollup.contexts | "required check never reported: <context> — see github-actions-silent-failures" |
All reviewThreads.isResolved | true | "Unresolved threads — run /resolve-pr-threads" |
reviewThreads.pageInfo.hasNextPage | false | "More than 100 threads — paginate manually and re-verify" |
mergeStateStatusvalues that are NOT ready:BEHIND(follow the Git Town rule from Phase 2),BLOCKED(branch protection — could be required review, CodeQL, or required status check),DIRTY(conflicts),DRAFT,UNKNOWN(GitHub computing),UNSTABLE(checks failed or pending). Any of these = return to Phase 2.
statusCheckRollup does NOT include CodeQL alert state. Run the canonical code-scanning
alert count from /gh-cli-patterns. Replace <OWNER> and <REPO> per the
placeholder convention.
Required: Result must be 0. Any open CodeQL alerts → return to Phase 2,
invoke /resolve-codeql fix.
/simplify ran at Phase 2.3.5 on all changesOnly if all three gates (3.1, 3.2, 3.3) pass: Proceed to Phase 4.
Delegate to a delegate (routing per core AGENTS.md) to keep full diff out of main context:
regenerate title (conventional commit format, <70 chars) and description
(Summary/Changes/Test Plan sections), link related issues/PRs (Closes #X
or Related: #X, carrying forward any existing Zammad reference verbatim),
then apply both together via the heredoc body pattern from
/gh-cli-patterns. Exact per-step mechanics:
references/phase-4-metadata.md.
Proceed to Phase 5.
Single/current-branch mode: Emit the Canonical PR Status Summary (Section 1 =
this PR, Section 2 = all open PRs in current repo) as defined in /gh-cli-patterns,
titled PR Status.
Multi-PR mode: Record the per-PR result (ready / blocked). Restore the original branch and continue to the next PR. If a PR needs human intervention (unresolvable conflict, unrecoverable CI failure, etc.), log it with reason and continue — do not stop the batch for one blocked PR. Do NOT emit a ready report — that happens in Phase 6.
MUST NOT return until ALL conditions pass for EVERY targeted PR: CI green, CodeQL clean, threads resolved, no conflicts, code simplified, local linters and tests pass, metadata updated. If ANY fails, loop back to Phase 2. CRITICAL: CodeQL is SEPARATE from CI — check both independently.
Emit the Canonical PR Status Summary as defined in /gh-cli-patterns, titled
Finalization Summary. Section 1 = all PRs processed this run. Section 2 = all open
PRs in affected repos (current repo for all mode; all repos from Phase 1 discovery
for org mode). Show the target repo as a label next to each merge command (no --repo flag; user
runs from the correct worktree).
Use ONLY after a PR exists. Phases: 1 (discover) → 1.5 (context brief) →
2 (fix loop) → 3 (verify) → 4 (metadata) → 5 (report ready).
For all/org modes: Phases 2-5 loop per PR, Phase 6 aggregates results.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub jacobpevans-ai/claude-code-plugins --plugin github-workflowsOther plugins' skills for the same job
18 skills in this plugin
/gh-cli-patternsCanonical reference for all gh CLI command shapes used by skills in this plugin. Defines the placeholder convention, default-branch (trunk vs git-flow) detection, allowed --json fields, GraphQL fallback rules, -f/-F/--raw-field flag semantics, the PR-readiness gate, required status contexts, the feedback ledger, code-scanning alert query, review-thread fetch/count/resolve mutations, and heredoc bodies. Prevents Unknown JSON field errors and divergent query shapes./github-actions-silent-failuresDiagnose GitHub Actions workflows that fail silently — a reusable-workflow run with zero jobs/logs, a gh-aw import mis-resolving vs a repo named .github, self-hosted-runner traps. Use when a required check never reds or a run has no jobs./