AgentSkillsCN

create-pr

当您准备提交作品以供审查时,这一工具能帮您通过gh CLI推送分支并创建PR。涵盖创建PR、提交PR、推送与PR。注意:此工具不适用于仅进行Git提交(请直接使用git),也不适用于PR审查(请使用Coderabbit)。

SKILL.md
--- frontmatter
name: create-pr
description: Use when ready to submit work for review. Pushes branch and creates PR via gh CLI. Covers create PR, submit PR, push and PR. NOT for: git commits only (use git directly), reviewing PRs (use coderabbit).
execute: scripts/create-pr.sh

Create PR

Push the current branch to origin and create a pull request against the target branch (default: main).

Prerequisites

  • gh CLI installed (brew install gh)
  • Authenticated: gh auth login
  • On a feature/fix branch (not main/master/dev)
  • All changes committed

Usage

bash
# Basic usage (auto-generates title and body from commits)
./scripts/create-pr.sh

# With custom title and body
./scripts/create-pr.sh --title "feat: add new feature" --body "Description of changes"

# Against different base branch
./scripts/create-pr.sh --base dev

Arguments

ArgumentDescriptionDefault
--titlePR titleAuto-generated from branch name
--bodyPR descriptionTemplate with summary prompt
--baseTarget branchmain

What It Does

  1. Validates branch - Ensures you're not on main/master/dev
  2. Checks for uncommitted changes - Warns if working directory is dirty
  3. Checks for existing PR - Shows existing PR if one exists
  4. Pushes branch - git push -u origin HEAD
  5. Creates PR - Using gh pr create
  6. Outputs result - Markdown with PR URL and details

Edge Cases

  • On main/dev/master branch: Exits with warning
  • Uncommitted changes: Exits with warning
  • PR already exists: Shows existing PR URL instead of creating new one

Example Output

markdown
## PR Created Successfully

**Title:** feat: add create-pr skill
**URL:** https://github.com/user/repo/pull/123
**Base:** main ← feature/create-pr

### Summary
- Pushed branch to origin
- Created PR #123

Related Skills

  • github - Full GitHub CLI reference
  • worktrees - Create isolated worktrees for features