pr-creator
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePR 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, ormaster(cannot create PR from these branches)HEAD - ✅ ALWAYS create pull request in draft mode
- ✅ ALWAYS use English for title and body
开始前,请确认以下限制:
- ❌ 禁止切换分支
- ❌ 禁止合并任何分支
- ❌ 禁止关闭任何拉取请求
- ❌ 禁止修改当前代码(若需要修改,请告知用户并终止流程)
- ⚠️ 若当前分支为、
main、develop或master,请终止操作(无法从这些分支创建PR)HEAD - ✅ 必须以草稿模式创建拉取请求
- ✅ 必须使用英文编写标题和正文
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
undefinedGet 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 titlegit 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`)
- 通常位于第一个`/`之后或分支名称开头
- 若未找到,标题中可省略工单IDStep 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: , , , or
maindevelopmasterHEADbash
git diff <base-branch>...<branch-name>典型基准分支: 、、或
maindevelopmasterHEADStep 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:
- : Automatic assignment to creator
--assignee @me - : Use appropriate label by change type (see Labels section)
--label
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
标题组成部分
| Component | Required | Description | Example |
|---|---|---|---|
| ❌ Optional | Ticket identifier (e.g., Jira) | |
| ✅ Required | Change type | |
| ❌ Optional | Modified module or area | |
| ✅ Required | Brief description of change | |
| 组件 | 是否必填 | 描述 | 示例 |
|---|---|---|---|
| ❌ 可选 | 工单标识符(如Jira) | |
| ✅ 必填 | 变更类型 | |
| ❌ 可选 | 修改的模块或区域 | |
| ✅ 必填 | 变更的简要说明 | |
Change Types
变更类型
- : Bug fixes
fix - : New feature
feat - : Documentation changes
docs - : Format changes (do not affect logic)
style - : Code refactoring
refactor - : Test additions or corrections
test - : Maintenance tasks
chore
- : 修复Bug
fix - : 新增功能
feat - : 文档变更
docs - : 格式调整(不影响逻辑)
style - : 代码重构
refactor - : 新增或修正测试
test - : 维护任务
chore
Title Examples
标题示例
undefinedundefinedWith 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): 简化令牌验证逻辑
undefinedBody Format (Description)
正文格式(描述)
The PR body should follow this Markdown structure:
PR正文应遵循以下Markdown结构:
Template
模板
markdown
undefinedmarkdown
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链接]
undefinedBody 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:
- : Automatic assignment
--assignee @me - : Label corresponding to change type
--label <type>
必须包含:
- : 自动分配给创建者
--assignee @me - : 与变更类型对应的标签
--label <type>
Type to Label Mapping
类型与标签映射
| Type | Label | Description |
|---|---|---|
| | Bug fixes |
| | New feature |
| | Documentation changes |
| | Code refactoring |
| | Tests |
| | Maintenance tasks |
| 类型 | 标签 | 描述 |
|---|---|---|
| | Bug修复 |
| | 新增功能 |
| | 文档变更 |
| | 代码重构 |
| | 测试相关 |
| | 维护任务 |
Complete Example
完整示例
bash
undefinedbash
undefined1. 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
--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 "## 🚀 概述
--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`