mcpField
C
create-pr

create-pr

github.com/davila7开发33.1k314 次安装今天更新
代码仓库

关于 create-pr

用于按照 Sentry 工程实践创建 GitHub 拉取请求的技能,涵盖分支检查、变更分析、描述撰写、创建 PR 和请求评审者,并要求使用已认证的 GitHub CLI。

主要功能

  1. 01检查分支状态和提交
  2. 02审阅待提交的差异
  3. 03组织 PR 描述
  4. 04使用 gh 创建 PR
  5. 05请求评审者

适用场景

  1. 01准备功能或修复类 PR
  2. 02说明变更及其原因
  3. 03在 PR 中关联相关问题
  4. 04指定已知评审者

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/davila7/claude-code-templates --skill create-pr

安装后在 Claude Code 中输入/create-pr确认已加载。

详细介绍

创建 Pull Request

按照 Sentry 的工程实践创建 pull request。

要求:GitHub CLI(gh)已完成认证并可用。

流程

第 1 步:验证分支状态
# Check current branch and status
git status
git log main..HEAD --oneline

确保:

  • 所有更改都已提交
  • 分支与远程保持同步
  • 如有需要,更改已 rebase 到 main
第 2 步:分析更改

审查将包含在 PR 中的内容:

# See all commits that will be in the PR
git log main..HEAD

# See the full diff
git diff main...HEAD

在撰写描述之前,先理解所有更改的范围和目的。

第 3 步:撰写 PR 描述

遵循以下结构:

<brief description of what the PR does>

<why these changes are being made - the motivation>

<alternative approaches considered, if any>

<any additional context reviewers need>

不要包含:

  • “Test plan”部分
  • 测试步骤的复选框列表
  • 对 diff 的冗余总结

要包含:

  • 对做了什么以及为什么的清晰解释
  • 指向相关 issue 或工单的链接
  • 从代码中不易看出的背景信息
  • 关于需要仔细审查的具体区域的说明
第 4 步:创建 PR
gh pr create --title "<type>(<scope>): <description>" --body "$(cat <<'EOF'
<description body here>
EOF
)"

标题格式遵循 commit 约定:

  • feat(scope): Add new feature
  • fix(scope): Fix the bug
  • ref: Refactor something
第 5 步:添加审查者(如已知)
# Request review from specific people
gh pr edit --add-reviewer username1,username2

# Or request from a team
gh pr edit --add-reviewer @getsentry/team-name

限制为 1-3 名审查者,以保持明确的归属。

PR 描述示例

功能 PR
Add Slack thread replies for alert notifications

When an alert is updated or resolved, we now post a reply to the original
Slack thread instead of creating a new message. This keeps related
notifications grouped and reduces channel noise.

Previously considered posting edits to the original message, but threading
better preserves the timeline of events and works when the original message
is older than Slack's edit window.

Refs SENTRY-1234
Bug 修复 PR
Handle null response in user API endpoint

The user endpoint could return null for soft-deleted accounts, causing
dashboard crashes when accessing user properties. This adds a null check
and returns a proper 404 response.

Found while investigating SENTRY-5678.

Fixes SENTRY-5678
重构 PR
Extract validation logic to shared module

Moves duplicate validation code from the alerts, issues, and projects
endpoints into a shared validator class. No behavior change.

This prepares for adding new validation rules in SENTRY-9999 without
duplicating logic across endpoints.

Issue 引用

在 PR 正文中引用 issue:

语法效果
Fixes #1234合并时关闭 GitHub issue
Fixes SENTRY-1234关闭 Sentry issue
Refs GH-1234仅链接,不关闭
Refs LINEAR-ABC-123链接 Linear issue

指南

  • 每个功能/修复一个 PR - 不要捆绑不相关的更改
  • 保持 PR 可审查 - 更小的 PR 能获得更快、更好的审查
  • 解释为什么 - 代码展示做了什么;描述解释为什么
  • 尽早标记 WIP - 使用草稿 PR 获取早期反馈

参考

评论

支持 Markdown