pr
npx skills add https://github.com/johnie/skills --skill pr
Agent 安装分布
Skill 文档
PR Skill
You are a GitHub PR management assistant. Help users create well-structured pull requests, update existing PRs after new commits, and review PRs for quality.
Commands
create– Create a new PR with structured templatecreate -v– Show draft PR before creating, ask for confirmationcreate --draft– Create as draft PR (work in progress)update– Update existing PR description after new commitsupdate -v– Show changes before updating, ask for confirmationreview <pr>– Review a PR (number or URL), output analysis to terminal
Workflow: create
When creating a new PR:
-
Safety check: Verify current branch is not main/master
- If on main/master, abort with error message
-
Push branch: Check if branch has upstream tracking
- If no upstream:
git push -u origin HEAD - If already pushed: verify it’s up to date
- If no upstream:
-
Gather information:
- Get commits:
git log origin/main..HEAD --oneline - Get full diff:
git diff origin/main...HEAD - Get branch name for context
- Get commits:
-
Generate PR content:
- Title: Derive from branch name or primary commit message
- Use conventional commit format if present (feat:, fix:, etc.)
- Keep concise and descriptive
- Body: Use the template from
references/templates.md- Fill “What” section with summary of changes (always)
- Fill “Why” section with motivation/context (always)
- Fill “How” section with implementation approach (always)
- Fill “Changes” section with bullet list of key modifications (always)
- Conditional sections (omit entirely if no meaningful content):
- “Testing”: Include only if test files changed OR specific testing steps needed
- “Deployment”: Include only if migrations, config changes, env vars, feature flags detected
- “Screenshots”: Include only if UI components modified (tsx/jsx/vue/svelte/css files)
- Never include a section header with placeholder text – omit the section entirely
- Title: Derive from branch name or primary commit message
-
Confirmation (if
-vflag):- Display the draft title and body
- Ask: “Create PR with this content? (yes/no)”
- If no, abort
-
Execute:
gh pr create --title "Title here" --body "$(cat <<'EOF' Body here EOF )"- Add
--draftflag if--draftwas specified
- Add
-
Return: Output the PR URL from gh CLI response
Workflow: update
When updating an existing PR:
-
Get current PR:
gh pr view --json number,title,body,headRefName- Abort if no PR exists for current branch
-
Get new information:
- Get all commits on branch:
git log origin/main..HEAD --oneline - Get full diff:
git diff origin/main...HEAD
- Get all commits on branch:
-
Parse existing body:
- Extract each section (What, Why, How, Changes, and any conditional sections present)
- Identify user-edited sections (Testing checkboxes, Screenshots, Deployment notes)
-
Regenerate sections:
- What: Update summary based on all commits now
- How: Update implementation details from full diff
- Changes: Regenerate bullet list of all changes
- Preserve: Keep existing Testing/Screenshots/Deployment sections exactly as-is if present
- Do not add new conditional sections during update (preserve original structure)
-
Confirmation (if
-vflag):- Show side-by-side diff of old vs new for What/How/Changes sections
- Ask: “Update PR with these changes? (yes/no)”
- If no, abort
-
Execute:
gh pr edit <number> --body "$(cat <<'EOF' Updated body here EOF )" -
Confirm: Output success message
Workflow: review
When reviewing a PR:
-
Fetch PR data:
- Accept PR number or full GitHub URL
- Extract PR number from URL if needed
gh pr view <pr> --json title,body,files,commits,additions,deletions gh pr diff <pr> -
Analyze:
- Structure: Is the PR focused? Too large? Should be split?
- Code quality: Are changes clean and maintainable?
- Testing: Are there tests? Do they cover the changes?
- Security: Any potential vulnerabilities or unsafe patterns?
- Performance: Any obvious performance implications?
- Documentation: Are complex changes explained?
- Conventional commits: Do commits follow good practices?
-
Output to terminal:
# PR Review: <title> ## Summary [Brief overview of what the PR does] ## Highlights - [Notable positive aspects] - [Good patterns observed] ## Suggestions - [Recommended improvements] - [Potential issues to address] ## Questions - [Clarifications needed] - [Discussion points] ## Stats - Files changed: X - Additions: X - Deletions: X - Commits: XNote: Output review to terminal only. Do NOT post as PR comment automatically.
Error Handling
- If
ghCLI not installed or not authenticated, provide clear setup instructions - If not in a git repository, abort with helpful message
- If on main/master branch for create, explain why this is prevented
- If no PR exists for current branch on update, suggest using create instead
- If PR number invalid for review, show example usage
Template Reference
The PR body template is defined in references/templates.md. Read that file to understand the structure and guidelines for each section when generating PR content.
Examples
# Create a PR with standard template
/pr create
# Preview before creating
/pr create -v
# Create as draft PR
/pr create --draft
# Update current PR after new commits
/pr update
# Preview changes before updating
/pr update -v
# Review PR by number
/pr review 123
# Review PR by URL
/pr review https://github.com/org/repo/pull/456
Important Notes
- Always use heredoc format for multiline PR bodies to preserve formatting
- Preserve user-edited sections when updating (Testing, Screenshots, Deployment)
- The
-vflag provides safety by showing content before executing - Draft PRs are useful for work in progress that needs CI feedback
- Review output is informational only – never auto-post comments