pr-creator

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Pull Request Creator

拉取请求创建工具

This skill guides the creation of high-quality Pull Requests that adhere to the repository's standards.
此技能可指导创建符合仓库标准的高质量拉取请求(PR)。

Workflow

工作流程

Follow these steps to create a Pull Request:
  1. Branch Management: Check the current branch to avoid working directly on
    main
    .
    • Run
      git branch --show-current
      .
    • If the current branch is
      main
      , create and switch to a new descriptive branch:
      bash
      git checkout -b <new-branch-name>
  2. Locate Template: Search for a pull request template in the repository.
    • Check
      .github/pull_request_template.md
    • Check
      .github/PULL_REQUEST_TEMPLATE.md
    • If multiple templates exist (e.g., in
      .github/PULL_REQUEST_TEMPLATE/
      ), ask the user which one to use or select the most appropriate one based on the context (e.g.,
      bug_fix.md
      vs
      feature.md
      ).
  3. Read Template: Read the content of the identified template file.
  4. Draft Description: Create a PR description that strictly follows the template's structure.
    • Headings: Keep all headings from the template.
    • Checklists: Review each item. Mark with
      [x]
      if completed. If an item is not applicable, leave it unchecked or mark as
      [ ]
      (depending on the template's instructions) or remove it if the template allows flexibility (but prefer keeping it unchecked for transparency).
    • Content: Fill in the sections with clear, concise summaries of your changes.
    • Related Issues: Link any issues fixed or related to this PR (e.g., "Fixes #123").
  5. Preflight Check: Before creating the PR, run the workspace preflight script to ensure all build, lint, and test checks pass.
    bash
    npm run preflight
    If any checks fail, address the issues before proceeding to create the PR.
  6. Create PR: Use the
    gh
    CLI to create the PR. To avoid shell escaping issues with multi-line Markdown, write the description to a temporary file first.
    bash
    # 1. Write the drafted description to a temporary file
    # 2. Create the PR using the --body-file flag
    gh pr create --title "type(scope): succinct description" --body-file <temp_file_path>
    # 3. Remove the temporary file
    rm <temp_file_path>
    • Title: Ensure the title follows the Conventional Commits format if the repository uses it (e.g.,
      feat(ui): add new button
      ,
      fix(core): resolve crash
      ).
按照以下步骤创建拉取请求:
  1. 分支管理:检查当前分支,避免直接在
    main
    分支上工作。
    • 运行
      git branch --show-current
      命令。
    • 如果当前分支是
      main
      ,创建并切换到一个具有描述性的新分支:
      bash
      git checkout -b <new-branch-name>
  2. 查找模板:在仓库中搜索拉取请求模板。
    • 检查
      .github/pull_request_template.md
      文件
    • 检查
      .github/PULL_REQUEST_TEMPLATE.md
      文件
    • 如果存在多个模板(例如在
      .github/PULL_REQUEST_TEMPLATE/
      目录下),询问用户使用哪个模板,或者根据上下文选择最合适的模板(例如
      bug_fix.md
      feature.md
      )。
  3. 阅读模板:读取找到的模板文件内容。
  4. 撰写描述草稿:严格按照模板结构创建PR描述。
    • 标题:保留模板中的所有标题。
    • 复选清单:检查每一项。已完成的项标记为
      [x]
      。如果某一项不适用,可保持未勾选状态或标记为
      [ ]
      (取决于模板说明),如果模板允许灵活调整也可删除该项(但为了透明性,建议保持未勾选状态)。
    • 内容:在各个部分填写清晰、简洁的变更摘要。
    • 相关问题:关联此PR修复或涉及的所有问题(例如:"Fixes #123")。
  5. 预检检查:创建PR之前,运行工作区预检脚本,确保所有构建、代码检查和测试都能通过。
    bash
    npm run preflight
    如果有任何检查未通过,请先解决问题,再继续创建PR。
  6. 创建PR:使用
    gh
    CLI工具创建PR。为避免多行Markdown的shell转义问题,请先将描述写入临时文件。
    bash
    # 1. Write the drafted description to a temporary file
    # 2. Create the PR using the --body-file flag
    gh pr create --title "type(scope): succinct description" --body-file <temp_file_path>
    # 3. Remove the temporary file
    rm <temp_file_path>
    • 标题:如果仓库使用Conventional Commits格式,请确保标题符合该格式(例如:
      feat(ui): add new button
      fix(core): resolve crash
      )。

Principles

原则

  • Compliance: Never ignore the PR template. It exists for a reason.
  • Completeness: Fill out all relevant sections.
  • Accuracy: Don't check boxes for tasks you haven't done.
  • 合规性:切勿忽略PR模板,它的存在是有原因的。
  • 完整性:填写所有相关部分。
  • 准确性:不要为未完成的任务勾选复选框。