create-mr
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCreate MR
创建MR
Create a GitHub pull request from the current branch by reading the repository state, respecting any PR template, and verifying the created PR.
从当前分支创建GitHub拉取请求,过程中会读取仓库状态、遵循PR模板并验证已创建的PR。
Workflow
工作流程
1. Detect PR Template
1. 检测PR模板
Search for a PR template in this order:
.github/PULL_REQUEST_TEMPLATE.md- (pick the first match)
.github/PULL_REQUEST_TEMPLATE/*.md PULL_REQUEST_TEMPLATE.mddocs/PULL_REQUEST_TEMPLATE.md
If a template is found, read it and use it as the base structure for the PR body. Preserve all template sections and fill them from the actual changes.
If no template is found, use the default body format below.
按以下顺序搜索PR模板:
.github/PULL_REQUEST_TEMPLATE.md- (选取第一个匹配的文件)
.github/PULL_REQUEST_TEMPLATE/*.md PULL_REQUEST_TEMPLATE.mddocs/PULL_REQUEST_TEMPLATE.md
如果找到模板,读取并将其作为PR正文的基础结构。保留所有模板章节,并根据实际变更填充内容。
如果未找到模板,则使用下方的默认正文格式。
2. Gather Context
2. 收集上下文
Run these checks, parallelizing file reads and git commands where possible:
bash
git status
git diff --staged
git diff
git log --oneline -20
git remote -v
git branch --show-current执行以下检查,尽可能并行化文件读取和git命令:
bash
git status
git diff --staged
git diff
git log --oneline -20
git remote -v
git branch --show-current3. Analyze Changes
3. 分析变更
From the gathered context:
- Summarize commits and diffs into a coherent narrative.
- Identify the change type: feature, bugfix, refactor, docs, chore, or test.
- Note verification evidence already present in the branch.
从收集到的上下文信息中:
- 将提交记录和差异内容总结为连贯的说明。
- 识别变更类型:功能新增(feature)、bug修复(bugfix)、代码重构(refactor)、文档更新(docs)、日常维护(chore)或测试相关(test)。
- 记录分支中已有的验证证据。
4. Check Changeset Requirement
4. 检查变更集(Changesets)要求
Before pushing or creating the PR, check whether the repository uses Changesets:
bash
test -d .changeset && test -f .changeset/config.json
rg -n '"@changesets/cli"|changeset' package.json pnpm-lock.yaml package-lock.json yarn.lock 2>/dev/nullIf Changesets is not configured, skip this step.
If Changesets is configured, inspect the staged, unstaged, and unpushed branch diff that will be included in the PR. When the diff changes a versioned package or adds a backward-compatible public capability, and no matching file is already included, use the skill before pushing.
.changeset/*.mdchangesetDo not duplicate package eligibility, package-name, or bump-selection logic here. Let the skill derive package names, release impact, and validation commands from repository metadata and Changesets config.
changesetInclude any generated file in the branch before running and .
.changeset/*.mdgit pushgh pr create在推送分支或创建PR之前,检查仓库是否使用Changesets:
bash
test -d .changeset && test -f .changeset/config.json
rg -n '"@changesets/cli"|changeset' package.json pnpm-lock.yaml package-lock.json yarn.lock 2>/dev/null如果未配置Changesets,跳过此步骤。
如果已配置Changesets,检查将包含在PR中的暂存、未暂存和未推送的分支差异。当差异修改了版本化包或添加了向后兼容的公共功能,且未包含匹配的文件时,需在推送前使用技能。
.changeset/*.mdchangeset此处无需重复包适用性、包名称或版本升级选择逻辑。让技能从仓库元数据和Changesets配置中推导包名称、发布影响和验证命令。
changeset在执行和之前,将生成的文件加入分支。
git pushgh pr create.changeset/*.md5. Generate PR Title and Body
5. 生成PR标题和正文
Title requirements:
- 72 characters or fewer.
- Imperative mood.
- Conventional commit style: .
<type>(<scope>): <short description>
Example:
text
feat(auth): add OAuth2 login flowDefault body when no template exists:
markdown
undefined标题要求:
- 长度不超过72个字符。
- 使用祈使语气。
- 符合规范提交格式:。
<type>(<scope>): <简短描述>
示例:
text
feat(auth): add OAuth2 login flow未找到模板时的默认正文格式:
markdown
undefinedSummary
摘要
- <1-3 bullets summarizing what this PR does>
- <1-3条要点总结本PR的内容>
Changes
变更内容
- <key change 1>
- <key change 2>
- <关键变更1>
- <关键变更2>
Test Plan
测试计划
- <how to verify these changes>
- <如何验证这些变更>
Screenshots
截图
<before/after for visual changes, or omit if not applicable>
undefined<视觉变更的前后对比图,若无则省略>
undefinedCreate the Pull Request
创建拉取请求
Use GitHub CLI:
bash
gh pr create --title "<title>" --body "<body>"If the body is large, write it to a temporary file and pass .
--body-fileIf the current branch has no remote tracking branch, push first:
bash
git push -u origin HEADThen retry .
gh pr create使用GitHub CLI:
bash
gh pr create --title "<title>" --body "<body>"如果正文内容较长,可将其写入临时文件并使用参数传递。
--body-file如果当前分支没有远程跟踪分支,先推送分支:
bash
git push -u origin HEAD然后重试。
gh pr createVerify
验证
After creation, run:
bash
gh pr view <number>For machine-readable verification, prefer:
bash
gh pr view <number> --json number,title,url,state,headRefName,baseRefNameReport the PR URL to the user.
创建完成后,执行:
bash
gh pr view <number>若需机器可读的验证结果,优先使用:
bash
gh pr view <number> --json number,title,url,state,headRefName,baseRefName将PR的URL告知用户。
Common Mistakes
常见错误
| Mistake | Fix |
|---|---|
| Ignoring a PR template | Search all supported template locations first. |
| Writing a title from memory | Base the title on the actual diff and commits. |
| Claiming tests passed without evidence | Put only verified commands in the test plan. |
| Omitting a required changeset | Check Changesets support and use the |
| Forgetting to push the branch | Push with |
| 错误 | 修复方法 |
|---|---|
| 忽略PR模板 | 先搜索所有支持的模板路径。 |
| 凭记忆编写标题 | 根据实际的差异内容和提交记录生成标题。 |
| 无证据声称测试通过 | 仅在测试计划中写入已验证的命令。 |
| 遗漏必填的changeset | 在推送影响发布的变更前,检查Changesets支持情况并使用 |
| 忘记推送分支 | 使用 |