SuperAPI AI 工具集

create-pr

编程与开发

查看项目

更新于 10-15 15:16

技能介绍

用途

create-pr 用于在 n8n 仓库中创建 GitHub Pull Request,并确保 PR 标题能够通过 n8n 的 check-pr-title CI 校验。它适用于创建 PR、提交变更以供审查等场景。

主要能力

PR 标题格式

标题格式为:

<type>(<scope>): <summary>

类型(必填)

类型 说明 是否进入 Changelog
feat 新功能 是
fix Bug 修复 是
perf 性能改进 是
test 添加/修正测试 否
docs 仅文档 否
refactor 代码变更(非 Bug 修复或新功能) 否
build 构建系统或依赖 否
ci CI 配置 否
chore 日常任务、维护 否

范围(可选但推荐)

  • API - 公共 API 变更
  • benchmark - Benchmark CLI 变更
  • core - 核心/后端/私有 API
  • editor - 编辑器 UI 变更
    • Node - 特定节点(例如 Slack Node、GitHub Node)

摘要规则

  • 使用祈使句现在时:用 "Add" 而非 "Added"
  • 首字母大写
  • 结尾不加句号
  • 不含工单 ID(例如 N8N-1234)
  • 添加 (no-changelog) 后缀以排除出 changelog

创建步骤

  1. 检查当前状态:
git status
git diff --stat
git log origin/master..HEAD --oneline
  1. 检查实现计划:在 .claude/plans/ 中查找与当前分支工单 ID 匹配的计划文件(例如分支为 scdekov/PAY-1234-some-feature,则检查 .claude/plans/PAY-1234.md)。如果存在计划文件,询问用户是否希望将其作为可折叠的 <details> 章节加入 PR 描述(见下方计划章节)。仅在用户明确批准后才包含该计划。

  2. 如果是安全修复,在继续之前审计所有面向公众的产物(见下方安全修复)。

  3. 分析变更以确定:类型、范围、摘要。

  4. 如需要则推送分支:

git push -u origin HEAD
  1. 使用 gh CLI 配合 .github/pull_request_template.md 中的模板创建 PR:
gh pr create --draft --title "<type>(<scope>): <summary>" --body "$(cat <<'EOF'
## Summary

<Describe what the PR does and how to test. Photos and videos are recommended.>

## Related Linear tickets, Github issues, and Community forum posts

<!-- Link to Linear ticket: https://linear.app/n8n/issue/[TICKET-ID] -->
<!-- Use "closes #<issue-number>", "fixes #<issue-number>", or "resolves #<issue-number>" to automatically close issues -->

## Review / Merge checklist

- [ ] PR title and summary are descriptive. ([conventions](../blob/master/.github/pull_request_title_conventions.md))
- [ ] [Docs updated](https://github.com/n8n-io/n8n-docs) or follow-up ticket created.
- [ ] Tests included.
- [ ] PR Labeled with `release/backport` (if the PR is an urgent fix that needs to be backported)
EOF
)"

PR 正文规范

基于 .github/pull_request_template.md:

Summary 章节

  • 描述 PR 做了什么
  • 说明如何测试这些变更
  • UI 变更需包含截图/视频

Related Links 章节

  • 链接到 Linear 工单:https://linear.app/n8n/issue/[TICKET-ID]
  • 使用关键词自动关闭 GitHub issue:closes #123 / fixes #123 / resolves #123
  • 如适用,链接到社区论坛帖子

Checklist

合并前应处理所有条目:

  • PR 标题遵循规范
  • 文档已更新或已创建后续工单
  • 已包含测试(Bug 需要回归测试,功能需要覆盖率)
  • 如果紧急修复需要回移,添加 release/backport 标签

示例

编辑器中的功能:

feat(editor): Add workflow performance metrics display

核心中的 Bug 修复:

fix(core): Resolve memory leak in execution engine

节点特定变更:

fix(Slack Node): Handle rate limiting in message send

破坏性变更(在冒号前加感叹号):

feat(API)!: Remove deprecated v1 endpoints

不进入 changelog:

refactor(core): Simplify error handling (no-changelog)

无范围(影响多个区域):

chore: Update dependencies to latest versions

校验

PR 标题必须匹配以下模式:

^(feat|fix|perf|test|docs|refactor|build|ci|chore|revert)(\([a-zA-Z0-9 ]+( Node)?\))?!?: [A-Z].+[^.]$

关键校验规则:

  • 类型必须是允许的类型之一
  • 范围可选,但若存在必须放在括号中
  • 破坏性变更的感叹号放在冒号之前
  • 摘要必须以大写字母开头
  • 摘要不得以句号结尾

计划章节

如果在 .claude/plans/ 中找到匹配的计划文件且用户已批准包含它,则在 PR 正文末尾(checklist 之后、EOF 之前)添加可折叠章节:

<details>
<summary>Implementation plan</summary>

<!-- paste plan file contents here -->

</details>

安全修复

该仓库是公开的。切勿在任何公开产物中暴露攻击向量。描述代码做了什么,而不是它防范了什么威胁。

产物 错误示例 正确示例
分支 fix-sql-injection-in-webhook fix-webhook-input-validation
PR 标题 fix(core): Prevent SSRF fix(core): Validate outgoing URLs
提交信息 fix: prevent denial of service fix: add payload size validation
PR 正文 "attacker could trigger SSRF…" "validates URL protocol and host"
Linear 引用 带 slug 的 URL(泄露标题) 不带 slug 的 URL 或仅工单 ID
测试名称 'should prevent SQL injection' 'should sanitize query parameters'

在推送安全修复之前,请确认:分支名、提交、PR 标题、PR 正文、Linear URL、测试名称或代码注释均未暗示该漏洞。

适用场景

  • 在 n8n 仓库中创建新的 Pull Request
  • 提交变更以供代码审查
  • 需要确保 PR 标题通过 check-pr-title CI 校验
  • 处理安全修复时需要脱敏公开产物

限制

  • 该技能针对 n8n 仓库的 PR 规范,其他仓库的规范可能不同
  • 需要本地已安装并配置 gh CLI
  • 需要遵循 .github/pull_request_template.md 模板
  • 计划章节仅在用户明确批准后才包含