Loading...
Loading...
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).
npx skill4agent add gn00678465/agentskills pull-requestUser 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 the current branch already has a PR
gh pr view --json number,title,state,url| 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 |
# 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)git push -u origin <current branch>maingit --no-pager log --oneline <target branch>..<current branch>git --no-pager show <commit-hash> --stat| Scenario | Title Strategy |
|---|---|
| Single commit | Use the commit message directly |
| Multiple commits | Descriptive title summarizing all changes |
\nFor the full template, please refer toreferences/pr-template.md
### 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.]--body--body-file\n# 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# 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# 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| Option | Description |
|---|---|
| Read PR description from file (recommended) |
| Create draft PR |
| Specify reviewers (comma separated) |
| Specify assignee |
| Add labels |
gh pr view --json number,title,body,state,url,headRefName,baseRefNamegh pr edit <PR number or URL> --title "<new title>"gh pr edit <PR number or URL> --body "<new description>"gh pr edit <PR number or URL> --add-reviewer <users>
gh pr edit <PR number or URL> --add-label <labels># List PRs of current repo
gh pr list
# View details of specific PR
gh pr view <PR number>mainghgh pr viewgit --no-pager log --oneline develop..HEADgh pr create --base develop --head feature/login --title "feat: 實作使用者登入功能" --body "..."gh pr view --json number,title,state{"number": 42, "title": "feat: 新增登入功能", "state": "OPEN"}gh pr edit 42 --title "修正購物車計算錯誤"gh pr view --json number,title,state{"number": 38, "title": "feat: 舊功能", "state": "MERGED"}references/pr-template.mdreferences/gh-pr-commands.md