AgentSkillsCN

git-pr

有效创建Pull Request的指南。当你需要开启PR、撰写PR描述、请求他人评审,或管理PR工作流时,这一技能将为你提供专业建议。

SKILL.md
--- frontmatter
name: git-pr
description: Guide for creating effective Pull Requests. Use when opening PRs, writing PR descriptions, requesting reviews, or managing PR workflow.

Git Pull Requests

This skill provides guidance for creating clear, reviewable Pull Requests that facilitate efficient code review.

When to Use This Skill

  • Opening a new Pull Request
  • Writing PR titles and descriptions
  • Choosing merge strategy
  • Managing PR workflow

Branch Naming

PrefixUse CaseExample
feature/New featuresfeature/user-auth
fix/Bug fixesfix/login-crash
hotfix/Urgent production fixeshotfix/security-patch
release/Release preparationrelease/v2.1.0
docs/Documentationdocs/api-guide
refactor/Code refactoringrefactor/auth-module

Naming Rules:

  • Lowercase with hyphens
  • Include ticket number if available: feature/JIRA-123-user-auth
  • Keep short but descriptive

PR Title

Follow the same format as commit messages:

code
<type>(<scope>): <description>

Examples:

code
feat(auth): add OAuth2 login support
fix(cart): resolve duplicate item bug
docs: update API documentation

PR Description Template

markdown
## Summary
Brief description of what this PR does.

## Changes
- Change 1
- Change 2
- Change 3

## Type of Change
- [ ] Bug fix (non-breaking change fixing an issue)
- [ ] New feature (non-breaking change adding functionality)
- [ ] Breaking change (fix or feature causing existing functionality to change)
- [ ] Documentation update

## Testing
- [ ] Unit tests pass
- [ ] Integration tests pass
- [ ] Manual testing completed

## Screenshots (if applicable)
[Add screenshots here]

## Related Issues
Closes #123

PR Size Guidelines

SizeLines ChangedReview TimeRecommendation
XS< 50~10 min✅ Ideal
S50-200~30 min✅ Good
M200-400~1 hour⚠️ Consider splitting
L400-800~2 hours⚠️ Split if possible
XL> 800Hours❌ Split required

[!TIP] Smaller PRs get reviewed faster and have fewer bugs. Aim for < 400 lines.

Draft vs Ready

StateWhen to Use
DraftWork in progress, not ready for review
ReadyComplete, tested, ready for review
bash
# Create as draft
gh pr create --draft

# Mark ready for review
gh pr ready

Requesting Reviews

Choose reviewers who:

  • Own the code area being changed
  • Have context on the feature/issue
  • Are available (check workload)

Minimum reviewers:

  • Small changes: 1 reviewer
  • Medium changes: 2 reviewers
  • Large/critical changes: 2-3 reviewers

Merge Strategies

StrategyUse WhenCommit History
Merge commitPreserving full historyAll commits + merge commit
Squash and mergeMany small commitsSingle commit
Rebase and mergeClean, linear historyIndividual commits, no merge

Recommendations:

  • Default: Squash and merge for feature branches
  • Use Rebase for clean, well-organized commits
  • Use Merge commit when history matters

Resolving Conflicts

bash
# Update your branch with target
git fetch origin
git rebase origin/main
# OR
git merge origin/main

# Resolve conflicts in files
# Then continue
git rebase --continue
# OR
git merge --continue

# Force push (if rebased)
git push --force-with-lease

Decision Tree

code
PR Workflow
├── Create branch
│   └── Use naming convention: feature/, fix/, etc.
├── Make changes
│   └── Commit using Conventional Commits
├── Open PR
│   ├── Work in progress → Create as Draft
│   └── Ready for review → Create as Ready
├── Get reviews
│   ├── Changes requested → Address feedback, re-request
│   └── Approved → Proceed to merge
└── Merge
    ├── Many small commits → Squash and merge
    ├── Clean commit history → Rebase and merge
    └── Need full history → Merge commit

Common Mistakes

MistakeSolution
Huge PR (>500 lines)Split into smaller, focused PRs
Vague title "Fix stuff"Use descriptive title with type
No descriptionAlways explain what and why
Merging without reviewWait for required approvals
Not resolving conflictsUpdate branch before merging

GitHub CLI Commands

bash
# Create PR
gh pr create --title "feat: add feature" --body "Description"

# Create draft PR
gh pr create --draft

# View PR status
gh pr status

# Request review
gh pr edit --add-reviewer username

# Merge PR
gh pr merge --squash

# Close PR
gh pr close

Resources

  • PR Template - Copy to .github/PULL_REQUEST_TEMPLATE.md in your repo

Related Skills