AgentSkillsCN

github-create-pr

使用 gh CLI 创建 GitHub Pull Request。当用户希望发起 PR、提交更改以供评审,或从其分支创建拉取请求时,可使用此技能。支持自定义 PR 标题、正文内容,并允许用户选择目标分支。

SKILL.md
--- frontmatter
name: github-create-pr
description: Create a GitHub Pull Request using the gh CLI. Use when the user wants to open a PR, submit changes for review, or create a pull request from their branch. Handles PR creation with title, body, and target branch selection.

GitHub Create PR

Create a GitHub Pull Request using the gh CLI.

When to Use

  • Ready to submit changes for review
  • Need to create a pull request
  • Any request to "open PR", "create PR", or "submit for review"

Prerequisites

Ensure gh CLI is installed and authenticated:

bash
gh --version
gh auth status

If not authenticated:

bash
gh auth login

Workflow

1. Check Branch Status

bash
git status
git branch --show-current
git log --oneline -5

2. Push Branch (if needed)

bash
git push -u origin HEAD

3. Create the PR

Quick creation with defaults:

bash
gh pr create

With custom title:

bash
gh pr create --title "feat: add user authentication"

With title and body:

bash
gh pr create --title "feat: add user authentication" --body "Implements OAuth2 login flow with support for Google and GitHub providers."

Fill from commit messages:

bash
gh pr create --fill

Target specific base branch:

bash
gh pr create --base main

4. Copy PR URL

After creation, the PR URL is printed. You can also get it with:

bash
gh pr view --json url --jq '.url'

Common Options

FlagDescription
--titlePR title
--bodyPR description
--fillUse commit message as title/body
--baseTarget branch (default: repo default)
--headSource branch (default: current)
--draftCreate as draft PR
--labelAdd labels
--assigneeAssign to user(s)
--reviewerRequest reviewer(s)

Examples

Create draft PR:

bash
gh pr create --draft --title "WIP: refactor API"

Add labels and reviewer:

bash
gh pr create --title "fix: resolve memory leak" --label "bug" --reviewer "@username"

Use template:

bash
gh pr create --template="feature.md"

Best Practices

  • Push branch before creating PR
  • Write clear, descriptive titles
  • Include context in body (what changed, why)
  • Reference related issues: Closes #123
  • Add appropriate labels
  • Request reviewers
  • Use draft PRs for work-in-progress