github-pull-request

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Github Pull Request

GitHub Pull Request

Path Resolution (avoid missing-skill errors)

路径解析(避免缺失skill错误)

  • Always open this skill using the absolute path from the active session skills list (for example
    <agent-skills-root>/github-pull-request/SKILL.md
    ).
  • Do not try guessed repo-relative skill paths unless the session explicitly lists that exact path.
  • If you hit a missing-skill error from an old path, re-open this skill from the active session skills list and continue (do not retry repo paths).
  • 始终从当前会话技能列表中使用绝对路径打开此skill(例如
    <agent-skills-root>/github-pull-request/SKILL.md
    )。
  • 除非会话明确列出确切路径,否则不要尝试猜测仓库相对的skill路径。
  • 如果因旧路径遇到缺失skill错误,请从当前会话技能列表重新打开此skill并继续操作(不要重试仓库路径)。

Workflow

工作流程

  1. Confirm branch and scope
    • Run
      git branch --show-current
      .
    • If branch looks wrong for the requested work, ask for correction.
  2. Gather change context
    • Run
      git status -sb
      .
    • Run
      git diff --stat origin/$(git rev-parse --abbrev-ref @{upstream}..HEAD)
      when upstream exists.
    • If no upstream exists, use
      git diff --stat
      and
      git diff
      against the likely target branch.
  3. Decide PR title
    • Follow
      type(scope): short imperative summary
      format.
    • Keep title under 72 chars where possible.
  4. Build PR body from required sections:
    • Summary
    • Why this change
    • What changed (bullets grouped by feature/file area)
    • Files changed
    • QA / testing (exact commands + outcomes)
    • Risk and impact
    • Rollback plan
    • Related issues
    • Checklist
  5. Identify related issue(s)
    • Parse issue number from branch if present (examples:
      123
      ,
      issue-123
      ,
      fix/123-...
      ).
    • Add
      Fixes #<issue>
      or
      Closes #<issue>
      in the PR body when confirmed.
  6. Push branch if needed
    • If branch has no upstream, run
      git push -u origin <branch>
      .
  7. Pre-create guards (avoid
    gh pr create
    hard failures)
    • Check whether an open PR already exists for this branch:
      • gh pr list --head <branch> --state open --json number,url
      • If one exists, stop and report the existing PR link instead of creating a duplicate.
    • Check commit delta against intended base branch before create:
      • git rev-list --count <base>..HEAD
      • If count is
        0
        , stop and report "no commits to open PR against
        <base>
        " with next action:
        • verify current repo/branch, or
        • push the intended commits, or
        • switch to the correct branch.
  8. Create PR
    • If user requested draft, pass
      --draft
      .
    • Write the PR body to a temp file and use
      --body-file
      to avoid shell quoting/interpolation bugs with Markdown/backticks.
    • Preferred pattern:
      • BODY_FILE=$(mktemp)
      • cat > "$BODY_FILE" <<'EOF'
        ...
        EOF
      • gh pr create --title "<title>" --body-file "$BODY_FILE"
      • rm -f "$BODY_FILE"
    • If
      gh
      auth is unavailable or user is not in GitHub environment, output the prepared title and body text for manual submission.
  9. Report back
    • Include PR link if created, target branch, and review expectations.
    • Ask explicitly what should be prioritized in review.
  1. 确认分支和范围
    • 运行
      git branch --show-current
    • 如果分支与请求的工作不符,请要求用户更正。
  2. 收集变更上下文
    • 运行
      git status -sb
    • 当存在上游分支时,运行
      git diff --stat origin/$(git rev-parse --abbrev-ref @{upstream}..HEAD)
    • 如果没有上游分支,针对可能的目标分支使用
      git diff --stat
      git diff
  3. 确定PR标题
    • 遵循
      type(scope): short imperative summary
      格式。
    • 尽可能将标题控制在72字符以内。
  4. 从必填部分构建PR正文:
    • 摘要
    • 变更原因
    • 变更内容(按功能/文件区域分组的项目符号)
    • 变更的文件
    • QA/测试(精确命令+结果)
    • 风险与影响
    • 回滚计划
    • 相关问题
    • 检查清单
  5. 识别相关问题
    • 如果分支中包含问题编号(例如:
      123
      issue-123
      fix/123-...
      ),解析该编号。
    • 确认后在PR正文中添加
      Fixes #<issue>
      Closes #<issue>
  6. 如有需要推送分支
    • 如果分支没有上游,运行
      git push -u origin <branch>
  7. 预创建检查(避免
    gh pr create
    执行失败)
    • 检查此分支是否已存在开放的PR:
      • gh pr list --head <branch> --state open --json number,url
      • 如果存在,停止操作并报告现有PR链接,避免创建重复项。
    • 创建前检查与目标分支的提交差异:
      • git rev-list --count <base>..HEAD
      • 如果计数为
        0
        ,停止操作并报告“没有可针对
        <base>
        分支创建PR的提交”,并给出后续操作建议:
        • 验证当前仓库/分支,或
        • 推送预期的提交,或
        • 切换到正确的分支。
  8. 创建PR
    • 如果用户要求创建草稿,添加
      --draft
      参数。
    • 将PR正文写入临时文件,并使用
      --body-file
      参数以避免Markdown/反引号带来的shell引用/插值错误。
    • 推荐模式:
      • BODY_FILE=$(mktemp)
      • cat > "$BODY_FILE" <<'EOF'
        ...
        EOF
      • gh pr create --title "<title>" --body-file "$BODY_FILE"
      • rm -f "$BODY_FILE"
    • 如果
      gh
      认证不可用或用户不在GitHub环境中,输出准备好的标题和正文文本供手动提交。
  9. 反馈结果
    • 如果已创建PR,包含PR链接、目标分支和评审预期。
    • 明确询问评审中应优先关注的内容。

PR body template

PR正文模板

undefined
undefined

Summary

摘要

  • ...
  • ...

Why

变更原因

  • ...
  • ...

What changed

变更内容

  • ...
  • ...

Files changed

变更的文件

  • ...
  • ...

QA / Testing

QA / 测试

  • Command:
    ...
    — Result: ...
  • Command:
    ...
    — Result: ...
  • 命令:
    ...
    — 结果:...
  • 命令:
    ...
    — 结果:...

Risks and impacts

风险与影响

  • ...
  • ...

Rollback plan

回滚计划

  • ...
  • ...

Related issues

相关问题

  • Fixes #123 (optional)
  • Fixes #123(可选)

Checklist

检查清单

  • Tests pass
  • No obvious regressions
  • Documentation updated where needed
  • Rollback path documented
undefined
  • 测试通过
  • 无明显回归问题
  • 必要时更新文档
  • 已记录回滚路径
undefined

Hard rules

硬性规则

  • Never submit a PR without a QA/testing section.
  • Never claim tests passed without listing exact commands and outputs.
  • Do not include secrets, credentials, or internal URLs in the PR description.
  • Ask before adding reviewers/labels if not already provided.
  • Never merge a PR automatically; only merge when the user explicitly instructs it.
  • 没有QA/测试部分的PR绝不上交。
  • 没有列出精确命令和输出,绝不能声称测试通过。
  • 不要在PR描述中包含密钥、凭证或内部URL。
  • 如果未提供评审人/标签,添加前需询问用户。
  • 绝不要自动合并PR;仅当用户明确指示时才合并。

Optional metadata enrichment with gh

使用gh进行可选元数据补充

  • Use
    gh pr create
    and
    gh pr view
    for consistency checks.
  • If labels are requested, add after creation:
    • gh pr edit <number> --add-label <label>
  • If reviewers are requested:
    • gh pr edit <number> --add-reviewer <users>
  • 使用
    gh pr create
    gh pr view
    进行一致性检查。
  • 如果需要添加标签,创建后执行:
    • gh pr edit <number> --add-label <label>
  • 如果需要添加评审人:
    • gh pr edit <number> --add-reviewer <users>