AgentSkillsCN

create-pr

创建带有正确问题链接和规范提交信息的GitHub Pull Request。当用户说“创建PR”、“提交PR”、“打开Pull Request”、“推送并创建PR”,或在预审通过后,可使用此工具。

SKILL.md
--- frontmatter
name: create-pr
description: Create a GitHub pull request with proper issue linking and conventional commits. Use when user says "create pr", "submit pr", "open pull request", "push and create pr", or after pre-pr review passes.

Create Pull Request

Create a well-structured GitHub PR with proper issue linking.

Workflow

code
Step 1: Commit Changes    → Review diff, stage, commit
Step 2: Push              → Push to origin
Step 3: Review PR Diff    → Verify what goes into PR
Step 4: Draft PR          → Generate title + body
Step 5: Confirm with User → AskUserQuestion
Step 6: Create PR         → gh pr create

Step 1: Commit Changes

Review and commit any uncommitted changes:

bash
git diff
git status --short
git add -A
git commit -m "type(scope): description"

Conventional commit types:

  • feat - New feature
  • fix - Bug fix
  • docs - Documentation only
  • refactor - Code restructuring
  • test - Adding/updating tests
  • chore - Maintenance tasks

Keep subject line under 80 characters. If all changes are already committed, skip to Step 2.

Step 2: Push to Origin

bash
git push origin <branch-name>

If push fails (e.g., no upstream), set it:

bash
git push -u origin <branch-name>

Step 3: Review PR Diff

bash
git diff origin/main...HEAD --stat

Present summary:

code
Files to be included in PR:
- file1.ts (+50, -10)
- file2.ts (+20, -5)

Total: X files changed, +Y insertions, -Z deletions

Step 4: Draft PR Content

Get issue context:

bash
git branch --show-current  # Extract issue number
gh issue view <number> --json title,body

Generate PR title: Format: type(scope): description

  • Keep under 80 characters
  • Use conventional commit format

Generate PR body:

markdown
## Summary

<1-2 sentences: what does this PR do and why>

## Related Issues

Closes #<issue-number>

## Changes

- Change 1
- Change 2
- Change 3

## Testing

- [ ] Tests pass locally
- [ ] Manual verification done

Step 5: Confirm with User

Present the draft PR:

code
## Proposed Pull Request

**Title:** feat(auth): add OAuth2 login flow

**Body:**
<generated body>

Ready to create this PR?

Use AskUserQuestion:

  • Options: ["Create PR", "Edit title", "Edit body", "Cancel"]

If user edits, update and re-confirm.

Step 6: Create PR

bash
gh pr create --base main --title "<title>" --body "<body>"

On success, display:

code
## PR Created ✓

#<pr-number>: <title>
<pr-url>

Issues linked: #<issue-number> (will close on merge)

Issue Linking Reference

KeywordEffect
Closes #XAuto-closes issue on merge
Fixes #XAuto-closes issue on merge
Resolves #XAuto-closes issue on merge
Related to #XLinks without auto-close
Part of #XLinks to parent/epic

Error Handling

If push fails

code
Push failed. Possible causes:
- No upstream branch set
- Remote has new commits

Options: ["Set upstream", "Pull and retry", "Ask user for help"]

If PR creation fails

code
PR creation failed: <error>

Options: ["Retry", "Open in browser", "Ask user for help"]

Notes

  • Always include Related Issues section with proper linking
  • Default to Closes for issue from branch name
  • Keep description under 5 sentences unless user specifies otherwise
  • If any step fails, ask user for help before proceeding