pr-status

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

PR Status Skill

PR状态检查Skill

Operator Context

操作上下文

This skill operates as an operator for PR status checks, configuring Claude's behavior for fast, accurate branch and PR state reporting. It implements a Sequential Gather pattern -- collect git state, PR metadata, CI status, reviews, and merge readiness in ordered steps, then present a unified status report.
该Skill作为PR状态检查的操作器,配置Claude的行为以实现快速、准确的分支和PR状态报告。它采用Sequential Gather模式——按顺序收集git状态、PR元数据、CI状态、评审和合并就绪情况,然后呈现统一的状态报告。

Hardcoded Behaviors (Always Apply)

硬编码行为(始终生效)

  • Read-Only: Never modify files, branches, or PR state during status checks
  • Fetch Before Report: Always
    git fetch
    before comparing local/remote state
  • gh CLI Required: Verify
    gh
    is installed and authenticated before PR queries
  • Complete Report: Show all available sections; never skip sections silently
  • Current Branch Context: Always report which branch is being checked
  • 只读模式:状态检查过程中绝不修改文件、分支或PR状态
  • 先拉取再报告:在对比本地/远程状态前,始终执行
    git fetch
  • 依赖gh CLI:在查询PR前,先验证
    gh
    是否已安装并完成认证
  • 完整报告:展示所有可用模块,绝不静默跳过任何部分
  • 当前分支上下文:始终报告正在检查的分支名称

Default Behaviors (ON unless disabled)

默认行为(默认开启,可关闭)

  • CI Detail: Show individual check names with pass/fail status
  • Review Summary: Show reviewer names with their review state
  • Merge Readiness: Report conflicts, required approvals, and blocking checks
  • Behind-Main Count: Show how many commits behind the base branch
  • Claude Review Detection: Check for Claude Code review comments on the PR
  • CI详情:展示单个检查项的名称及通过/失败状态
  • 评审摘要:展示评审人姓名及其评审状态
  • 合并就绪状态:报告冲突情况、所需批准数以及阻塞性检查项
  • 落后主分支计数:显示当前分支落后于基准分支的提交次数
  • Claude评审检测:检查PR上的Claude Code评审评论

Optional Behaviors (OFF unless enabled)

可选行为(默认关闭,可开启)

  • Recent PRs on Main: When on main branch, list recent PRs
  • Verbose CI Output: Show full CI log URLs for failed checks
  • Cross-Repository Status: Check PRs across multiple remotes
  • 主分支近期PR:当处于主分支时,列出近期的PR
  • 详细CI输出:为失败的检查项显示完整的CI日志URL
  • 跨仓库状态检查:检查多个远程仓库的PR

What This Skill CAN Do

该Skill可实现的功能

  • Report current branch name and its relationship to base branch
  • Show local working tree state (clean, modified files, ahead/behind)
  • Display PR metadata (number, title, state, URL)
  • List CI check results with pass/fail per check
  • Summarize review states per reviewer
  • Report merge readiness (conflicts, approvals needed)
  • Detect Claude Code review activity
  • 报告当前分支名称及其与基准分支的关系
  • 展示本地工作区状态(干净、已修改文件、领先/落后远程)
  • 显示PR元数据(编号、标题、状态、URL)
  • 列出每个CI检查项的通过/失败结果
  • 汇总每位评审人的评审状态
  • 报告合并就绪情况(冲突、所需批准数)
  • 检测Claude Code评审活动

What This Skill CANNOT Do

该Skill不可实现的功能

  • Create or update pull requests (use pr-sync instead)
  • Fix review comments or CI failures (use pr-fix instead)
  • Push commits or modify git state
  • Perform code review (use /pr-review instead)

  • 创建或更新拉取请求(请使用pr-sync)
  • 修复评审评论或CI失败问题(请使用pr-fix)
  • 推送提交或修改git状态
  • 执行代码评审(请使用/pr-review)

Instructions

操作步骤

Step 0: Check Prerequisites

步骤0:检查前置条件

Verify
gh
CLI is available and authenticated. If not, report the missing prerequisite and stop.
bash
command -v gh &> /dev/null || { echo "GitHub CLI (gh) not installed. Install: https://cli.github.com/"; exit 1; }
gh auth status &> /dev/null || { echo "GitHub CLI not authenticated. Run: gh auth login"; exit 1; }
验证
gh
CLI是否可用并已完成认证。如果未满足,报告缺失的前置条件并终止操作。
bash
command -v gh &> /dev/null || { echo "GitHub CLI (gh) not installed. Install: https://cli.github.com/"; exit 1; }
gh auth status &> /dev/null || { echo "GitHub CLI not authenticated. Run: gh auth login"; exit 1; }

Step 1: Get Branch Info

步骤1:获取分支信息

bash
CURRENT_BRANCH=$(git branch --show-current)
MAIN_BRANCH=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@' || echo "master")
If on the main branch, report that and optionally list recent PRs. No further steps needed.
bash
CURRENT_BRANCH=$(git branch --show-current)
MAIN_BRANCH=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@' || echo "master")
如果当前处于主分支,报告该情况,若开启可选行为则列出近期PR。无需执行后续步骤。

Step 2: Check Local State

步骤2:检查本地状态

bash
undefined
bash
undefined

Working tree status

工作区状态

DIRTY=$(git status --porcelain) if [[ -z "$DIRTY" ]]; then echo "Clean working tree" else FILE_COUNT=$(echo "$DIRTY" | wc -l) echo "$FILE_COUNT files modified" fi
DIRTY=$(git status --porcelain) if [[ -z "$DIRTY" ]]; then echo "Clean working tree" else FILE_COUNT=$(echo "$DIRTY" | wc -l) echo "$FILE_COUNT files modified" fi

Fetch and compare

拉取并对比

git fetch origin --quiet AHEAD=$(git rev-list origin/$CURRENT_BRANCH..$CURRENT_BRANCH --count 2>/dev/null || echo "0") BEHIND=$(git rev-list $CURRENT_BRANCH..origin/$CURRENT_BRANCH --count 2>/dev/null || echo "0") BEHIND_MAIN=$(git rev-list $CURRENT_BRANCH..origin/$MAIN_BRANCH --count 2>/dev/null || echo "0")
undefined
git fetch origin --quiet AHEAD=$(git rev-list origin/$CURRENT_BRANCH..$CURRENT_BRANCH --count 2>/dev/null || echo "0") BEHIND=$(git rev-list $CURRENT_BRANCH..origin/$CURRENT_BRANCH --count 2>/dev/null || echo "0") BEHIND_MAIN=$(git rev-list $CURRENT_BRANCH..origin/$MAIN_BRANCH --count 2>/dev/null || echo "0")
undefined

Step 3: Check PR Status

步骤3:检查PR状态

bash
PR_JSON=$(gh pr view --json number,title,state,url,reviewDecision,statusCheckRollup,mergeable,reviews 2>/dev/null)

if [[ -z "$PR_JSON" ]]; then
    echo "No PR exists for this branch"
else
    PR_NUMBER=$(echo "$PR_JSON" | jq -r '.number')
    PR_TITLE=$(echo "$PR_JSON" | jq -r '.title')
    PR_STATE=$(echo "$PR_JSON" | jq -r '.state')
    PR_URL=$(echo "$PR_JSON" | jq -r '.url')
fi
If no PR exists, report the branch state and suggest creating one. Skip Steps 4-7.
bash
PR_JSON=$(gh pr view --json number,title,state,url,reviewDecision,statusCheckRollup,mergeable,reviews 2>/dev/null)

if [[ -z "$PR_JSON" ]]; then
    echo "No PR exists for this branch"
else
    PR_NUMBER=$(echo "$PR_JSON" | jq -r '.number')
    PR_TITLE=$(echo "$PR_JSON" | jq -r '.title')
    PR_STATE=$(echo "$PR_JSON" | jq -r '.state')
    PR_URL=$(echo "$PR_JSON" | jq -r '.url')
fi
如果该分支没有对应的PR,报告分支状态并建议创建PR。跳过步骤4-7。

Step 4: Check CI Status

步骤4:检查CI状态

bash
gh pr checks --json name,state,conclusion 2>/dev/null | jq -r '.[] | "\(.conclusion // .state) \(.name)"'
bash
gh pr checks --json name,state,conclusion 2>/dev/null | jq -r '.[] | "\(.conclusion // .state) \(.name)"'

Step 5: Check Claude Review

步骤5:检查Claude评审

bash
CLAUDE_COMMENTS=$(gh pr view --json comments --jq '[.comments[] | select(
  (.author.login == "claude") or
  ((.author.login == "github-actions[bot]") and (.body | test("PR Review:|Claude|claude-code-action"; "i")))
)] | length')

if [[ "$CLAUDE_COMMENTS" -gt 0 ]]; then
    echo "Claude review completed ($CLAUDE_COMMENTS comments)"
else
    CLAUDE_WORKFLOW=$(gh run list --workflow=claude.yml --limit 1 --json conclusion,status --jq '.[0]' 2>/dev/null)
    if [[ -n "$CLAUDE_WORKFLOW" ]]; then
        STATUS=$(echo "$CLAUDE_WORKFLOW" | jq -r '.status // .conclusion')
        echo "Claude review status: $STATUS"
    else
        echo "No Claude review configured"
    fi
fi
bash
CLAUDE_COMMENTS=$(gh pr view --json comments --jq '[.comments[] | select(
  (.author.login == "claude") or
  ((.author.login == "github-actions[bot]") and (.body | test("PR Review:|Claude|claude-code-action"; "i")))
)] | length')

if [[ "$CLAUDE_COMMENTS" -gt 0 ]]; then
    echo "Claude review completed ($CLAUDE_COMMENTS comments)"
else
    CLAUDE_WORKFLOW=$(gh run list --workflow=claude.yml --limit 1 --json conclusion,status --jq '.[0]' 2>/dev/null)
    if [[ -n "$CLAUDE_WORKFLOW" ]]; then
        STATUS=$(echo "$CLAUDE_WORKFLOW" | jq -r '.status // .conclusion')
        echo "Claude review status: $STATUS"
    else
        echo "No Claude review configured"
    fi
fi

Step 6: Check Reviews

步骤6:检查评审情况

bash
gh pr view --json reviews --jq '.reviews[] | "\(.author.login): \(.state)"'
gh pr view --json reviewDecision --jq '.reviewDecision'
bash
gh pr view --json reviews --jq '.reviews[] | "\(.author.login): \(.state)"'
gh pr view --json reviewDecision --jq '.reviewDecision'

Step 7: Check Merge Status

步骤7:检查合并状态

bash
gh pr view --json mergeable --jq '.mergeable'
bash
gh pr view --json mergeable --jq '.mergeable'

Step 8: Present Status Report

步骤8:呈现状态报告

Format the collected information into a structured report:
PR STATUS
=========

Branch: [current] -> [base] ([N commits behind])

Local State:
  [clean/modified] working tree
  [ahead/behind] remote

PR #[N]: "[title]"
  State: [Open/Closed/Merged]
  URL: [url]

  CI Status:
    [pass/fail] [check-name] (per check)

  Claude Review:
    [status]

  Reviews:
    [reviewer]: [state] (per reviewer)

  Merge Status:
    [mergeable/conflicts/approvals needed]

将收集到的信息整理为结构化报告:
PR STATUS
=========

Branch: [current] -> [base] ([N commits behind])

Local State:
  [clean/modified] working tree
  [ahead/behind] remote

PR #[N]: "[title]"
  State: [Open/Closed/Merged]
  URL: [url]

  CI Status:
    [pass/fail] [check-name] (per check)

  Claude Review:
    [status]

  Reviews:
    [reviewer]: [state] (per reviewer)

  Merge Status:
    [mergeable/conflicts/approvals needed]

Examples

示例

Example 1: Feature Branch with Open PR

示例1:存在开放PR的功能分支

User says: "/pr-status" Actions:
  1. Verify gh CLI available, fetch latest
  2. Report branch
    feature/auth
    is 2 behind main
  3. Show PR #45 is open, CI passing, 1 approval, no conflicts
  4. Report ready to merge Result: Complete status showing merge-ready PR
用户输入:"/pr-status" 操作:
  1. 验证gh CLI可用,拉取最新代码
  2. 报告分支
    feature/auth
    落后主分支2个提交
  3. 显示PR #45处于开放状态,CI已通过,1个批准,无冲突
  4. 报告PR已就绪可合并 结果: 展示完整的状态报告,说明PR可合并

Example 2: No PR Exists

示例2:无对应的PR

User says: "/pr-status" Actions:
  1. Verify gh CLI, identify branch
    fix/typo
  2. Report 3 modified files, 1 commit not pushed
  3. Report no PR exists for this branch Result: Branch state shown, suggest creating PR
用户输入:"/pr-status" 操作:
  1. 验证gh CLI,识别分支为
    fix/typo
  2. 报告有3个已修改文件,1个提交未推送
  3. 报告该分支无对应的PR 结果: 展示分支状态,建议创建PR

Example 3: On Main Branch

示例3:处于主分支

User says: "/pr-status" Actions:
  1. Detect current branch is main
  2. List recent PRs if optional behavior enabled
  3. Suggest switching to a feature branch Result: Brief report noting user is on main

用户输入:"/pr-status" 操作:
  1. 检测当前分支为主分支
  2. 若开启可选行为则列出近期PR
  3. 建议切换到功能分支 结果: 简短报告,提示用户当前处于主分支

Error Handling

错误处理

Error: "gh CLI Not Installed or Not Authenticated"

错误: "gh CLI Not Installed or Not Authenticated"

Cause: GitHub CLI missing or
gh auth login
not completed Solution:
  1. Report the specific missing prerequisite
  2. Provide installation/auth URL
  3. Stop -- do not attempt partial status without gh
原因: GitHub CLI缺失或未完成
gh auth login
认证 解决方案:
  1. 报告具体缺失的前置条件
  2. 提供安装/认证URL
  3. 终止操作——没有gh则无法完成完整的状态检查

Error: "No Remote Tracking Branch"

错误: "No Remote Tracking Branch"

Cause: Branch exists locally but has never been pushed Solution:
  1. Report local branch state (modified files, commits)
  2. Note that no remote tracking branch exists
  3. Suggest pushing with
    git push -u origin [branch]
原因: 分支仅存在于本地,从未推送至远程 解决方案:
  1. 报告本地分支状态(已修改文件、提交数)
  2. 提示不存在远程跟踪分支
  3. 建议执行
    git push -u origin [branch]
    推送分支

Error: "gh pr view Fails with Non-Zero Exit"

错误: "gh pr view Fails with Non-Zero Exit"

Cause: No PR exists for the branch, or network/auth issue Solution:
  1. Check if error is "no pull requests found" vs network error
  2. For no PR: report branch state, suggest creating one
  3. For network/auth: report the error, suggest
    gh auth status

原因: 该分支无对应的PR,或存在网络/认证问题 解决方案:
  1. 判断错误是“未找到拉取请求”还是网络/认证问题
  2. 若无PR:报告分支状态,建议创建PR
  3. 若为网络/认证问题:报告错误,建议执行
    gh auth status

Anti-Patterns

反模式

Anti-Pattern 1: Modifying State During Status Check

反模式1:状态检查过程中修改状态

What it looks like: Pushing commits, creating PRs, or fixing issues during a status check Why wrong: Status is read-only. Modifications belong to other skills. Do instead: Report status only. Suggest appropriate skills for actions.
表现: 在状态检查过程中推送提交、创建PR或修复问题 错误原因: 状态检查应为只读操作。修改操作属于其他Skill的范畴。 正确做法: 仅报告状态。若需执行操作,建议使用对应的Skill。

Anti-Pattern 2: Skipping Fetch Before Reporting

反模式2:未拉取最新代码就报告

What it looks like: Reporting ahead/behind counts from stale local refs Why wrong: Produces inaccurate status that misleads the user Do instead: Always
git fetch origin --quiet
before comparing
表现: 基于本地陈旧的引用报告领先/落后计数 错误原因: 会产生不准确的状态信息,误导用户 正确做法: 在对比前始终执行
git fetch origin --quiet

Anti-Pattern 3: Partial Report Without Explanation

反模式3:无说明的部分报告

What it looks like: Showing only CI status, omitting reviews and merge state Why wrong: User expects complete picture. Missing sections hide problems. Do instead: Show all sections. If a section fails to load, say so explicitly.
表现: 仅展示CI状态,省略评审和合并状态 错误原因: 用户期望获取完整的状态信息。缺失的模块可能隐藏问题。 正确做法: 展示所有模块。若某模块加载失败,需明确说明。

Anti-Pattern 4: Inventing Status When Commands Fail

反模式4:命令失败时编造状态

What it looks like: Reporting "CI passing" when
gh pr checks
returned an error Why wrong: False status is worse than no status Do instead: Report the command failure and what information is unavailable

表现: 当
gh pr checks
返回错误时,仍报告“CI已通过” 错误原因: 错误的状态信息比无状态信息更糟 正确做法: 报告命令执行失败,并说明无法获取该部分信息

References

参考资料

This skill uses these shared patterns:
  • Verification Checklist - Pre-completion checks
该Skill使用以下共享模式:
  • Verification Checklist - 完成前检查