用途
github-pr 用于在创建 Pull Request 时保持高质量与一致性。触发场景包括:创建新的 Pull Request、编写 PR 标题和描述、准备提交以供审查,以及使用 gh CLI 的 gh pr create 命令。
主要能力
该技能围绕两个核心规范展开:
-
PR 标题 = 约定式提交(Conventional Commit)
格式为
<type>(<scope>): <short description>,其中 type 包括:- feat:新功能
- fix:缺陷修复
- docs:文档
- refactor:代码重构
- test:添加测试
- chore:维护性工作
-
PR 描述结构
推荐使用如下 Markdown 结构:
## Summary - 1-3 bullet points explaining WHAT and WHY ## Changes - List main changes ## Testing - [ ] Tests added/updated - [ ] Manual testing done Closes #123
此外还强调原子提交:每个提交只做一件事。例如:
# Good: One thing per commit
git commit -m "feat(user): add User model"
git commit -m "feat(user): add UserService"
git commit -m "test(user): add UserService tests"
# Bad: Everything in one commit
git commit -m "add user feature"
使用方式
技能提供了多种 gh pr create 命令示例:
基础 PR 创建
gh pr create \
--title "feat(auth): add OAuth2 login" \
--body "## Summary
- Add Google OAuth2 authentication
## Changes
- Added AuthProvider component
- Created useAuth hook
Closes #42"
使用 HEREDOC 编写复杂描述
gh pr create --title "feat(dashboard): add analytics" --body "$(cat <<'EOF'
## Summary
- Add real-time analytics dashboard
## Changes
- Created AnalyticsProvider
- Added LineChart, BarChart components
## Testing
- [x] Unit tests for components
- [x] Manual testing complete
## Screenshots

Closes #123
EOF
)"
草稿 PR
gh pr create --draft \
--title "wip: refactor auth" \
--body "Work in progress"
指定审查者与标签
gh pr create \
--title "feat(api): add rate limiting" \
--body "Adds rate limiting to API" \
--reviewer "user1,user2" \
--label "enhancement,api"
常用命令
# Create PR
gh pr create --title "type(scope): desc" --body "..."
# Create with web editor
gh pr create --web
# View PR status
gh pr status
# View diff
gh pr diff
# Check CI status
gh pr checks
# Merge with squash
gh pr merge --squash
# Add reviewer
gh pr edit --add-reviewer username
反模式
技能明确列出应避免的做法:
- 模糊标题:如
fix bug、update;应改为fix(auth): prevent session timeout。 - 巨型 PR:如 50 个文件、2000+ 行放在一个 PR 中;应拆分为逻辑独立的 PR,例如先加模型、再加 API、最后加 UI。
- 空描述:如仅写
Added feature;应包含 Summary、Changes 和 Closes #123。
速查表
| 任务 | 命令 |
|---|---|
| 创建 PR | gh pr create -t "type: desc" -b "body" |
| 草稿 PR | gh pr create --draft |
| Web 编辑器 | gh pr create --web |
| 添加审查者 | --reviewer user1,user2 |
| 添加标签 | --label bug,high-priority |
| 关联 issue | 在 body 中写 Closes #123 |
| 查看状态 | gh pr status |
| 压缩合并 | gh pr merge --squash |
适用场景
适用于任何使用 GitHub 与 gh CLI 进行协作开发的团队或个人,尤其适合需要统一 PR 规范、提升代码审查效率、保持提交历史清晰的场景。
限制
资料未提供该技能的安装方式、依赖要求、平台限制或收费信息,暂未提供。