一键导入
gh-pr-handling
Expert GitHub CLI and PR handling. Use when working with pull requests, GitHub issues, reviews, CI checks, or any gh command operations.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Expert GitHub CLI and PR handling. Use when working with pull requests, GitHub issues, reviews, CI checks, or any gh command operations.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | gh-pr-handling |
| description | Expert GitHub CLI and PR handling. Use when working with pull requests, GitHub issues, reviews, CI checks, or any gh command operations. |
| allowed-tools | Bash, Read |
Expert guidance for GitHub CLI (gh) operations and pull request management.
Activate this skill when the user:
gh# Create PR with proper formatting (use HEREDOC for body)
gh pr create --title "feat: add feature X" --body "$(cat <<'EOF'
## Summary
- Brief description of changes
## Test plan
- [ ] Unit tests pass
- [ ] Manual testing completed
EOF
)"
# Create draft PR
gh pr create --draft --title "WIP: feature X"
# Create PR with labels
gh pr create --title "fix: bug" --label "bug,priority:high"
# View current PR
gh pr view
# Get PR number
gh pr view --json number -q '.number'
# Get PR state (OPEN, MERGED, CLOSED)
gh pr view --json state -q '.state'
# List open PRs
gh pr list --state open
# List PRs for specific branch pattern
gh pr list --state open --json headRefName,number \
-q '.[] | select(.headRefName | test("^feature/")) | "\(.number):\(.headRefName)"'
# View all checks
gh pr checks
# Get check conclusions
gh pr checks --json conclusion -q '.[].conclusion'
# Get failed checks with details
gh pr checks --json name,conclusion,detailsUrl \
-q '.[] | select(.conclusion == "FAILURE")'
# Wait for checks to complete
gh pr checks --watch
# Get all reviews
gh pr view --json reviews -q '.reviews'
# Get Copilot review state
gh pr view --json reviews -q '
[.reviews[] | select(.author.login | test("copilot"; "i"))]
| sort_by(.submittedAt) | .[-1].state // ""
'
# Get latest Copilot comment
gh pr view --json comments,reviews -q '
(
[.comments[] | select(.author.login | test("copilot"; "i"))] +
[.reviews[] | select(.author.login | test("copilot"; "i"))]
) | sort_by(.createdAt) | .[-1]
'
# Add comment to PR
gh pr comment --body "Comment text here"
# Request review
gh pr edit --add-reviewer username
# Squash merge and delete branch
gh pr merge --squash --delete-branch
# Merge with auto-merge when checks pass
gh pr merge --auto --squash
# Rebase merge
gh pr merge --rebase --delete-branch
When branch protection requires:
copilot[bot] APPROVED state# Check if PR is mergeable
gh pr view --json mergeable -q '.mergeable'
# Get merge state status
gh pr view --json mergeStateStatus -q '.mergeStateStatus'
if gh pr view >/dev/null 2>&1; then
echo "PR exists"
else
echo "No PR for this branch"
fi
pr_info="$(gh pr view --json number,state 2>/dev/null || echo "")"
if [ -n "$pr_info" ]; then
pr_number="$(echo "$pr_info" | jq -r '.number')"
pr_state="$(echo "$pr_info" | jq -r '.state')"
fi
for i in $(seq 1 60); do
conclusions="$(gh pr checks --json conclusion -q '.[].conclusion')"
if echo "$conclusions" | grep -iq "failure"; then
echo "CI failed"
break
fi
if ! echo "$conclusions" | grep -iq "pending"; then
echo "CI passed"
break
fi
sleep 30
done
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
comments(first: 1) {
nodes { body author { login } }
}
}
}
}
}
}
' -F owner="OWNER" -F repo="REPO" -F pr=123
gh api graphql -f query='
mutation($threadId: ID!) {
resolveReviewThread(input: {threadId: $threadId}) {
thread { isResolved }
}
}
' -F threadId="THREAD_NODE_ID"
gh api repos/{owner}/{repo}/pulls/{pr}/comments/{comment_id}/replies -f body="Fixed in latest commit"
The auto-approve.yml GitHub workflow automates PR approval with strict conditions.
Approval conditions (ALL must be met):
Flow:
Manual trigger (fallback):
gh workflow run auto-approve.yml -f pr_number=123
Check workflow status:
# List recent runs
gh run list --workflow=auto-approve.yml
# Watch current run
gh run watch
# View run details
gh run view <run-id>
Why auto-approve exists:
Critical: Fix issues before approval:
When autopilot should NOT wait:
--json for scripting - Parse structured output with jq