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