AgentSkillsCN

pr

推送当前分支,并创建 GitHub 拉取请求。

SKILL.md
--- frontmatter
name: pr
description: Push current branch and create a GitHub pull request.
argument-hint: "[base-branch] (default: main)"
allowed-tools: Read, Glob, Grep, Bash(git *), Bash(gh *), TodoWrite
model: haiku
user-invocable: true

/pr — Create Pull Request

Push the current branch and open a PR against: ${ARGUMENTS:-main}

Note: Use /pr for standalone PR creation outside the /implement workflow. If you're running /implement, it handles PR creation in Stage 7 — you don't need /pr separately.

Pre-flight

  1. Verify GitHub CLI is authenticated:
bash
gh auth status

If not authenticated, STOP and tell the user to run gh auth login.

  1. Verify not on main/master:
bash
BRANCH=$(git branch --show-current)
if [ "$BRANCH" = "main" ] || [ "$BRANCH" = "master" ]; then
  echo "ERROR: Cannot create PR from $BRANCH. Switch to a feature branch first."
  exit 1
fi
  1. Verify a remote exists:
bash
git remote get-url origin 2>/dev/null || echo "ERROR: No remote 'origin'. Add one with: git remote add origin <url>"

If no remote, STOP and tell the user.

  1. Check for uncommitted changes:
bash
git status --porcelain

If uncommitted changes exist, ask the user whether to commit them first.

  1. Check if PR already exists:
bash
gh pr view --json url --jq '.url' 2>/dev/null

If a PR already exists, report its URL and ask if the user wants to update it.

Create PR

  1. Push the branch:
bash
git push -u origin $(git branch --show-current)
  1. Gather context for the PR description:
bash
git log ${ARGUMENTS:-main}..HEAD --oneline
git diff ${ARGUMENTS:-main}..HEAD --stat
  1. Create the PR. If the branch name matches task/<number>, include Closes #<number> in the body:
bash
gh pr create \
  --base ${ARGUMENTS:-main} \
  --title "<concise title from commit messages>" \
  --body "## Summary
<bullet points summarizing the changes>

## Changes
<output of git diff --stat>

Closes #<number-if-applicable>"

Post-create

  1. Report the PR URL:
bash
gh pr view --json url --jq '.url'
  1. Tell the user: "PR created. Run /review <branch> for an agent review, or /dod <task-id> to run all gates."