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
Added on

NPX Install

npx skill4agent add gn00678465/agentskills pull-request

SKILL.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 results

Check if PR exists

bash
# Check if the current branch already has a PR
gh pr view --json number,title,state,url
Judgment Logic:
Output ResultJudgmentFollow-up Action
Returns JSON and
state: "OPEN"
PR exists and is openEnter modification flow
Returns JSON and
state: "MERGED"
PR has been mergedAsk if you want to create a new PR
Returns JSON and
state: "CLOSED"
PR has been closedAsk if you want to reopen or create a new PR
Error message
no pull requests found
PR does not existEnter 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
main
):
bash
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> --stat

Step 3: Generate PR title

Decide the title strategy based on the number of commits:
ScenarioTitle Strategy
Single commitUse the commit message directly
Multiple commitsDescriptive 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
\n
:
For the full template, please refer to
references/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
--body
parameter directly. You must first write the content to a temporary file, then use
--body-file
to read the content to avoid line breaks being escaped as
\n
strings.
bash
# 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 complete
PowerShell 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.md
Bash 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.md
Common Options:
OptionDescription
--body-file <file>
Read PR description from file (recommended)
--draft
Create draft PR
--reviewer <users>
Specify reviewers (comma separated)
--assignee <users>
Specify assignee
--label <labels>
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,baseRefName

Step 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
    gh
    tool is installed and logged in

Examples

Example 1: PR does not exist - Create new PR

User request: "Help me create a PR to develop"
Execution flow:
  1. Check PR:
    gh pr view
    → Error "no pull requests found"
  2. Judgment: PR does not exist, enter creation flow
  3. Pre-check: Confirm that the branch is on the remote
  4. Get commits:
    git --no-pager log --oneline develop..HEAD
  5. Analyze changes to generate title and description
  6. 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:
  1. Check PR:
    gh pr view --json number,title,state
    json
    {"number": 42, "title": "feat: 新增登入功能", "state": "OPEN"}
  2. Judgment: PR already exists, enter modification flow
  3. Report: "There is already PR #42 'feat: 新增登入功能' for this branch, what modification do you want to make?"
  4. 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:
  1. Check PR:
    gh pr view --json number,title,state
    json
    {"number": 38, "title": "feat: 舊功能", "state": "MERGED"}
  2. Judgment: PR has been merged
  3. 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

  • references/pr-template.md
    - PR description template and writing guide
  • references/gh-pr-commands.md
    - Complete reference for GitHub CLI PR related commands