/ai-dev-extensions:github-complete-prfrom ai-dev-extensions
Use when a GitHub pull request has just been merged or closed - switches back to the repository default branch, syncs it, and deletes the now-obsolete feature branch both locally and on the remote if it still exists
Ships in ai-dev-extensions. 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.
Once a pull request is merged or closed, the feature branch is no longer needed. Leaving it around clutters the local repo and the remote, creates stale references, and confuses future git branch / PR listings. This skill defines the cleanup steps to run immediately after PR completion.
develop, release/*, main) — never delete theseBefore deleting anything, verify the PR state via gh:
gh pr view <number-or-branch> --json state,mergedAt,headRefName,baseRefName
Only proceed when state is MERGED or CLOSED. If the PR is still OPEN, stop and tell the user.
Do not assume main. Query it:
gh repo view --json defaultBranchRef --jq .defaultBranchRef.name
Use whatever it returns (main, master, trunk, etc.) as the checkout target.
git checkout <default-branch>
git pull --ff-only origin <default-branch>
Use --ff-only to avoid accidental merge commits if the local default branch has drifted.
git branch -d <feature-branch>
Use -d (safe delete) first. Git will refuse when the branch is not fully merged into the default branch — this is common and expected when the PR was squash-merged or rebase-merged (the tip commit of the feature branch is not an ancestor of main).
Force-delete with -D is acceptable only when one of the following is true, confirmed via gh pr view:
state is MERGED — the changes exist on the default branch under a new commit hash; the original commits are redundant.state is CLOSED and the branch was intentionally abandoned (the user confirms the work will not be reused).git branch -D <feature-branch>
Data-loss warning. For a CLOSED (unmerged) PR, -D permanently discards any commits on that branch that live nowhere else — there is no remote copy to recover from once the remote branch is also deleted in step 5. Confirm with the user before force-deleting a closed-unmerged branch.
Never use -D without first confirming PR state via gh pr view.
Many PR workflows auto-delete the remote branch on merge, but not all. Check and clean up:
git fetch --prune origin
if git ls-remote --exit-code --heads origin <feature-branch> >/dev/null 2>&1; then
git push origin --delete <feature-branch>
else
echo "Remote branch already deleted"
fi
--prune removes stale remote-tracking refs. The ls-remote check avoids a noisy error when the remote branch is already gone. The explicit if/else (instead of A && B || C) ensures a real git push --delete failure surfaces as an error rather than being swallowed by the "already deleted" message.
Finish by showing the user the state so they can verify:
git branch # local branches
git branch -r # remote-tracking branches
The feature branch must be absent from both.
The recipe below enforces Rule §1 (abort when state is OPEN) and Rule §4 (only force-delete after state validation), and derives FEATURE_BRANCH from the PR itself so a mistyped argument cannot cause the wrong branch to be deleted.
PR=<branch-or-number>
# 1. Verify PR state and capture the exact head branch from the PR
PR_STATE=$(gh pr view "$PR" --json state --jq .state)
FEATURE_BRANCH=$(gh pr view "$PR" --json headRefName --jq .headRefName)
if [ -z "$PR_STATE" ] || [ -z "$FEATURE_BRANCH" ]; then
echo "Could not determine PR state or head branch; aborting."
exit 1
fi
if [ "$PR_STATE" = "OPEN" ]; then
echo "PR is still OPEN; refusing to delete anything."
exit 1
fi
# 2. Find default branch and refuse protected branches
DEFAULT=$(gh repo view --json defaultBranchRef --jq .defaultBranchRef.name)
if [ -z "$DEFAULT" ]; then
echo "Could not determine default branch (gh auth/config issue, or not a git repo); aborting."
exit 1
fi
if [ "$FEATURE_BRANCH" = "$DEFAULT" ] \
|| [ "$FEATURE_BRANCH" = "main" ] \
|| [ "$FEATURE_BRANCH" = "master" ] \
|| [ "$FEATURE_BRANCH" = "develop" ] \
|| [[ "$FEATURE_BRANCH" == release/* ]]; then
echo "Refusing to delete protected or default branch: $FEATURE_BRANCH"
exit 1
fi
# 3. Switch + sync
git checkout "$DEFAULT"
git pull --ff-only origin "$DEFAULT"
# 4. Delete local branch — safe delete first; auto-force-delete only for MERGED PRs.
# For CLOSED (unmerged) PRs, abort and require the user to explicitly confirm data loss.
if ! git branch -d "$FEATURE_BRANCH"; then
if [ "$PR_STATE" = "MERGED" ]; then
echo "Safe delete failed (squash/rebase merge rewrote history). Force-deleting merged branch: $FEATURE_BRANCH"
git branch -D "$FEATURE_BRANCH"
else
echo "Safe delete failed because the branch is not fully merged."
echo "PR state is $PR_STATE (not MERGED). Refusing to force-delete without explicit confirmation that the work is abandoned."
echo "If you have confirmed the branch can be discarded, rerun manually:"
echo " git branch -D \"$FEATURE_BRANCH\""
exit 1
fi
fi
# 5. Prune + delete remote branch if still present
git fetch --prune origin
if git ls-remote --exit-code --heads origin "$FEATURE_BRANCH" >/dev/null 2>&1; then
git push origin --delete "$FEATURE_BRANCH"
else
echo "Remote branch already deleted"
fi
# 6. Verify
git branch
git branch -r
OPEN → do not delete anythingmain, master, develop, release/*) → never delete-D) is needed but PR merge state is unverified → verify firstWhat SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub using-system/ai-dev-extensions --plugin ai-dev-extensions8 skills in this plugin
/aks-kubectlUse when running kubectl commands against an AKS cluster - enforces az aks command invoke for private cluster access, requires --file for complex commands, and persists cluster identity in memory/docs-englishUse when writing or editing documentation, code comments, docstrings, README files, CHANGELOG entries, PR descriptions, commit messages, or any committed textual artifact - enforces English as the sole language regardless of the language used in the conversation/git-commitUse when creating git commits - enforces Conventional Commits specification for semantic versioning compatibility