wtf.create-pr
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCreate PR
创建PR
Open a pull request for a completed task branch. Core value: reads the full spec hierarchy (Task + Feature + Epic) and the branch diff to write a PR description that explains why the change exists — not just what it does.
为已完成的任务分支打开拉取请求。核心价值:读取完整的规格层级(Task + Feature + Epic)和分支差异,撰写PR描述来解释为什么要进行这项更改——而不只是说明更改了什么。
Process
流程
0. GitHub CLI setup
0. GitHub CLI 配置
Run steps 1–2 of (install check and auth check). Stop if is not installed or not authenticated. Extensions are not required for this skill.
../references/gh-setup.mdghSkip this step if invoked from or another skill that already ran gh-setup this session.
verify-task执行中的步骤1–2(安装检查和身份验证检查)。如果未安装或未通过身份验证,则停止操作。此技能不需要扩展。
../references/gh-setup.mdgh如果是从或本次会话中已运行gh-setup的其他技能调用,则跳过此步骤。
verify-task1. Confirm the branch
1. 确认分支
Check the current branch and verify it is not :
mainbash
git branch --show-currentIf on , ask: "Which branch should I open a PR from?"
mainCheck whether a PR already exists for this branch:
bash
gh pr list --head <branch_name> --state openIf an open PR already exists, print its URL and call with:
AskUserQuestion-
: "A PR already exists for this branch. Would you like me to update its description instead?"
question -
: "Existing PR"
header -
:
options[{label: "Update description", description: "Edit the existing PR's description"}, {label: "Open a new one", description: "Create a new PR anyway"}] -
Update description → skip to step 5, targeting the existing PR for update via.
gh pr edit <pr_number> -
Open a new one → continue.
检查当前分支并验证它不是分支:
mainbash
git branch --show-current如果当前在分支上,询问:“我应该从哪个分支创建PR?”
main检查该分支是否已存在PR:
bash
gh pr list --head <branch_name> --state open如果已存在打开的PR,打印其URL并调用,参数如下:
AskUserQuestion-
: “该分支已存在PR。您是否希望我更新它的描述?”
question -
: “已存在的PR”
header -
:
options[{label: "更新描述", description: "编辑现有PR的描述"}, {label: "创建新PR", description: "无论如何都创建新PR"}] -
更新描述 → 跳至步骤5,通过针对现有PR进行更新。
gh pr edit <pr_number> -
创建新PR → 继续操作。
2. Identify the Task (if any)
2. 识别任务(如果有)
Try to extract a task number from the branch name (e.g. → ).
task/42-date-range-filter#42If found, call with , , and .
AskUserQuestionquestion: "I found Task #<n> linked to this branch. Is that the right task?"header: "Linked task"options: [{label: "Yes, that's correct", description: "Use Task #<n>"}, {label: "No, use a different task", description: "I'll provide the correct issue number"}]If not found or the user says no, call with , , and .
AskUserQuestionquestion: "Is there a Task issue linked to this work?"header: "Linked task"options: [{label: "No linked task", description: "Proceed without a task link"}, {label: "Yes — I'll provide the number", description: "Enter the task issue number"}]尝试从分支名称中提取任务编号(例如 → )。
task/42-date-range-filter#42如果找到,调用,参数为,,以及。
AskUserQuestionquestion: "我发现该分支关联了任务#<n>。是否正确?"header: "关联任务"options: [{label: "是的,正确", description: "使用任务#<n>"}, {label: "否,使用其他任务", description: "我将提供正确的议题编号"}]如果未找到或用户选择否,调用,参数为,,以及。
AskUserQuestionquestion: "这项工作是否关联了任务议题?"header: "关联任务"options: [{label: "无关联任务", description: "不关联任务继续操作"}, {label: "是——我将提供编号", description: "输入任务议题编号"}]3. Lifecycle check (if Task linked)
3. 生命周期检查(如果关联了任务)
If a Task issue is known, check its labels:
bash
gh issue view <task_number> --json labels --jq '.labels[].name'If the label is absent, warn the user that the task hasn't been verified yet and that the recommended flow is: write-task → design-task → implement-task → verify-task → create-pr. Then call with:
verifiedAskUserQuestion-
: "This task hasn't been verified yet. How would you like to proceed?"
question -
: "Verify first?"
header -
:
optionsverify-task[{label: "Verify first", description: "Runbefore opening the PR (default)"}, {label: "Open PR anyway", description: "Skip verification and open the PR now"}] -
Verify first → follow theprocess, passing the Task number in as context.
verify-task -
Open PR anyway → proceed.
If no Task is linked, skip this step.
如果已知任务议题,检查其标签:
bash
gh issue view <task_number> --json labels --jq '.labels[].name'如果标签不存在,警告用户该任务尚未验证,推荐流程为:write-task → design-task → implement-task → verify-task → create-pr。然后调用,参数如下:
verifiedAskUserQuestion-
: “该任务尚未验证。您希望如何继续?”
question -
: “先验证?”
header -
:
optionsverify-task[{label: "先验证", description: "创建PR前先运行(默认选项)"}, {label: "直接创建PR", description: "跳过验证,立即创建PR"}] -
先验证 → 遵循流程,传入任务编号作为上下文。
verify-task -
直接创建PR → 继续操作。
如果未关联任务,跳过此步骤。
4. Fetch the spec hierarchy
4. 获取规格层级
If a Task issue is known, fetch the full hierarchy:
bash
gh issue view <task_number> # Gherkin, Contracts, DoD, Test Mapping — also yields feature and epic numbers如果已知任务议题,获取完整层级:
bash
gh issue view <task_number> # Gherkin、契约、DoD、测试映射——同时获取功能和史诗编号Extract feature and epic numbers, then in parallel:
提取功能和史诗编号,然后并行执行:
gh issue view <feature_number> # ACs, user stories
gh issue view <epic_number> # Goal, context, constraints
**If no Task issue**, skip hierarchy fetch. The PR will be written from diff context alone (step 5).gh issue view <feature_number> # 验收标准、用户故事
gh issue view <epic_number> # 目标、背景、约束条件
**如果无任务议题**,跳过层级获取。PR将仅基于差异上下文撰写(步骤5)。5. Inspect the diff
5. 检查差异
Determine the base branch using the same logic as step 8 (task/* → parent feature branch; feature/* → main), then collect the branch diff against that base:
bash
git log <base_branch>..HEAD --oneline
git diff <base_branch>...HEAD --statThis avoids including unrelated merged commits when the branch has a long history against main. Use output only unless a specific commit message is ambiguous and cannot be resolved without the diff.
--stat使用与步骤8相同的逻辑确定基准分支(task/* → 父功能分支;feature/* → main),然后收集该分支相对于基准分支的差异:
bash
git log <base_branch>..HEAD --oneline
git diff <base_branch>...HEAD --stat当分支相对于main的历史较长时,这可以避免包含无关的合并提交。仅使用输出,除非特定提交消息不明确,必须查看完整差异才能解析。
--stat6. Draft the PR
6. 撰写PR草稿
Title generation: Spawn a subagent using the model to generate a PR title following Conventional Commits 1.0.0. Pass in the task title (if available), the commit log, and whether this is a breaking change. If the subagent returns nothing usable, generate the title directly using the same rules below. Rules:
claude-haiku-4-5- Format:
<type>[optional scope]: <description> - Types: (new feature),
feat(bug fix),fix,docs,style,refactor,perf,test,build,choreci - Scope: optional noun in parentheses describing the codebase section, e.g.
feat(auth): … - Breaking change: append after type/scope, e.g.
!feat!: … - Description: lowercase, imperative mood, no period at end
- Under 72 characters total
- Examples: ,
feat(search): add date range filter,fix(payments): prevent double settlementrefactor(orders): extract fulfilment service
Body: Use the structure from @.github/pull_request_template.md. Fill in all sections:
- Summary: derived from the Task's Intent + Functional Description (or commit messages if no Task). Explain the why.
- Changes: grouped logical summary of output — not a file list.
git diff --stat - Test plan: if a Task exists, derive checklist items from the Gherkin scenario names. If no Task, derive from changed files and commit messages. At minimum one item per observable behavior changed.
- Related: one line per closed issue — never comma-separated. If a Task exists, include
Closes #<n>. If the PR also closes the parent Feature (all sibling tasks already merged), addCloses #<task_number>on its own line. Example:Closes #<feature_number>Closes #42 Closes #15
标题生成:使用模型生成子代理,按照Conventional Commits 1.0.0规范生成PR标题。传入任务标题(如果可用)、提交日志以及是否为破坏性更改。如果子代理未返回可用内容,则直接按照以下规则生成标题:
claude-haiku-4-5- 格式:
<type>[可选范围]: <描述> - 类型:(新功能)、
feat(bug修复)、fix、docs、style、refactor、perf、test、build、choreci - 范围:可选的名词,放在括号中描述代码库部分,例如
feat(auth): … - 破坏性更改:在类型/范围后追加,例如
!feat!: … - 描述:小写、祈使语气,结尾无句号
- 总长度不超过72个字符
- 示例:、
feat(search): add date range filter、fix(payments): prevent double settlementrefactor(orders): extract fulfilment service
正文:使用@.github/pull_request_template.md中的结构。填写所有部分:
- 摘要:来自任务的意图+功能描述(如果无任务则来自提交消息)。解释为什么进行更改。
- 更改内容:对输出进行逻辑分组总结——不是文件列表。
git diff --stat - 测试计划:如果存在任务,从Gherkin场景名称生成检查项。如果无任务,从更改的文件和提交消息生成。至少为每个更改的可观察行为添加一个检查项。
- 关联内容:每个关闭的议题单独一行——切勿用逗号分隔。如果存在任务,包含
Closes #<n>。如果PR同时关闭父功能(所有兄弟任务已合并),单独添加一行Closes #<task_number>。示例:Closes #<feature_number>Closes #42 Closes #15
7. Review with user
7. 与用户审核
Show the draft title and body. Then call with , , and .
AskUserQuestionquestion: "Does this look right?"header: "Review"options: [{label: "Looks good — create the PR", description: "Proceed with PR creation"}, {label: "I have changes", description: "I want to adjust something first"}]Apply edits, then proceed.
展示草稿标题和正文。然后调用,参数为,,以及。
AskUserQuestionquestion: “这样看起来是否正确?”header: “审核”options: [{label: “没问题——创建PR”, description: “继续创建PR”}, {label: “我需要修改”, description: “我想先调整一些内容”}]应用修改后继续操作。
8. Create the PR
8. 创建PR
Determine the base branch from the current branch name:
- branch → target the parent feature branch (
task/*)feature/<feature-number>-<feature-slug> - branch → target
feature/*main - Other → call with
AskUserQuestion,question: "What branch should this PR target?", options derived fromheader: "Base branch".git branch -r
Write the body to a temp file, then create the PR:
bash
undefined根据当前分支名称确定基准分支:
- 分支 → 目标为父功能分支(
task/*)feature/<feature-number>-<feature-slug> - 分支 → 目标为
feature/*main - 其他分支 → 调用,参数为
AskUserQuestion,question: “此PR应针对哪个分支?”,选项来自header: “基准分支”的结果。git branch -r
将正文写入临时文件,然后创建PR:
bash
undefinedtask branch:
task分支:
gh pr create
--title "<title>"
--body-file /tmp/wtf-create-pr-body.md
--base feature/<feature-number>-<feature-slug>
--title "<title>"
--body-file /tmp/wtf-create-pr-body.md
--base feature/<feature-number>-<feature-slug>
gh pr create
--title "<title>"
--body-file /tmp/wtf-create-pr-body.md
--base feature/<feature-number>-<feature-slug>
--title "<title>"
--body-file /tmp/wtf-create-pr-body.md
--base feature/<feature-number>-<feature-slug>
feature branch:
feature分支:
gh pr create
--title "<title>"
--body-file /tmp/wtf-create-pr-body.md
--base main
--title "<title>"
--body-file /tmp/wtf-create-pr-body.md
--base main
Print the PR URL.gh pr create
--title "<title>"
--body-file /tmp/wtf-create-pr-body.md
--base main
--title "<title>"
--body-file /tmp/wtf-create-pr-body.md
--base main
打印PR的URL。9. Update the Task issue (if linked)
9. 更新任务议题(如果关联)
If a Task issue is linked, post a comment linking the PR:
bash
gh issue comment <task_number> --body "PR opened: <pr_url>"如果关联了任务议题,发布评论链接该PR:
bash
gh issue comment <task_number> --body "PR已创建: <pr_url>"10. Offer next steps
10. 提供下一步选项
Call with:
AskUserQuestion-
: "What's next?"
question -
: "Next step"
header -
:
options[{label: "Request a review", description: "Add reviewers to this PR now (default)"}, {label: "Done", description: "Exit — no further action"}] -
Request a review → callwith
AskUserQuestion,question: "Who should review this?", andheader: "Reviewer"pre-filled with team member usernames inferred from recent git log authors or the repository's CODEOWNERS file. Then:optionsbashgh pr edit <pr_number> --add-reviewer <username>For multiple reviewers, pass a comma-separated list:. Print the PR URL.--add-reviewer user1,user2 -
Done → exit.
调用,参数如下:
AskUserQuestion-
: “下一步做什么?”
question -
: “下一步”
header -
:
options[{label: “请求审核”, description: “立即为此PR添加审核者(默认选项)”}, {label: “完成”, description: “退出——无需进一步操作”}] -
请求审核 → 调用,参数为
AskUserQuestion,question: “谁来审核此PR?”,选项从最近的git日志作者或仓库的CODEOWNERS文件中推断出团队成员用户名。然后执行:header: “审核者”bashgh pr edit <pr_number> --add-reviewer <username>若有多个审核者,传入逗号分隔的列表:。 打印PR的URL。--add-reviewer user1,user2 -
完成 → 退出。