pr

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Context

背景信息

  • Current branch: !
    git branch --show-current
  • Base branch: !
    git rev-parse --verify main >/dev/null 2>&1 && echo main || echo master
  • Commits on this branch (since base): !
    BASE=$(git rev-parse --verify main >/dev/null 2>&1 && echo main || echo master) && git log --oneline $BASE..HEAD
  • PR for this branch: !
    gh pr view --json number,title,url 2>/dev/null || echo "NO_PR"
  • 当前分支: !
    git branch --show-current
  • 基准分支: !
    git rev-parse --verify main >/dev/null 2>&1 && echo main || echo master
  • 该分支上的提交(相对于基准分支): !
    BASE=$(git rev-parse --verify main >/dev/null 2>&1 && echo main || echo master) && git log --oneline $BASE..HEAD
  • 该分支对应的PR: !
    gh pr view --json number,title,url 2>/dev/null || echo "NO_PR"

Your task

你的任务

Create or update a pull request for the current branch.
为当前分支创建或更新Pull Request。

Pre-flight checks

前置检查

  1. If the current branch is the base branch, stop and tell the user to switch to a feature branch first. Do nothing else.
  2. If there are no commits ahead of the base branch, stop and tell the user to commit changes first. Do nothing else.
  3. Never run
    git add
    or
    git commit
    . Only manage the PR.
  1. 如果当前分支是基准分支,请停止操作并告知用户先切换到功能分支,不执行其他操作。
  2. 如果该分支相对于基准分支没有任何提交,请停止操作并告知用户先提交变更,不执行其他操作。
  3. 绝不执行
    git add
    git commit
    命令,仅负责管理PR。

Analysis

分析步骤

  1. Run
    git diff <base>...HEAD
    to get the full diff of all changes on this branch.
  2. Run
    git log <base>..HEAD --format="%h %s"
    to get all commit messages.
  3. Identify the main topic, group specific changes logically.
  1. 执行
    git diff <base>...HEAD
    获取该分支所有变更的完整差异。
  2. 执行
    git log <base>..HEAD --format="%h %s"
    获取所有提交信息。
  3. 确定核心主题,将具体变更进行逻辑分组。

Decide: create or update

决策:创建或更新

  • If the PR context above shows
    NO_PR
    create a new PR.
  • If a PR is found for the current branch → update that PR.
  • 如果上述PR背景信息显示
    NO_PR
    创建新的PR。
  • 如果找到当前分支对应的PR → 更新该PR。

PR title

PR标题

Follow Conventional Commits format:
<type>: <description>
.
Types: feat, fix, docs, refactor, test, chore, build, perf, ci. Append
!
for breaking changes.
When updating, keep the existing title unless it is generic (e.g. "Update"), outdated, or does not follow Conventional Commits.
遵循Conventional Commits格式:
<type>: <description>
类型包括:feat, fix, docs, refactor, test, chore, build, perf, ci。若为破坏性变更,需在类型后追加
!
更新PR时,保留现有标题,除非标题过于通用(例如"Update")、已过时或不符合Conventional Commits规范。

PR body format

PR正文格式

undefined
undefined

Summary

摘要

<1-2 sentence high-level description of what this PR does and why>
<1-2句话的高层级描述,说明本PR的作用及原因>

Changes

变更内容

<bulleted list of all meaningful changes, grouped logically>
<所有重要变更的项目符号列表,按逻辑分组>

Test plan

测试计划

<bulleted checklist of how to verify these changes> ```
<用于验证这些变更的可操作检查清单>
undefined

Execution

执行流程

Create flow:
  1. Push the branch to origin:
    git push -u origin <branch>
    .
  2. Create the PR:
    gh pr create --title "<title>" --body "<body>"
    .
Update flow:
  1. Update the PR:
    gh pr edit --title "<title>" --body "<body>"
    .
创建流程:
  1. 将分支推送到远程仓库:
    git push -u origin <branch>
  2. 创建PR:
    gh pr create --title "<title>" --body "<body>"
更新流程:
  1. 更新PR:
    gh pr edit --title "<title>" --body "<body>"

Rules

规则

  • Write the summary in plain English, focusing on the why and the what.
  • List changes as concise bullet points. Group related items under sub-headers if the PR touches multiple areas.
  • The test plan should contain actionable verification steps relevant to the changes. If a check was already run and passed, mark it as done.
  • Use a HEREDOC to pass the body to
    gh pr create
    or
    gh pr edit
    .
  • Do not send any text besides the tool calls.
  • 摘要使用简洁明了的英文撰写,重点说明原因内容
  • 变更内容以简洁的项目符号列表呈现,如果PR涉及多个领域,可将相关项归类到子标题下。
  • 测试计划应包含与变更相关的可操作验证步骤。如果某项检查已执行并通过,标记为已完成。
  • 使用HEREDOC将正文内容传递给
    gh pr create
    gh pr edit
    命令。
  • 除工具调用命令外,不得发送任何其他文本。