create-pull-request
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCreate Pull Request
创建Pull Request
Publish one completed change as a clear, accurate, ready-for-review GitHub pull request.
A direct request to create, open, or publish the PR authorizes the ordinary commit, push, and PR creation needed for that exact change. If a matching open PR already exists, this includes updating its title and body to reflect the completed change and marking it ready for review. It does not authorize force-pushing, merging, issue edits, labels, reviewers, assignees, or unrelated local changes.
Leave the published PR open for review. Merging requires a separate explicit user instruction after publication and delivery of the PR URL, even if the original request bundled creation and merging. Do not merge, enable auto-merge, or enqueue a merge during this workflow.
将一项已完成的变更以清晰、准确、可供评审的GitHub pull request形式发布。
直接提出创建、打开或发布PR的请求,即表示授权执行该变更所需的常规commit、push和PR创建操作。如果已存在匹配的未关闭PR,这包括更新其标题和正文以反映已完成的变更,并将其标记为可供评审状态。该授权不包括force-push、merge、编辑issue、添加标签、指定评审人/经办人,或处理无关的本地变更。
保持发布后的PR处于打开状态以供评审。即使原始请求同时包含创建和merge的要求,merge操作也需要在PR发布并提供PR URL后,由用户单独明确指示。在此工作流中,不得执行merge、启用auto-merge或将PR加入merge队列。
Establish the change
确认变更信息
- Read the repository instructions for branches, commits, verification, and pull requests, including the applicable PR template.
- Resolve the exact GitHub host, base repository, head repository, and push remote from the user's request, repository instructions, and Git remotes. Ask when the intended destination remains ambiguous.
- Use the user's requested head branch, otherwise the current branch. Use the requested base branch; when unspecified, follow repository instructions, then , then GitHub's default branch. Ask if repository instructions and explicit branch configuration conflict. A default or protected branch can be the PR head; respect restrictions on the actual push operation.
branch.<head>.gh-merge-base - Do not create or switch branches by default. If publication requires creating or switching a branch, explain the concrete reason and proposed branch, ask for permission, and wait before proceeding unless the user has already explicitly authorized that action. A request to publish a PR alone is not permission to change branches. Resolve a detached HEAD or a head and base that identify the same branch under this rule.
- Record the resolved head ref and commit. Use them for the diff, verification, push, and PR comparison; local represents the requested head only when they match. When the intended commit is already the remote head, inspect that ref without requiring a checkout or push. Commit local changes only in a checkout of the selected head, subject to the branch permission rule.
HEAD - Inspect the complete merge-base diff from the fetched base to the selected head, its commits, and any local changes intended for publication, including staged and unstaged changes, untracked files, and .
git diff --check - Preserve unrelated worktree changes. Stage only clearly in-scope paths; never stash, discard, clean, reset, amend, rebase, or rewrite history merely to publish the PR.
- Check for an existing open PR with the same base repository and branch and head repository and branch. Read its title, body, and draft state, then reuse it instead of creating a duplicate. Do not reopen or reuse a closed or merged PR without explicit direction.
If the intended change set is empty, mixed with changes of uncertain ownership, or incomplete, stop before committing or pushing and explain the exact blocker.
- 阅读仓库中关于分支、commit、验证和pull request的规范说明,包括适用的PR模板。
- 结合用户请求、仓库规范和Git remote配置,确定准确的GitHub主机、基础仓库、头仓库和push远程地址。如果目标位置不明确,需向用户询问。
- 优先使用用户指定的head分支,否则使用当前分支。优先使用用户指定的base分支;若未指定,遵循仓库规范,其次参考配置,最后使用GitHub默认分支。如果仓库规范与明确的分支配置存在冲突,需向用户确认。默认分支或受保护分支也可以作为PR的head分支;需遵守实际push操作的相关限制。
branch.<head>.gh-merge-base - 默认情况下不得创建或切换分支。如果发布PR需要创建或切换分支,需说明具体原因和拟使用的分支,征得用户同意后再继续操作,除非用户已明确授权该操作。仅请求发布PR并不等同于允许更改分支。若遇到detached HEAD或head与base为同一分支的情况,需遵循此规则处理。
- 记录已确认的head引用和commit。将其用于diff、验证、push和PR对比;仅当本地与记录的commit匹配时,才代表其为请求的head分支。如果目标commit已经是远程head分支的最新提交,无需checkout或push,直接检查该引用即可。仅在已checkout到所选head分支时才能commit本地变更,且需遵守分支权限规则。
HEAD - 检查从已拉取的base分支到所选head分支的完整merge-base diff、相关commit,以及所有拟发布的本地变更,包括staged和unstaged变更、未跟踪文件,同时运行检查。
git diff --check - 保留无关的worktree变更。仅将明确属于范围内的路径加入staged区;绝不能仅为了发布PR而执行stash、丢弃、clean、reset、amend、rebase或改写历史记录的操作。
- 检查是否已存在具有相同基础仓库、base分支、头仓库和head分支的未关闭PR。读取其标题、正文和draft状态,复用该PR而非创建重复项。未经明确指示,不得重新打开或复用已关闭或已merge的PR。
如果目标变更集为空、混杂了归属不明确的变更,或者变更不完整,需在commit或push之前停止操作,并说明具体的阻碍原因。
Prepare and verify the change
准备并验证变更
Before publication, confirm that the requested scope is complete, the base and head are correct, the full PR diff is coherent, and no known blocker is hidden.
Run repository-required formatting, lint, type, test, build, or validation commands at their required stage: before committing, after committing, after pushing, or after PR creation. Require checks that can run before publication to pass before creating or marking the PR ready. Checks that require a push or PR run after that prerequisite exists; report them as pending until results are available. If the repository specifies no checks for this change, use the smallest deterministic checks that exercise the changed behavior, with on the intended diff as the minimum repository check.
git diff --checkReuse recorded verification results when they can be tied to the code being published and the relevant dependencies, configuration, and environment still match. Run only missing or invalidated checks unless repository rules require a fresh run at the current stage; opening a PR is not itself a reason to repeat successful verification.
Record the exact commands and outcomes, distinguishing passed, failed, skipped, and unable-to-run checks. Confirm required coverage actually ran; a successful command that excluded it does not satisfy the publication check. A known required-check failure or unavailable required check blocks creating or marking the PR ready at that stage. Report the failure or gap; if a PR already exists, include its URL and leave it open. Never claim a test, review, or user journey that was not run. Preserve valid failing regressions; do not weaken tests, bypass the failing path, or reclassify required checks merely to publish. Resolve in-scope defects when authorized, or report the precise blocker.
If in-scope local changes remain, run checks required before committing, stage only the intended changes, inspect the staged diff, and create one clear commit for that completed work. Preserve existing commits unless the user explicitly requests a history change. Update the recorded head commit, recompute the complete base-to-head diff, and run checks required after committing. A commit with unchanged tested file contents does not invalidate evidence unless the check depends on Git metadata. If hooks change files, or verification depended on worktree changes absent from the commit, rerun the affected checks against the final revision.
发布前,需确认请求的变更范围完整、base和head分支正确、完整的PR diff逻辑通顺,且不存在已知的隐藏阻碍。
在要求的阶段运行仓库规定的格式化、lint、类型检查、测试、构建或验证命令:commit前、commit后、push后或PR创建后。可在发布前运行的检查必须全部通过,才能创建PR或将其标记为可供评审状态。需要push或PR创建后才能运行的检查,在前置条件满足后再执行;在结果出来之前,将其标记为待处理。如果仓库未对此类变更规定检查项,使用能验证变更行为的最小确定性检查集,最低要求是对目标diff运行。
git diff --check如果已记录的验证结果与待发布代码关联,且相关依赖、配置和环境仍匹配,可以复用这些结果。仅运行缺失或已失效的检查,除非仓库规则要求在当前阶段重新运行;创建PR本身不能作为重复执行已通过验证的理由。
记录准确的命令和执行结果,区分通过、失败、跳过和无法运行的检查。确认要求的覆盖率检查确实已执行;如果命令执行成功但未包含覆盖率检查,不满足发布检查要求。已知的必需检查失败或必需检查不可用,会阻碍在该阶段创建PR或将其标记为可供评审状态。需报告失败或缺失情况;如果PR已存在,附上其URL并保持打开状态。绝不能声称已运行未执行的测试、评审或用户旅程。保留有效的失败回归用例;不得仅为了发布而弱化测试、绕过失败路径或重新分类必需检查。在获得授权的情况下修复范围内的缺陷,否则报告具体的阻碍原因。
如果仍有范围内的本地变更,运行commit前所需的检查,仅将目标变更加入staged区,检查staged diff,然后为已完成的工作创建一个清晰的commit。保留现有commit,除非用户明确要求更改历史记录。更新记录的head commit,重新计算完整的base到head的diff,并运行commit后所需的检查。如果commit未更改已测试的文件内容,则不会使验证结果失效,除非检查依赖于Git元数据。如果hooks修改了文件,或者验证依赖的worktree变更未包含在commit中,需针对最终修订版重新运行受影响的检查。
Author the pull request
编写Pull Request内容
Derive the title and body from the source issue or specification when available, the complete committed diff, the commit list, and the final verification results. Do not rely on conversation memory alone.
PR的标题和正文需基于可用的源issue或规范、完整的已提交diff、commit列表以及最终验证结果来编写,不得仅依赖对话记忆。
Title
标题
- Describe the outcome in simple, ordinary language.
- Make it understandable without reading the issue.
- Avoid vague wording such as "update logic" or "fix issue."
- Use repository prefixes such as only when the repository requires them.
feat:
- 用简单平实的语言描述变更结果。
- 即使不阅读关联issue也能理解标题含义。
- 避免使用模糊表述,例如或
update logic。fix issue - 仅在仓库要求时,才使用这类仓库规定的前缀。
feat:
Body
正文
Follow the applicable repository template or the user's requested format. Preserve required sections and answer them accurately; omit optional sections that add no information. Do not mark template checkboxes complete without supporting evidence.
When no template governs, choose the structure the change warrants. A simple PR may need only a short explanation of the problem and resulting behavior, followed by verification commands and outcomes. Add implementation decisions, review pointers, compatibility risks, or non-goals only when they help assess the change. Avoid duplicate summaries, empty headings, and boilerplate such as a mandatory "None identified" risk section.
Keep every claim traceable to repository evidence. Do not invent scope, files, tests, risks, follow-up work, or success. Remove secrets, absolute local paths, private command output, and internal agent artifacts. Use repository-relative paths and concise result summaries.
Add only when the PR fully completes that same-repository issue. Use a non-closing reference when the issue is only context or the work is partial. Do not infer issue numbers from branch names alone.
Closes #<number>Write the reviewed Markdown to a temporary file outside the repository, or stream it through standard input when supported. Pass it with ; do not interpolate multiline Markdown into a shell argument.
--body-file遵循适用的仓库模板或用户要求的格式。保留必填部分并准确填写;省略无实际信息的可选部分。没有支撑证据的情况下,不得勾选模板中的复选框。
如果没有适用的模板,根据变更类型选择合适的结构。简单的PR可能只需要简短说明问题和变更后的行为,然后附上验证命令和结果。仅在有助于评估变更时,才添加实现决策、评审要点、兼容性风险或非目标内容。避免重复的摘要、空标题和套话,例如强制添加“未发现风险”之类的风险章节。
确保所有陈述都能在仓库中找到证据支撑。不得编造变更范围、文件、测试、风险、后续工作或成功结果。移除密钥、本地绝对路径、私有命令输出和内部Agent产物。使用仓库相对路径和简洁的结果摘要。
仅当PR完全完成了同一仓库中的对应issue时,才添加。如果issue仅作为上下文或工作仅部分完成,使用非关闭式引用。不得仅从分支名称推断issue编号。
Closes #<number>将经过评审的Markdown内容写入仓库外的临时文件,或在支持的情况下通过标准输入传递。使用参数传递内容;不要将多行Markdown插值到shell参数中。
--body-filePublish once
单次发布
Require and successful authentication for the active account on the resolved host using .
ghgh auth status --active --hostname HOSTCompare the remote head branch with the recorded head commit. Push only if that commit is not already the remote branch tip, using the resolved source ref and destination branch explicitly, without force. Confirm the source ref still identifies the recorded commit before pushing; if it moved, inspect and verify the new state first. Preserve existing upstream tracking configuration; publishing a PR does not require changing it.
For an existing matching PR, use with its URL and explicit title and arguments only when updates are needed. Preserve accurate human-authored context. Once the applicable checks pass, use with its URL if it is a draft. Do not call for an existing open PR.
gh pr edit--body-filegh pr readygh pr createOtherwise create the PR with explicit arguments, including the resolved host in the repository identifier:
bash
gh pr create \
--repo HOST/OWNER/REPO \
--base BASE_BRANCH \
--head HEAD_BRANCH \
--title "TITLE" \
--body-file PR_BODY_FILEFor a fork, qualify the head as . Never pass ; this skill creates a real PR that is immediately ready for human and automated review.
OWNER:BRANCH--draftIf creation fails or returns unclear output, query GitHub for the exact head and base before retrying. Never blindly repeat a create operation. If the push succeeded but PR creation did not, preserve the pushed branch and report the partial state and exact error.
需确保已安装,且通过命令确认已在目标主机上的活跃账号成功认证。
ghgh auth status --active --hostname HOST将远程head分支与记录的head commit进行对比。仅当该commit不是远程分支的最新提交时才执行push,明确使用已确认的源引用和目标分支,不得使用force模式。push前需确认源引用仍对应记录的commit;如果已发生变动,先检查并验证新的状态。保留现有的上游跟踪配置;发布PR不需要更改该配置。
对于已存在的匹配PR,仅在需要更新时才使用命令,传入PR URL、明确的标题和参数。保留准确的人工编写的上下文。如果PR是draft状态,在相关检查通过后,使用命令并传入PR URL将其标记为就绪。对于已存在的未关闭PR,不得调用命令。
gh pr edit--body-filegh pr readygh pr create否则使用明确的参数创建PR,仓库标识中需包含已确认的主机:
bash
gh pr create \
--repo HOST/OWNER/REPO \
--base BASE_BRANCH \
--head HEAD_BRANCH \
--title "TITLE" \
--body-file PR_BODY_FILE如果是fork仓库,将head分支格式化为。不得传入参数;本Skill创建的是正式PR,可立即供人工和自动化评审。
OWNER:BRANCH--draft如果创建失败或返回的输出不明确,重试前先查询GitHub上准确的head和base状态。绝不能盲目重复创建操作。如果push成功但PR创建失败,保留已push的分支,并报告部分完成的状态和具体错误。
Verify the published result
验证发布结果
Read the created or reused PR back by URL with and verify:
gh pr view- it has a URL and number and is open
- is false
isDraft - repository, base branch, and head branch are exact
- GitHub's head commit matches the recorded, verified head commit
- title and body match the reviewed content
Inspect checks that require publication now that the PR exists. Return the PR URL and number, base and head, published commit, verification commands and outcomes, and any pending or failed checks or other disclosed limitation, then stop with the PR open for review. Do not manually close its source issue.
使用命令通过URL读取已创建或复用的PR,并验证以下内容:
gh pr view- PR具有URL和编号,且处于打开状态
- 为false
isDraft - 仓库、base分支和head分支完全正确
- GitHub上的head commit与记录并验证过的head commit一致
- 标题和正文与经过评审的内容一致
PR创建完成后,检查需要发布后才能运行的检查项。返回PR URL和编号、base和head分支、已发布的commit、验证命令和结果,以及任何待处理或失败的检查或其他已披露的限制,然后结束操作,保持PR处于打开状态以供评审。不得手动关闭其源issue。