pr-creator

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

PR Creator

PR 创建器

Overview

概述

This skill automates the creation of GitHub pull requests in draft mode following Conventional Commits format. It pushes the current branch, analyzes changes, generates a structured PR with proper labels, and assigns it to the creator. The skill never modifies code or merges branches.
本技能可按照Conventional Commits格式自动以草稿模式创建GitHub拉取请求。它会推送当前分支、分析变更、生成带有合适标签的结构化PR,并将其分配给创建者。本技能绝不会修改代码或合并分支。

Important Restrictions

重要限制

Before starting, verify these restrictions:
  • DO NOT change branches
  • DO NOT merge any branch
  • DO NOT close any pull request
  • DO NOT make changes to current code (if needed, mention this and stop the process)
  • ⚠️ STOP if current branch is
    main
    ,
    develop
    ,
    master
    , or
    HEAD
    (cannot create PR from these branches)
  • ALWAYS create pull request in draft mode
  • ALWAYS use English for title and body
开始前,请确认以下限制:
  • 禁止切换分支
  • 禁止合并任何分支
  • 禁止关闭任何拉取请求
  • 禁止修改当前代码(若需要修改,请告知用户并终止流程)
  • ⚠️ 若当前分支为
    main
    develop
    master
    HEAD
    ,请终止操作(无法从这些分支创建PR)
  • 必须以草稿模式创建拉取请求
  • 必须使用英文编写标题和正文

Process

流程

Step 0: Identify Ticket ID (if exists)

步骤0:识别工单ID(若存在)

Extract the ticket ID from the current branch name using common patterns:
bash
undefined
从当前分支名称中提取工单ID,常见格式如下:
bash
undefined

Get current branch name

获取当前分支名称

git rev-parse --abbrev-ref HEAD

**Extraction patterns:**

| Branch Format | Ticket ID |
|---------------|-----------|
| `feat/ABC-123/foo-tar-biz` | `ABC-123` |
| `fix/ABCD-123/handle-null-timestamps` | `ABCD-123` |
| `ABC-456-update-user-profile` | `ABC-456` |
| `refactor/no-ticket-name` | `(no ticket)` |

**Extraction rule:**
- Look for pattern: `LETTERS-NUMBERS` (e.g., `ABC-123`, `ABCD-123`, `JIRA-4567`)
- Usually after first `/` or at the beginning of branch
- If not found, ticket is optional in title
git rev-parse --abbrev-ref HEAD

**提取规则:**

| 分支格式 | 工单ID |
|---------------|-----------|
| `feat/ABC-123/foo-tar-biz` | `ABC-123` |
| `fix/ABCD-123/handle-null-timestamps` | `ABCD-123` |
| `ABC-456-update-user-profile` | `ABC-456` |
| `refactor/no-ticket-name` | `(无工单)` |

**提取逻辑:**
- 查找格式为`字母-数字`的内容(例如`ABC-123`、`ABCD-123`、`JIRA-4567`)
- 通常位于第一个`/`之后或分支名称开头
- 若未找到,标题中可省略工单ID

Step 1: Push branch to remote

步骤1:推送分支至远程仓库

bash
git push origin <branch-name>
bash
git push origin <branch-name>

Step 2: Review differences

步骤2:查看差异

bash
git diff <base-branch>...<branch-name>
Typical base branches:
main
,
develop
,
master
, or
HEAD
bash
git diff <base-branch>...<branch-name>
典型基准分支:
main
develop
master
HEAD

Step 3: Create Pull Request in draft mode

步骤3:以草稿模式创建拉取请求

bash
gh pr create --draft \
  --base <base-branch> \
  --head <branch-name> \
  --title "<pull-request-title>" \
  --body "<pull-request-description>" \
  --assignee @me \
  --label <label-by-type>
Important notes:
  • --assignee @me
    : Automatic assignment to creator
  • --label
    : Use appropriate label by change type (see Labels section)
bash
gh pr create --draft \
  --base <base-branch> \
  --head <branch-name> \
  --title "<pull-request-title>" \
  --body "<pull-request-description>" \
  --assignee @me \
  --label <label-by-type>
重要说明:
  • --assignee @me
    : 自动分配给创建者
  • --label
    : 根据变更类型选择合适的标签(参见标签章节)

Title Format

标题格式

Follow Conventional Commits convention:
(TICKET-ID) type(scope): brief description
遵循Conventional Commits规范:
(工单ID) 类型(范围): 简要描述

Title Components

标题组成部分

ComponentRequiredDescriptionExample
TICKET-ID
❌ OptionalTicket identifier (e.g., Jira)
ABCD-123
type
✅ RequiredChange type
fix
,
feat
,
docs
scope
❌ OptionalModified module or area
profile
,
auth
description
✅ RequiredBrief description of change
handle null enrollment timestamps
组件是否必填描述示例
工单ID
❌ 可选工单标识符(如Jira)
ABCD-123
类型
✅ 必填变更类型
fix
feat
docs
范围
❌ 可选修改的模块或区域
profile
auth
描述
✅ 必填变更的简要说明
处理空的注册时间戳

Change Types

变更类型

  • fix
    : Bug fixes
  • feat
    : New feature
  • docs
    : Documentation changes
  • style
    : Format changes (do not affect logic)
  • refactor
    : Code refactoring
  • test
    : Test additions or corrections
  • chore
    : Maintenance tasks
  • fix
    : 修复Bug
  • feat
    : 新增功能
  • docs
    : 文档变更
  • style
    : 格式调整(不影响逻辑)
  • refactor
    : 代码重构
  • test
    : 新增或修正测试
  • chore
    : 维护任务

Title Examples

标题示例

undefined
undefined

With ticket extracted from branch

从分支中提取到工单ID的情况

(ABCD-123) fix(profile): handle null enrollment timestamps by converting to OffsetDateTime at mapper level
(ABCD-123) fix(profile): 在映射层将空的注册时间戳转换为OffsetDateTime

With ticket extracted: feat/ABCD-123/add-profile-endpoint

从分支feat/ABCD-123/add-profile-endpoint提取工单ID的情况

(ABCD-123) feat(profile): add enrollment timestamp to profile response
(ABCD-123) feat(profile): 在用户资料响应中添加注册时间戳

Without ticket in branch

分支中无工单ID的情况

feat(auth): implement JWT token refresh mechanism
feat(auth): 实现JWT令牌刷新机制

With ticket: refactor/JIRA-789/simplify-validation

从分支refactor/JIRA-789/simplify-validation提取工单ID的情况

(JIRA-789) refactor(validation): simplify token validation logic
undefined
(JIRA-789) refactor(validation): 简化令牌验证逻辑
undefined

Body Format (Description)

正文格式(描述)

The PR body should follow this Markdown structure:
PR正文应遵循以下Markdown结构:

Template

模板

markdown
undefined
markdown
undefined

🚀 Overview

🚀 概述

[Brief description of the change made, explaining the purpose and impact on the project. Include details about added features, resolved issues, or implemented improvements.]
[变更的简要描述,说明其目的及对项目的影响。包括新增功能、修复的问题或实现的改进等细节。]

✨ Key Features

✨ 核心特性

  • [Important feature or change 1]
  • [Important feature or change 2]
  • [New functionality, performance improvement, bug fix, etc.]
  • [重要特性或变更1]
  • [重要特性或变更2]
  • [新功能、性能优化、Bug修复等]

🛠️ Changes Made

🛠️ 变更内容

[Detailed description of code changes:]
  • Modified classes/modules: [List of files or modules]
  • Added/modified methods: [Brief description]
  • Business logic changes: [If applicable]
  • Structural changes: [If applicable]
[代码变更的技术细节:]
  • 修改的类/模块: [文件或模块列表]
  • 新增/修改的方法: [简要说明]
  • 业务逻辑变更: [若适用]
  • 结构变更: [若适用]

✅ Validation & Testing

✅ 验证与测试

  • [Test 1: Description and result]
  • [Test 2: Description and result]
  • Command executed:
    [command to run tests]
  • [测试1:描述及结果]
  • [测试2:描述及结果]
  • 执行的命令:
    [运行测试的命令]

🔗 Related

🔗 相关链接

  • [Link to Jira ticket/Issue]
  • [Link to related documentation]
  • [Link to other related PRs]
undefined
  • [Jira工单/问题链接]
  • [相关文档链接]
  • [其他相关PR链接]
undefined

Body Notes

正文说明

  • Overview: General context and purpose of change
  • Key Features: Concise list of most relevant changes
  • Changes Made: Technical implementation details
  • Validation & Testing: Always include the command used to run tests
  • Related: Optional section for links to related resources
  • 概述:变更的整体背景和目的
  • 核心特性:最相关变更的简洁列表
  • 变更内容:技术实现细节
  • 验证与测试必须包含运行测试所使用的命令
  • 相关链接:可选章节,用于添加相关资源的链接

Labels and Assignment

标签与分配

ALWAYS include:
  • --assignee @me
    : Automatic assignment
  • --label <type>
    : Label corresponding to change type
必须包含:
  • --assignee @me
    : 自动分配给创建者
  • --label <type>
    : 与变更类型对应的标签

Type to Label Mapping

类型与标签映射

TypeLabelDescription
fix
bug
Bug fixes
feat
enhancement
or
feature
New feature
docs
documentation
Documentation changes
refactor
refactor
Code refactoring
test
testing
Tests
chore
maintenance
or
chore
Maintenance tasks
类型标签描述
fix
bug
Bug修复
feat
enhancement
feature
新增功能
docs
documentation
文档变更
refactor
refactor
代码重构
test
testing
测试相关
chore
maintenance
chore
维护任务

Complete Example

完整示例

bash
undefined
bash
undefined

1. Push branch

1. 推送分支

git push origin fix/handle-null-timestamps
git push origin fix/handle-null-timestamps

2. Review differences

2. 查看差异

git diff main...fix/handle-null-timestamps
git diff main...fix/handle-null-timestamps

3. Create PR in draft

3. 以草稿模式创建PR

gh pr create --draft
--base main
--head fix/handle-null-timestamps
--title "(ABCD-123) fix(profile): handle null enrollment timestamps"
--body "## 🚀 Overview
Fixed null pointer exception when enrollment timestamps are null...
gh pr create --draft
--base main
--head fix/handle-null-timestamps
--title "(ABCD-123) fix(profile): 处理空的注册时间戳"
--body "## 🚀 概述
修复了当注册时间戳为空时出现的空指针异常...

✨ Key Features

✨ 核心特性

  • Added null checks for enrollment timestamps
  • Converted timestamps to OffsetDateTime at mapper level
  • 为注册时间戳添加空值检查
  • 在映射层将时间戳转换为OffsetDateTime

🛠️ Changes Made

🛠️ 变更内容

  • Modified: ProfileMapper.java
  • Added: Null safety checks in timestamp conversion
  • 修改: ProfileMapper.java
  • 新增: 时间戳转换中的空安全检查

✅ Validation & Testing

✅ 验证与测试

  • Unit tests passing
  • Command executed: `mvn test`
  • 单元测试全部通过
  • 执行的命令: `mvn test`

🔗 Related

🔗 相关链接

undefined
undefined