Finalize and merge a pull request after work is complete and approved.
Finalizes and merges approved pull requests after validating CI status and cleaning up branches.
/plugin marketplace add brkastner/kas-claude-plugin/plugin install kas@kas-claude-pluginFinalize and merge a pull request after work is complete and approved.
$ARGUMENTS - Optional: PR number or PR URL# If argument provided, resolve it
# Otherwise check current branch for open PR
gh pr view $ARGUMENTS --json number,headRefName,title,state,mergeable,url
If no PR found or ambiguous, ask user which PR to merge.
Check the PR JSON response:
state must be OPENheadRefName must not be mainmergeable must be MERGEABLEIf conflicts exist (mergeable = CONFLICTING), abort:
Cannot merge: PR has conflicts. Please resolve conflicts first.
gh pr checks <PR#> --json name,status,conclusion
| Status | Action |
|---|---|
| All COMPLETED + SUCCESS | Proceed to step 4 |
| Any COMPLETED + FAILURE | Attempt auto-fix (check logs, re-run). If can't fix, ask user. |
| Any IN_PROGRESS | Wait with progress indication (max 5 min, check every 30s) |
If CI doesn't pass after waiting/fixing, ask user for guidance.
gh pr merge <PR#> --merge --delete-branch
# Check if in worktree
WORKTREE_PATH=$(pwd)
if [[ "$WORKTREE_PATH" == *"/.worktrees/"* ]]; then
MAIN_REPO=$(git rev-parse --path-format=absolute --git-common-dir | sed 's/\.git$//')
cd "$MAIN_REPO"
git worktree remove "$WORKTREE_PATH" --force
fi
gh pr view <PR#> --json state,mergedAt
Provide summary:
--merge flag (preserve branch history)--delete-branch)util/beads-sync branch (not feature branches), so no squashing needed| Error | Action |
|---|---|
| No PR found | Ask user to specify PR |
| Merge conflicts | Abort, tell user to resolve conflicts first |
| CI failing | Attempt auto-fix, then ask user |
| CI timeout (>5 min) | Ask user whether to wait more or proceed |
| Worktree removal fails | Log warning, continue |