AgentSkillsCN

open-pr

基于对话情境,以结构化的格式和标签选择,起草并创建 GitHub Pull Request。

SKILL.md
--- frontmatter
name: open-pr
description: Draft and create GitHub pull requests from conversation context with structured formatting and tag selection.

Create a Pull Request

Reviews the current branch's changes, drafts a well-formatted pull request, and creates it after user confirmation.

PR Structure

markdown
# [tag][#issue-number] Brief description of what was accomplished

## Summary

Concise overview of the completed work and the value it delivers.

## Changes

- Modified `path/to/file:lines` — what changed and why
- Added `path/to/new_file` — purpose
- Deleted `path/to/old_file` — reason

## Testing

- Added `tests/test_feature.py` — verifies behaviour X
- Manually tested scenario Y

## Related Issue

Closes #issue-number

Choosing a Tag

Check whether the project defines its own tag list (common locations: docs/git-msg-tags.md, CONTRIBUTING.md). If none is found, use these defaults:

TagWhen to use
[feat]New functionality
[fix]Bug fix
[docs]Documentation-only change
[refactor]Restructuring without behaviour change
[test]Test-only change
[chore]Tooling, CI, or dependency updates

Workflow

1. Review the Changes

Before drafting anything, inspect what the branch contains:

bash
git status
git diff
git log origin/main..HEAD --oneline

Understand the full scope of changes — not just the latest commit, but everything that will land when the PR merges.

2. Select the Tag

  • Read the project's tag file if one exists
  • Determine the primary purpose of the changes
  • If ambiguous, ask the user to choose

3. Find the Issue Number

The PR title must reference an issue number in the format [tag][#N].

Where to look:

  1. Conversation history for explicit references
  2. Branch name (e.g., issue-42)
  3. Recent issues: gh issue list --limit 10

If no related issue exists, ask the user to create one first.

4. Draft the PR

Title: [tag][#N] Brief description — past tense, under 80 characters for the description portion.

Summary: What was achieved and why it matters.

Changes: List every file modified, added, or deleted with a brief note. Include line ranges where helpful. Do not paste code snippets.

Testing: What was tested and how — new test files, manual verification steps, etc.

Related Issue: Use Closes #N, Fixes #N, or Part of #N as appropriate.

5. Confirm with the User

Display the complete draft and wait for explicit approval.

6. Push and Create

Ensure the branch is on the remote:

bash
git push -u origin $(git branch --show-current)

Then create the PR:

bash
gh pr create --title "TITLE" --body-file - <<'EOF'
BODY
EOF

Display the PR URL to the user.

7. Handle Errors

ProblemAction
No issue number foundAsk user to provide one or create an issue first
No changes on the branchInform user there's nothing to open a PR for
GitHub CLI not authenticatedAsk user to run gh auth login
Not on a feature branchWarn user and suggest creating one
Push failsShow the error and suggest resolution

Ownership

The PR is created on behalf of the user. The AI agent must not add any authorship or co-authorship attribution.