pr

📁 johnie/skills 📅 Jan 25, 2026
4
总安装量
3
周安装量
#48702
全站排名
安装命令
npx skills add https://github.com/johnie/skills --skill pr

Agent 安装分布

claude-code 3
windsurf 1
opencode 1
codex 1
gemini-cli 1

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 template
  • create -v – Show draft PR before creating, ask for confirmation
  • create --draft – Create as draft PR (work in progress)
  • update – Update existing PR description after new commits
  • update -v – Show changes before updating, ask for confirmation
  • review <pr> – Review a PR (number or URL), output analysis to terminal

Workflow: create

When creating a new PR:

  1. Safety check: Verify current branch is not main/master

    • If on main/master, abort with error message
  2. 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
  3. Gather information:

    • Get commits: git log origin/main..HEAD --oneline
    • Get full diff: git diff origin/main...HEAD
    • Get branch name for context
  4. 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
  5. Confirmation (if -v flag):

    • Display the draft title and body
    • Ask: “Create PR with this content? (yes/no)”
    • If no, abort
  6. Execute:

    gh pr create --title "Title here" --body "$(cat <<'EOF'
    Body here
    EOF
    )"
    
    • Add --draft flag if --draft was specified
  7. Return: Output the PR URL from gh CLI response

Workflow: update

When updating an existing PR:

  1. Get current PR:

    gh pr view --json number,title,body,headRefName
    
    • Abort if no PR exists for current branch
  2. Get new information:

    • Get all commits on branch: git log origin/main..HEAD --oneline
    • Get full diff: git diff origin/main...HEAD
  3. Parse existing body:

    • Extract each section (What, Why, How, Changes, and any conditional sections present)
    • Identify user-edited sections (Testing checkboxes, Screenshots, Deployment notes)
  4. 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)
  5. Confirmation (if -v flag):

    • 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
  6. Execute:

    gh pr edit <number> --body "$(cat <<'EOF'
    Updated body here
    EOF
    )"
    
  7. Confirm: Output success message

Workflow: review

When reviewing a PR:

  1. 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>
    
  2. 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?
  3. 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: X
    

    Note: Output review to terminal only. Do NOT post as PR comment automatically.

Error Handling

  • If gh CLI 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 -v flag 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