pull-request
Original:🇨🇳 Chinese
Translated
Assists in creating, modifying, viewing or managing GitHub Pull Request (PR). Automatically analyzes branch commits and change content, generates compliant Traditional Chinese PR titles and descriptions. Use cases include: (1) Create a new PR from the current branch, (2) Modify the title, description, reviewers or labels of an existing PR, (3) Check the PR status of the branch (open, merged, closed), (4) Need to automatically aggregate multiple changes to generate a summary. Applicable to scenarios with requests such as "create PR", "create pull request", "help me open a PR", "modify PR content". Operations are executed via GitHub CLI (gh).
7installs
Sourcegn00678465/agentskills
Added on
NPX Install
npx skill4agent add gn00678465/agentskills pull-requestTags
Translated version includes tags in frontmatterSKILL.md Content (Chinese)
View Translation Comparison →GitHub Pull Request Assistant
Assists users in creating or modifying GitHub Pull Request, automatically analyzes branch commits and generates Traditional Chinese PR titles and descriptions.
Features
- Create PR: Create a Pull Request from the current branch to the target branch
- Modify PR: Update the title or description of an existing PR
- Analyze commits: Automatically aggregate branch changes to generate PR content
Decision Flow
User requests PR-related operation
│
├─ Step 1: Check if the current branch has a corresponding PR
│ │
│ │ gh pr view --json number,title,state 2>&1
│ │
│ ├─ 【Has output and state="OPEN"】→ PR already exists
│ │ │
│ │ └─ Enter 【PR Modification Flow】
│ │ - Display existing PR information
│ │ - Ask the user what content to modify
│ │ - Execute gh pr edit command
│ │
│ └─ 【No output or error】→ PR does not exist
│ │
│ └─ Enter 【PR Creation Flow】
│ - Perform pre-checks
│ - Analyze commits
│ - Generate title and description
│ - Execute gh pr create command
│
└─ Step 2: Execute the corresponding process and report resultsCheck if PR exists
bash
# Check if the current branch already has a PR
gh pr view --json number,title,state,urlJudgment Logic:
| Output Result | Judgment | Follow-up Action |
|---|---|---|
Returns JSON and | PR exists and is open | Enter modification flow |
Returns JSON and | PR has been merged | Ask if you want to create a new PR |
Returns JSON and | PR has been closed | Ask if you want to reopen or create a new PR |
Error message | PR does not exist | Enter creation flow |
PR Creation Flow
Step 0: Pre-check
Confirm that the current branch has been pushed to the remote:
bash
# Get current branch name
git rev-parse --abbrev-ref HEAD
# Check if the branch exists on the remote
git ls-remote --heads origin $(git rev-parse --abbrev-ref HEAD)If there is no output: The branch has not been pushed to the remote, you need to execute first:
bash
git push -u origin <current branch>Step 1: Get commits list
Get commits of the current branch relative to the target branch (default ):
mainbash
git --no-pager log --oneline <target branch>..<current branch>Step 2: Get commit detailed information
Get change statistics for each commit:
bash
git --no-pager show <commit-hash> --statStep 3: Generate PR title
Decide the title strategy based on the number of commits:
| Scenario | Title Strategy |
|---|---|
| Single commit | Use the commit message directly |
| Multiple commits | Descriptive title summarizing all changes |
Step 4: Generate PR description
Must strictly follow the format below, ensure the output is real Markdown line breaks, not strings containing :
\nFor the full template, please refer toreferences/pr-template.md
markdown
### Summary
[One sentence summarizing the main purpose of this PR]
### Modification Content
- Change item 1: Describe the specific modification content
- Change item 2: Describe the specific modification content
- Change item 3: Describe the specific modification content
### ⚠️ Risk Assessment
[Assess whether this PR has breaking changes, points that need special attention]
Common risk types:
- Database changes (migration, schema modification)
- API changes (endpoint modification, parameter modification)
- Configuration file changes (environment variables, configuration parameters)
- Dependency updates (package version upgrade)
If there is no risk, you can note: "No breaking changes"
### Remarks
[Other points that reviewers need to pay attention to, such as testing methods, deployment precautions, related Issue links, etc.]Step 5: Create Pull Request
Use GitHub CLI to create PR.
⚠️ It is strictly forbidden to use the parameter directly. You must first write the content to a temporary file, then use to read the content to avoid line breaks being escaped as strings.
--body--body-file\nbash
# Correct approach:
# 1. Create temporary file pr-body.md, write PR description content (ensure real line breaks in the content)
# 2. Use --body-file to read the file
gh pr create --base <target branch> --head <current branch> --title "<title>" --body-file pr-body.md
# 3. Delete the temporary file after creation is completePowerShell Example:
powershell
# Write PR description to file
@"
### Summary
Implement user login function
### Modification Content
- Add login API endpoint
- Implement JWT authentication mechanism
### ⚠️ Risk Assessment
No breaking changes
"@ | Out-File -FilePath pr-body.md -Encoding UTF8
# Create PR
gh pr create --base main --title "feat: 實作登入功能" --body-file pr-body.md
# Clean up temporary files
Remove-Item pr-body.mdBash Example:
bash
# Write PR description to file
cat << 'EOF' > pr-body.md
### Summary
實作使用者登入功能
### 修改內容
- 新增登入 API 端點
- 實作 JWT 驗證機制
### ⚠️ 風險評估
無破壞性變更
EOF
# 建立 PR
gh pr create --base main --title "feat: 實作登入功能" --body-file pr-body.md
# 清理暫存檔案
rm pr-body.mdCommon Options:
| Option | Description |
|---|---|
| Read PR description from file (recommended) |
| Create draft PR |
| Specify reviewers (comma separated) |
| Specify assignee |
| Add labels |
PR Modification Flow
Enter this flow when PR already exists.
Step 1: Get existing PR information
bash
gh pr view --json number,title,body,state,url,headRefName,baseRefNameStep 2: Display PR summary
Display to the user:
- PR number and title
- Current status (OPEN/DRAFT)
- Source branch → Target branch
- PR link
Step 3: Confirm modification content
Perform corresponding operations according to user requirements:
Modify title
bash
gh pr edit <PR number or URL> --title "<new title>"Modify description
bash
gh pr edit <PR number or URL> --body "<new description>"Add reviewers/labels
bash
gh pr edit <PR number or URL> --add-reviewer <users>
gh pr edit <PR number or URL> --add-label <labels>View existing PR
bash
# List PRs of current repo
gh pr list
# View details of specific PR
gh pr view <PR number>Notes
- Only process committed changes: Ignore unstaged changes are ignored
- Language requirement: PR title and description use Traditional Chinese (zh-TW)
- Default target branch: If not specified by the user, the default is
main - GitHub CLI required: Ensure that the tool is installed and logged in
gh
Examples
Example 1: PR does not exist - Create new PR
User request: "Help me create a PR to develop"
Execution flow:
- Check PR: → Error "no pull requests found"
gh pr view - Judgment: PR does not exist, enter creation flow
- Pre-check: Confirm that the branch is on the remote
- Get commits:
git --no-pager log --oneline develop..HEAD - Analyze changes to generate title and description
- Execute:
gh pr create --base develop --head feature/login --title "feat: 實作使用者登入功能" --body "..."
Example 2: PR already exists - Automatically enter modification mode
User request: "Help me open a PR"
Execution flow:
- Check PR:
gh pr view --json number,title,statejson{"number": 42, "title": "feat: 新增登入功能", "state": "OPEN"} - Judgment: PR already exists, enter modification flow
- Report: "There is already PR #42 'feat: 新增登入功能' for this branch, what modification do you want to make?"
- Wait for user instructions
Example 3: Explicitly modify PR
User request: "Modify the title of PR #42 to 'Fix shopping cart calculation error'"
Execution:
bash
gh pr edit 42 --title "修正購物車計算錯誤"Example 4: PR has been merged
User request: "Help me create a PR"
Execution flow:
- Check PR:
gh pr view --json number,title,statejson{"number": 38, "title": "feat: 舊功能", "state": "MERGED"} - Judgment: PR has been merged
- Report: "PR #38 for this branch has been merged. If you have new changes that need to create a PR, please confirm that there are new commits."
References
- - PR description template and writing guide
references/pr-template.md - - Complete reference for GitHub CLI PR related commands
references/gh-pr-commands.md