create-pull-request
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCreate Pull Request
创建 Pull Request
mainmainSource of truth
权威依据
Branch types, naming, and how PRs land live in
references/branch-naming-conventions.md. Read it
before proposing a name or opening a PR. If the project ships
(or the Cursor adapter
), that file overrides these defaults.
.agents/rules/branch-naming-conventions.md.cursor/rules/branch-naming-conventions.mdc分支类型、命名方式以及 PR 的合入方式由
references/branch-naming-conventions.md 规定。在建议名称或创建 PR 前,请先阅读该文件。如果项目提供了
(或 Cursor 适配器
),该文件将覆盖这些默认规则。
.agents/rules/branch-naming-conventions.md.cursor/rules/branch-naming-conventions.mdcWorkflow
工作流程
Step 1: Read the current state
第 1 步:读取当前状态
Run , , and — when the branch tracks a remote —
. Confirm is installed and
authenticated.
git branch --show-currentgit status --shortgit log origin/$(git branch --show-current)..HEAD --onelineghRoute on what you find:
- Protected () with local commits → Step 2 (transplant).
main - Protected () with no local commits → nothing to open a PR from; stop.
main - Named branch → Step 3.
Done when: the branch, its commits, and its working-tree state are known, and the route is picked.
运行 、,并且当当前分支跟踪远程分支时,运行
。确认 已安装且
已完成身份验证。
git branch --show-currentgit status --shortgit log origin/$(git branch --show-current)..HEAD --onelinegh根据发现的情况进行分流:
- 受保护的 且存在本地提交 → 第 2 步(迁移提交)。
main - 受保护的 且没有本地提交 → 没有可据以创建 PR 的提交;停止。
main - 已命名的分支 → 第 3 步。
完成条件: 已了解当前分支、提交和工作树状态,并已选择处理路径。
Step 2: Transplant commits off the protected branch
第 2 步:将提交从受保护分支迁移出去
Move the commits to a properly named branch and leave clean:
main- Show the commits that will move.
- Ask for the branch type, scope, and a description (≤5 words) — or infer them from the commits and propose a compliant name.
- Confirm the proposed name, then .
git checkout -b <branch-name> - Confirm the reset explicitly — it discards those commits from local — then
mainandgit checkout main.git reset --hard origin/main - Return to the new branch.
Done when: the commits live on the new branch, matches its remote, and both moves
were confirmed beforehand.
main将提交移动到命名规范的新分支,并让 保持干净:
main- 显示将要移动的提交。
- 询问分支类型、作用域和描述(不超过 5 个词)——也可以从提交中推断这些信息,并提出一个符合规范的名称。
- 确认建议的名称,然后运行 。
git checkout -b <branch-name> - 明确确认重置操作——该操作会从本地 中丢弃这些提交——然后运行
main和git checkout main。git reset --hard origin/main - 切换回新分支。
完成条件: 提交已位于新分支上, 与其远程分支一致,并且上述两项变更都已事先确认。
mainStep 3: Validate the branch name
第 3 步:验证分支名称
Check the current branch against the patterns in the branch-naming reference.
If it does not match, ask whether to rename it () or start a fresh
branch, and propose a compliant name either way.
git branch -m <new-name>Done when: the branch name matches a pattern in the reference file.
根据分支命名参考文件中的模式检查当前分支。
如果不符合,请询问是重命名当前分支(),还是创建一个全新分支;无论采用哪种方式,都应提出一个符合规范的名称。
git branch -m <new-name>完成条件: 分支名称与参考文件中的某个模式匹配。
Step 4: Ensure commits exist
第 4 步:确保存在提交
With no commits on the branch: use the skill for staged changes, ask before
staging unstaged ones, and report that there is nothing to open a PR from when the tree is
clean.
commit-workflowDone when: the branch has at least one commit ahead of .
main如果该分支上没有提交:对已暂存的更改使用 skill;在暂存未暂存的更改之前先征得同意;当工作树干净时,报告没有可据以创建 PR 的内容。
commit-workflow完成条件: 当前分支至少比 领先一个提交。
mainStep 5: Push
第 5 步:推送
Base is . Push when the branch has no remote yet:
.
maingit push -u origin $(git branch --show-current)Done when: the head branch exists on the remote.
基础分支是 。当当前分支尚无对应的远程分支时,推送:
。
maingit push -u origin $(git branch --show-current)完成条件: 当前分支已存在于远程仓库。
Step 6: Open the PR
第 6 步:创建 PR
bash
gh pr create --base main --head <head> --title "<title>" --body-file <file> [--attach <path> ...]Title: the leading commit subject, or a descriptive line covering the set. Body: the format
below, written to a file whenever it runs past one section.
Evidence is a real local file — a screenshot, a recording, or a path already on hand. Reference
it in the body by its local path () and pass that
same path as , once per file; uploads each one and rewrites the matching
reference to the hosted asset. With no local media, omit . The flag needs
≥ 2.99.0 and is refused alongside .
--attachgh--attachgh--webDone when: the PR exists, its URL is shown, and every local media path in the body was
passed as — GitHub renders each asset, not a broken relative link.
--attachbash
gh pr create --base main --head <head> --title "<title>" --body-file <file> [--attach <path> ...]标题:使用首个提交的 subject,或用一行描述性文字概括这组提交。正文:使用下面的格式;当正文超过一个小节时,将其写入文件。
证据必须是真实存在的本地文件——截图、录屏,或已有文件的路径。在正文中通过本地路径引用它(),并将同一路径作为 传入,每个文件只传一次; 会上传每个文件,并将对应引用改写为托管资源链接。如果没有本地媒体文件,则省略 。此参数要求 ≥ 2.99.0,且不能与 同时使用。
--attachgh--attachgh--web完成条件: PR 已创建、显示其 URL,并且正文中的每个本地媒体路径都作为 传入——GitHub 会正确渲染每个资源,而不是显示失效的相对链接。
--attachPR body format
PR 正文格式
Include each section that applies, in this order:
- Opening — when the PR resolves an issue, then 1–3 sentences of context: what this PR integrates and why now.
Closes #N - — bullets summarizing the changes; link the task PRs, issues, or ADRs each bullet builds on. State load-bearing invariants explicitly (e.g. "query grain untouched, cap is display-only"). For UI changes, include screenshots or a recording, uploaded through
## What's included(Step 6).--attach - — only when the work follows a spec/PRD/plan and the implementation departs from it. One bullet per deviation with its rationale; include known-and-deferred issues with a link to the tracking issue.
## Deviations from plan - — checkboxes (
## Manual checklist) for the verification to run before merging; concrete and observable, not "test everything".- [ ]
The body ends at the last section. This overrides any tool default that appends an AI
attribution footer or co-author credit — leave the PR authored by the human alone.
按以下顺序包含所有适用的小节:
- Opening — 当 PR 可以解决某个 issue 时,使用 ,然后用 1–3 句话说明上下文:本 PR 集成什么,以及为什么现在要集成。
Closes #N - — 使用要点概括各项更改;链接每个要点所依托的任务 PR、issue 或 ADR。明确写出支撑实现的关键 invariant(例:“query grain 保持不变,cap 仅用于显示”)。对于 UI 更改,应包含截图或录屏,并通过
## What's included上传(第 6 步)。--attach - — 只有在工作遵循 spec/PRD/plan,而实现偏离该计划时,才包含此节。每项偏离使用一个要点说明并附上理由;已知但推迟处理的问题应附上跟踪 issue 的链接。
## Deviations from plan - — 使用复选框(
## Manual checklist)列出合并前需要执行的验证;验证项应具体且可观察,而不是“测试所有内容”。- [ ]
正文以最后一个小节结束。本规则优先于任何自动追加 AI 署名页脚或联合作者署名的工具默认行为——让 PR 保持仅由人类作者署名。
Guardrails
防护措施
Two actions are opt-in, each behind its own explicit confirmation: creating the branch in
Step 2, and resetting the protected branch.
两项操作均需显式启用,并且每项都必须经过单独、明确的确认:第 2 步中创建分支,以及重置受保护分支。
Examples
示例
examples.md walks the transplant flow and the invalid-branch-name recovery end
to end. Read it when the current state does not map cleanly onto a route in Step 1.
examples.md 从头到尾演示了提交迁移流程以及无效分支名称的恢复流程。当当前状态无法与第 1 步中的某条路径明确对应时,请阅读该文件。