AgentSkillsCN

gh-pr-create

在 git-incremental-commits 生成整洁的工作树后,使用 gh CLI 创建 GitHub Pull Request。适用于被要求打开 PR、在提交后创建 PR,或“制作 PR”时使用。自动生成包含摘要、主要变更、可选截图、可选测试,以及可选附加信息的 PR 内容。

SKILL.md
--- frontmatter
name: gh-pr-create
description: Create a GitHub Pull Request using the gh CLI after git-incremental-commits has produced a clean working tree. Use when asked to open a PR, create a PR after committing, or "make a PR". Generates a PR body with Summary, Major changes, optional Screenshots, optional Tests, and optional Additional info.

GitHub PR Create (gh)

Goal

After $git-incremental-commits finishes (working tree clean), push the branch and open a PR with a consistent body format.

Preconditions

  • Repo is on a non-main/master branch.
  • git status -sb is clean.
  • gh is installed and authenticated (gh auth status).

Workflow

  1. Verify working tree is clean.

    • git status -sb
    • Stop if there are uncommitted changes.
  2. Confirm you are on a branch suitable for a PR.

    • git branch --show-current
    • If on main/master or detached HEAD: stop and create/switch to a branch.
  3. Ensure the branch is pushed.

    • If no upstream is set: git push -u origin HEAD
    • Otherwise: git push
  4. Determine PR base branch.

    • Prefer the repo default branch: gh repo view --json defaultBranchRef -q .defaultBranchRef.name
  5. Write a PR body in this format (human summary, not diffstats).

  • Include these headings exactly:

    1. ## Summary
    2. ## Major changes
  • Conditionally include these headings:

    • ## Screenshots: include only if relevant (UI changes or image diffs).
    • ## Tests: include only if the repo has a configured test command/CI expectation.
    • ## Additional info: include only if there is something non-obvious to call out (follow-ups, rollout notes, risks).
  1. Open the PR with gh pr create.
  • Title:

    • Default to a summarized Conventional Commit style title derived from the branch commits (e.g. Feat: ..., Fix: ..., Docs: ...).
    • Override with PR_TITLE="..." if needed.
  • Body:

    • Use --body or --body-file:
      • gh pr create --title "..." --body-file /tmp/pr-body.md

Notes

  • Keep the PR body concise but specific.
  • If there are multiple major changes, list them as bullets under ## Major changes.
  • If tests are not configured, omit the entire ## Tests section (do not include an empty heading).
  • Avoid including raw git diff --stat output in ## Summary (GitHub already provides file-level diff context).