/empire-git:pr-merge [--pr <number>] [--squash|--merge|--rebase] [--admin]from empire-git
Gates and merges a single pull request safely: verifies CI is green, rebases and resolves conflicts, triages unresolved review threads, then merges and deletes the branch.
Ships in empire-git. 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.
None: SKILL.md is the whole skill.
Merge one PR only after it is genuinely ready: CI green, no conflicts, review threads handled. Then merge and delete the head branch.
User input: $ARGUMENTS
CRITICAL: Never merge red CI, never bypass a failing gate with --admin unless the user explicitly asks, and never force-merge over unresolved actionable review feedback.
gh pr view --json number).Capture context once:
gh pr view <pr> --json number,title,state,baseRefName,headRefName,mergeable,mergeStateStatus,reviewDecision,url
gh pr checks <pr>
gh pr checks <pr> --watch (or wait and re-check). Don't merge until resolved.ci-investigation skill if available), fix the cause, commit, push, and re-check. Re-run this step until green.Read mergeable and mergeStateStatus from Step 1.
MERGEABLE / clean → continue.CONFLICTING, or behind the base enough to need an update → rebase onto the base:git fetch origin
git rebase origin/<baseRefName>
# resolve conflicts, then:
git push --force-with-lease
Resolve conflicts by understanding both sides, never by blindly taking one. If a worktree isn't already isolating this branch, prefer doing the rebase in one (/empire-git:worktree-open). Re-check CI after pushing.
Fetch unresolved threads:
gh api graphql -f query='
query($owner:String!,$repo:String!,$pr:Int!){
repository(owner:$owner,name:$repo){
pullRequest(number:$pr){
reviewThreads(first:100){ nodes{
id isResolved isOutdated path line
comments(first:20){ nodes{ author{login} body } }
} }
}
}
}' -F owner=<owner> -F repo=<repo> -F pr=<pr> \
--jq '.data.repository.pullRequest.reviewThreads.nodes[] | select(.isResolved==false)'
Triage each unresolved thread — be smart, not mechanical:
| Thread | Action |
|---|---|
| Nit, already addressed, or acknowledged | Resolve it (mutation below). |
| Real, in-scope issue | Fix the code, push, then resolve the thread. |
| Ambiguous, contentious, design-level, or out of scope | Ask the user. Do not decide unilaterally. |
Resolve a thread once handled:
gh api graphql -f query='mutation($id:ID!){ resolveReviewThread(input:{threadId:$id}){ thread{ isResolved } } }' -F id=<threadId>
Block the merge only on threads that are real and unhandled. Outdated threads on code that no longer exists are safe to resolve.
Detect the allowed merge methods:
gh repo view --json squashMergeAllowed,mergeCommitAllowed,rebaseMergeAllowed
--squash / --merge / --rebase from the user.Merge and delete the now-orphaned head branch:
gh pr merge <pr> --squash --delete-branch
If branch protection blocks the merge (missing required approvals, etc.), report exactly what's missing. Use --admin only if the user explicitly authorized bypassing.
The merge landed on the remote base branch. If that branch is checked out locally (the main working tree or a worktree), fast-forward it so local work sees the merge — e.g. update master after merging into it.
Find a local checkout of the base branch:
git worktree list --porcelain \
| awk -v b="<baseRefName>" '/^worktree /{p=substr($0,10)} /^branch /{if ($2=="refs/heads/"b) print p}'
If a path is found, fast-forward only — never clobber local commits or a dirty tree:
git -C <path> fetch origin <baseRefName>
git -C <path> merge --ff-only origin/<baseRefName>
If the checkout is dirty or can't fast-forward, skip it and warn — leave the working tree untouched. If the base branch is checked out nowhere locally, do nothing.
State the outcome: PR merged (method), branch deleted, local base fast-forwarded (if it was checked out). Note anything deferred to the user.
A merge is the one irreversible step in the PR lifecycle. Gating on CI, conflicts, and live feedback prevents landing broken or contested work. Fast-forwarding the local base checkout keeps local work in sync with what just landed.
What SKILL.md sets; muted values are Claude Code's defaults
sonnetThree short reads, in order
pr-merge, pull-request, ci-gate, git-workflow, github-cli, merge-automation
Other plugins' skills for the same job
12 skills in this plugin
/activity-reportGenerate a concise activity report of the user's GitHub work over a period, grouped by area or feature instead of PR by PR. Use when user says "activity report", "weekly report", "what did I do this week", "what did I ship", "work summary", "summarize my week", "status update for my manager", "what did <user> ship", or `/empire-git:activity-report [start-date] [end-date] [author]`.
/pr-comment-replyRender the canonical reply text for a PR review comment. Use when drafting, writing, or posting a "PR comment reply", "review comment reply", "reply to this comment", "respond to this review comment", "answer the reviewer", "reply on the PR thread", or any text bound for `gh api` review-thread replies, `gh pr comment`, or a GitHub review comment box. Triggers on "reply to the comment", "answer this review comment", "respond to the reviewer", "draft a reply", "post a reply on the PR". Outputs plain text for the caller to post unchanged.
/pr-descriptionRender the canonical PR description body. Use when drafting, writing, updating, or regenerating a "PR description", "PR body", "pull request description", "pull request body", "PR summary", "PR template", "GitHub PR body", or any text bound for `gh pr create --body`, `gh pr create --body-file`, `gh pr edit --body`, `gh pr edit --body-file`, or a GitHub PR template. Triggers on "draft a PR", "write the PR", "summarize this branch for review", "regenerate PR body". MUST be invoked before any `gh pr create --body*` or `gh pr edit --body*` per empire-git rules. Outputs markdown for stdin.
npx claudepluginhub marcoskichel/empire --plugin empire-git