create-pr-from-spec

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Create Pull Request from Specification

从规格文档创建Pull Request

Create a GitHub Pull Request for a specification using the pull_request_template.md template located at
${workspaceFolder}/.github/pull_request_template.md
.
使用位于
${workspaceFolder}/.github/pull_request_template.md
的pull_request_template.md模板,为规格文档创建GitHub Pull Request。

Overview

概述

This skill automates the creation of GitHub Pull Requests directly from specifications. It follows a structured process:
  1. Analyzes the specification template requirements
  2. Creates a draft PR with the target branch
  3. Verifies no duplicate PRs exist
  4. Updates PR body and title with template-compliant content
  5. Marks PR as ready for review
  6. Automatically assigns to the creator
  7. Returns PR URL to user
Key Benefits:
  • ✅ Automated PR creation from specifications
  • ✅ Template-compliant PR body and title
  • ✅ Duplicate PR prevention
  • ✅ Auto-assignment to creator
  • ✅ Streamlined spec-to-PR workflow
本技能可直接从规格文档自动创建GitHub Pull Request,遵循以下结构化流程:
  1. 分析规格模板要求
  2. 创建指向目标分支的草稿PR
  3. 验证不存在重复PR
  4. 使用符合模板要求的内容更新PR正文和标题
  5. 将PR标记为待审核状态
  6. 自动分配给创建者
  7. 向用户返回PR URL
核心优势:
  • ✅ 从规格文档自动创建PR
  • ✅ 符合模板要求的PR正文和标题
  • ✅ 防止重复PR
  • ✅ 自动分配给创建者
  • ✅ 简化规格文档转PR的工作流

When to Use

适用场景

Use this skill when:
  1. Specification is ready to merge - Convert finalized spec to PR
  2. Need automated PR creation - Avoid manual PR drafting
  3. Template compliance required - Ensure PR follows pull_request_template.md
  4. Multiple PRs from specs - Batch process specifications into PRs
  5. Team collaboration - Share specs as PRs for review
Trigger phrases:
  • "Create pull request from spec"
  • "Convert spec to PR"
  • "Open PR for specification"
  • "Submit spec as pull request"
  • "Automate PR creation"
在以下场景使用本技能:
  1. 规格文档已准备好合并 - 将定稿的规格文档转换为PR
  2. 需要自动创建PR - 避免手动起草PR
  3. 要求符合模板规范 - 确保PR遵循pull_request_template.md
  4. 从多个规格文档创建PR - 批量将规格文档处理为PR
  5. 团队协作 - 将规格文档以PR形式分享以便审核
触发短语:
  • "从规格文档创建Pull Request"
  • "将规格文档转换为PR"
  • "为规格文档开启PR"
  • "提交规格文档作为Pull Request"
  • "自动创建PR"

Instructions

操作说明

Prerequisites

前提条件

Before using this skill, ensure:
  • Specification file is finalized and ready for review
  • Target branch is specified (e.g.,
    main
    ,
    develop
    )
  • .github/pull_request_template.md
    exists in the repository
  • You have write access to create PRs
使用本技能前,请确保:
  • 规格文档已定稿并准备好审核
  • 指定了目标分支(例如:
    main
    develop
  • 仓库中存在
    .github/pull_request_template.md
    文件
  • 您拥有创建PR的写入权限

Step-by-Step Process

分步流程

1. Analyze specification template
  • Extract requirements from
    ${workspaceFolder}/.github/pull_request_template.md
  • Use search tool to parse template sections and placeholders
2. Create pull request draft
  • Use
    create_pull_request
    tool to create draft PR to target branch
  • First verify no existing PR exists using
    get_pull_request
    to prevent duplicates
  • If PR already exists, stop and report to user
3. Get pull request changes
  • Use
    get_pull_request_diff
    tool to analyze differences
  • Verify code changes are correct before updating
4. Update pull request
  • Use
    update_pull_request
    tool to populate PR body and title
  • Incorporate template sections from step 1
  • Ensure all required fields are filled
5. Mark ready for review
  • Use
    update_pull_request
    tool to change state from draft to ready for review
  • Verify PR is no longer in draft mode
6. Assign pull request
  • Use
    get_me
    to retrieve current user information
  • Use
    update_issue
    tool to assign PR to creator
7. Return pull request URL
  • Provide user with clickable PR URL
  • Include summary of PR contents
1. 分析规格模板
  • ${workspaceFolder}/.github/pull_request_template.md
    提取要求
  • 使用搜索工具解析模板章节和占位符
2. 创建Pull Request草稿
  • 使用
    create_pull_request
    工具创建指向目标分支的草稿PR
  • 首先使用
    get_pull_request
    工具检查是否存在现有PR,以防止重复
  • 如果PR已存在,则停止操作并向用户报告
3. 获取Pull Request变更内容
  • 使用
    get_pull_request_diff
    工具分析差异
  • 在更新前验证代码变更是否正确
4. 更新Pull Request
  • 使用
    update_pull_request
    工具填充PR正文和标题
  • 整合步骤1中的模板章节
  • 确保所有必填字段已填写
5. 标记为待审核
  • 使用
    update_pull_request
    工具将状态从草稿改为待审核
  • 验证PR不再处于草稿模式
6. 分配Pull Request
  • 使用
    get_me
    工具获取当前用户信息
  • 使用
    update_issue
    工具将PR分配给创建者
7. 返回Pull Request URL
  • 向用户提供可点击的PR URL
  • 包含PR内容摘要

Examples

示例

Example 1: Basic PR Creation

示例1:基础PR创建

bash
Input: Create PR from spec to main branch
Process:
  1. Analyze pull_request_template.md
  2. Create draft PR to main
  3. Check for existing PRs
  4. Update PR title: "feat: [Feature Name from Spec]"
  5. Update PR body with template sections
  6. Mark as ready for review
  7. Assign to creator
Output: https://github.com/user/repo/pull/123
bash
输入:从规格文档创建指向main分支的PR
流程:
  1. 分析pull_request_template.md
  2. 创建指向main的草稿PR
  3. 检查是否存在现有PR
  4. 更新PR标题:"feat: [来自规格文档的功能名称]"
  5. 使用模板章节更新PR正文
  6. 标记为待审核
  7. 分配给创建者
输出:https://github.com/user/repo/pull/123

Example 2: Template-Compliant PR

示例2:符合模板规范的PR

markdown
PR Title: feat: Implement user authentication system

PR Body:
markdown
PR标题:feat: 实现用户认证系统

PR正文:

Description

描述

Implements JWT-based authentication with token refresh mechanism
实现基于JWT的认证机制,包含令牌刷新功能

Related Issue

相关问题

Closes #456
关闭 #456

Changes

变更内容

  • Added JWT middleware
  • Implemented token validation
  • Added refresh token endpoint
  • 添加JWT中间件
  • 实现令牌验证
  • 添加刷新令牌端点

Testing

测试

  • Unit tests for auth middleware
  • Integration tests for token endpoints
  • 认证中间件的单元测试
  • 令牌端点的集成测试

Checklist

检查清单

  • Tests pass
  • Documentation updated
  • No breaking changes
undefined
  • 测试通过
  • 文档已更新
  • 无破坏性变更
undefined

Example 3: Duplicate Prevention

示例3:重复PR预防

bash
Input: Create PR from spec
Check: PR for current branch already exists?
  → Yes: Report error, don't create duplicate
  → No: Proceed with PR creation
Output: "PR already exists at https://github.com/user/repo/pull/789"
bash
输入:从规格文档创建PR
检查:当前分支是否已存在PR?
  → 是:报告错误,不创建重复PR
  → 否:继续创建PR
输出:"PR已存在,链接为https://github.com/user/repo/pull/789"

Requirements

要求

  • Single pull request for the complete specification
  • Clear title and body identifying the specification/feature
  • Pull request body follows pull_request_template.md structure
  • Verification that no duplicate pull requests exist
  • PR automatically assigned to creator
  • No draft PRs left behind
  • 为完整的规格文档创建单个Pull Request
  • 清晰的标题和正文,明确标识规格文档/功能
  • Pull Request正文遵循pull_request_template.md结构
  • 验证不存在重复的Pull Request
  • PR自动分配给创建者
  • 不遗留草稿PR

Success Criteria

成功标准

  • ✅ PR created without errors
  • ✅ PR body follows pull_request_template.md structure
  • ✅ PR title clearly identifies the specification/feature
  • ✅ No duplicate PRs exist for the branch
  • ✅ PR assigned to creator
  • ✅ PR URL returned to user
  • ✅ PR is ready for review (not in draft)
  • ✅ PR创建无错误
  • ✅ PR正文遵循pull_request_template.md结构
  • ✅ PR标题清晰标识规格文档/功能
  • ✅ 该分支不存在重复PR
  • ✅ PR已分配给创建者
  • ✅ 向用户返回PR URL
  • ✅ PR处于待审核状态(非草稿)

Constraints and Warnings

约束与警告

⚠️ Important:
  • PR creation requires write access to repository
  • Target branch must exist before PR creation
  • Template file must exist at
    .github/pull_request_template.md
  • Cannot create PR without valid branch target
  • Duplicate PRs will be detected and rejected
  • PR assignment requires valid GitHub user
🚫 Limitations:
  • Does not perform code review automatically
  • Does not trigger CI/CD pipelines
  • Does not merge PRs automatically
  • Cannot modify existing code, only PR metadata
⚠️ 重要提示:
  • 创建PR需要仓库的写入权限
  • 创建PR前目标分支必须存在
  • 模板文件必须位于
    .github/pull_request_template.md
  • 无有效目标分支则无法创建PR
  • 会检测并拒绝重复PR
  • PR分配需要有效的GitHub用户
🚫 限制:
  • 不会自动执行代码审核
  • 不会触发CI/CD流水线
  • 不会自动合并PR
  • 仅能修改PR元数据,无法修改现有代码

Best Practices

最佳实践

  1. Verify before creating - Always review specification before converting to PR
  2. Use descriptive titles - PR titles should clearly indicate feature/fix purpose
  3. Complete template - Ensure all required template sections are filled
  4. Link related issues - Include issue references in PR body
  5. Test first - Ensure all tests pass before creating PR
  6. Team review - Get team approval before marking ready for review
  7. Clean git history - Ensure commits are clean and well-documented
  1. 创建前验证 - 转换为PR前务必审核规格文档
  2. 使用描述性标题 - PR标题应清晰说明功能/修复的用途
  3. 完成模板 - 确保填写所有必填模板章节
  4. 关联相关问题 - 在PR正文中包含问题引用
  5. 先测试 - 创建PR前确保所有测试通过
  6. 团队审核 - 标记为待审核前获得团队批准
  7. 清理Git历史 - 确保提交记录清晰且文档完善

Tools Used

使用的工具

  • search
    - Analyze specification template requirements
  • create_pull_request
    - Create new PR in draft mode
  • get_pull_request
    - Check for existing PRs before creation
  • get_pull_request_diff
    - Analyze PR changes
  • update_pull_request
    - Update PR title, body, and state
  • update_issue
    - Assign PR to creator
  • get_me
    - Retrieve current user information
  • search
    - 分析规格模板要求
  • create_pull_request
    - 创建草稿模式的新PR
  • get_pull_request
    - 创建前检查是否存在现有PR
  • get_pull_request_diff
    - 分析PR变更内容
  • update_pull_request
    - 更新PR标题、正文和状态
  • update_issue
    - 将PR分配给创建者
  • get_me
    - 获取当前用户信息