AgentSkillsCN

pr

在创建 Pull Request 时使用此技能。系统会自动在浏览器中打开 PR,方便团队成员进行审阅。

SKILL.md
--- frontmatter
name: pr
description: Use when creating a pull request. Opens PR in browser for review.
argument-hint: "[additional context]"
model: sonnet
allowed-tools:
  - Glob
  - Read

Create Pull Request

Opens a pull request in the browser for final review and submission.

Arguments

code
[additional context]

Optional context to incorporate into the PR description - details not covered in commits, important considerations, areas needing attention, or anything to emphasize for reviewers.

Instructions

1. Check for PR Template

Search for templates in order of precedence:

code
.github/pull_request_template.md
.github/PULL_REQUEST_TEMPLATE/*.md
pull_request_template.md
PULL_REQUEST_TEMPLATE/*.md
docs/pull_request_template.md
docs/PULL_REQUEST_TEMPLATE/*.md

If multiple templates exist in a PULL_REQUEST_TEMPLATE/ directory, list them and ask which to use.

2. Gather Context

Run in parallel:

  • git status - check for uncommitted changes
  • git log --oneline @{upstream}..HEAD 2>/dev/null || git log --oneline -10 - commits to include
  • git diff --stat @{upstream}..HEAD 2>/dev/null || git diff --stat HEAD~5..HEAD - files changed

If there are staged changes ready to commit, ask whether to commit first or proceed. If there are only untracked files (not relevant to the PR), proceed without asking.

3. Draft PR Content

Title: Derive from branch name or commits. Use conventional format if repo follows it.

Body: If template found, fill it in. Otherwise use:

markdown
## Why

[Problem/motivation - 1-3 sentences]

## What

[Approach - brief, not a code walkthrough]

## Notes for reviewers

[Non-obvious decisions, areas of uncertainty, or "looks wrong but isn't" explanations]

If user provided additional context in arguments, incorporate it appropriately into the PR body.

Draft the content but don't show it to the user for approval - proceed directly to creation.

4. Push and Create PR

Push first: If the branch hasn't been pushed or is behind:

bash
git push -u origin <branch-name>

Then create PR using the shim:

Default command:

bash
~/.claude/skills/pr/gh-pr-create-web --title "..." --body "..."

With template file:

bash
~/.claude/skills/pr/gh-pr-create-web --template ".github/pull_request_template.md"

The shim enforces --web flag, ensuring PRs open in browser for human review.

5. Report Result

Simply note that the PR creation command was executed. The browser will open automatically for final review.

Examples

code
/pr                                           → Standard PR, opens browser
/pr This needs careful review of the DB migrations → Emphasizes DB migration review
/pr The API changes are breaking but documented    → Highlights breaking changes

Edge Cases

  • No upstream: Ask for base branch
  • Empty diff: Warn and confirm before creating empty PR
  • Draft PR: If user mentions "draft" or "WIP", add --draft flag
  • Multiple templates: List options, ask which to use