pr-automation

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

PR Automation Skill

PR自动化技能

Automate pull request workflows to streamline PR creation and validation.
自动化拉取请求(PR)工作流,简化PR的创建与验证流程。

When to Use

适用场景

Use this skill when:
  • Before creating a PR
  • When user requests PR creation
  • Before pushing code to remote
  • After completing a feature or fix
使用本技能的场景:
  • 创建PR之前
  • 用户请求创建PR时
  • 向远程仓库推送代码之前
  • 完成功能开发或问题修复之后

Capabilities

核心能力

1. Generate PR Descriptions

1. 自动生成PR描述

Automatically generate comprehensive PR descriptions:
  • Analyze git diff to understand changes
  • Extract commit messages for context
  • Identify changed files and their purposes
  • Generate structured PR description following template
  • Include all required sections (description, changes, testing, etc.)
自动生成全面的PR描述:
  • 分析git diff以理解代码变更
  • 提取提交信息作为上下文
  • 识别变更文件及其用途
  • 遵循模板生成结构化的PR描述
  • 包含所有必填章节(描述、变更内容、测试情况等)

2. Validate PR Requirements

2. 验证PR要求

Check PR requirements before creation:
  • Verify tests exist for new features
  • Check that tests pass
  • Verify documentation is updated
  • Validate code follows project conventions
  • Check for linting errors
  • Verify formatting is correct
  • Ensure no secrets or credentials are committed
在创建PR前检查要求:
  • 验证新功能是否有对应的测试
  • 检查测试是否通过
  • 验证文档是否已更新
  • 确认代码符合项目规范
  • 检查代码检查错误
  • 验证代码格式是否正确
  • 确保没有提交机密信息或凭证

3. Check for Missing Tests/Docs

3. 检查缺失的测试与文档

Identify missing requirements:
  • Check if new features have tests
  • Verify documentation is updated
  • Check for missing type hints (Python)
  • Verify error handling is documented
  • Check for missing API documentation
识别缺失的必要内容:
  • 检查新功能是否有测试
  • 验证文档是否已更新
  • 检查是否缺失Python类型提示
  • 验证错误处理是否已文档化
  • 检查是否缺失API文档

4. Link Issues Automatically

4. 自动关联议题

Automatically link related issues:
  • Parse commit messages for issue references (#123)
  • Search for related issues based on changes
  • Add "Closes #123" or "Related to #123" to PR description
  • Link to parent issues or epics
自动关联相关议题:
  • 解析提交信息中的议题引用(#123)
  • 根据代码变更搜索相关议题
  • 在PR描述中添加"Closes #123"或"Related to #123"
  • 关联父议题或史诗级议题

5. Suggest Reviewers

5. 推荐评审人员

Suggest appropriate reviewers:
  • Based on files changed (domain expertise)
  • Based on previous reviewers of similar changes
  • Based on code owners (if CODEOWNERS file exists)
  • Based on team structure
推荐合适的评审人员:
  • 根据变更文件(领域专业知识)
  • 根据类似变更的过往评审人员
  • 根据代码所有者(如果存在CODEOWNERS文件)
  • 根据团队架构

Workflow

工作流

  1. Analyze Changes: Review git diff and commit history
  2. Generate Description: Create comprehensive PR description
  3. Run Validation: Check all PR requirements
  4. Fix Issues: Address any validation failures
  5. Create PR: Generate PR with all information
  6. Post-Creation: Add labels, assign reviewers, link issues
  1. 分析变更:查看git diff和提交历史
  2. 生成描述:创建全面的PR描述
  3. 执行验证:检查所有PR要求
  4. 修复问题:处理所有验证不通过的问题
  5. 创建PR:生成包含所有信息的PR
  6. 创建后操作:添加标签、分配评审人员、关联议题

PR Description Template

PR描述模板

Follows the template from
.cursor/rules/context-communication.mdc
:
  • Description of what changed and why
  • Related issue links
  • List of changes
  • How it was verified
  • Related code references
  • Assumptions made
  • Breaking changes (if any)
  • Testing checklist
遵循
.cursor/rules/context-communication.mdc
中的模板:
  • 变更内容及原因描述
  • 相关议题链接
  • 变更列表
  • 验证方式
  • 相关代码引用
  • 做出的假设
  • 破坏性变更(如有)
  • 测试检查清单

Related Resources

相关资源

Rules

规则

  • .cursor/rules/git-workflow.mdc
    - Git workflow and PR process
  • .cursor/rules/context-communication.mdc
    - PR description best practices
  • .cursor/rules/testing.mdc
    - Testing requirements
  • .cursor/rules/git-workflow.mdc
    - Git工作流与PR流程
  • .cursor/rules/context-communication.mdc
    - PR描述最佳实践
  • .cursor/rules/testing.mdc
    - 测试要求

Subagents

子Agent

  • .cursor/agents/pr-manager.md
    - PR management subagent
  • .cursor/agents/code-reviewer.md
    - Code review subagent
  • .cursor/agents/test-runner.md
    - Test runner subagent
  • .cursor/agents/pr-manager.md
    - PR管理子Agent
  • .cursor/agents/code-reviewer.md
    - 代码评审子Agent
  • .cursor/agents/test-runner.md
    - 测试运行子Agent

Commands

命令

  • /auto-pr
    - Generate PR with automation
  • /pr
    - Create pull request with proper description
  • /code-review
    - Review code before PR
  • /auto-pr
    - 自动生成PR
  • /pr
    - 创建带有规范描述的PR
  • /code-review
    - PR前代码评审