AgentSkillsCN

pr-create

基于 git 提交及相关问题,以智能且富含上下文的内容生成 Pull Request 的正文

SKILL.md
--- frontmatter
name: pr-create
description: Create or update pull requests with intelligent, contextually rich bodies based on git commits and related issues
license: MIT
compatibility: opencode

What I do

  • Generate PR titles and bodies based on git commits and related issues
  • Update existing PRs with current context
  • Follow repository-specific PR templates and conventions
  • Link PRs to related issues and epics

When to use me

Use this skill when:

  • Creating a new pull request
  • Updating an existing pull request
  • Need guidance on PR structure and content
  • Working with the HubSpot Social team repositories

Process Overview

1. Gather Branch Context

If JSON context data is not already provided, run the extract-branch-info.sh script:

bash
extract-branch-info.sh

This script provides:

  • Git commits on the current branch
  • Related issues linked to the branch
  • Epic context if the issue is part of a larger initiative
  • Repository details and PR template

2. Check for Existing PR

  • If existingPr is not null in the context data, update the existing PR instead of creating a new one
  • Use gh pr edit to update the PR title and body with current information
  • Ensure the updated content reflects the current state of commits and removes any outdated information

3. Analyze the Context

Review the provided context to understand:

  • Commits: What changes were made and why
  • Related issue: The problem being solved or feature being added
  • Epic context: How this fits into a larger initiative
  • PR template: Repository-specific structure requirements

PR Title Format

Create a concise, descriptive title based on the commits and/or related issue.

Format

code
[Type]: Description

Common Types

  • Fix: Bug fixes
  • Feature: New functionality
  • Update: Enhancements to existing features
  • Refactor: Code restructuring
  • Docs: Documentation changes
  • Test: Testing improvements
  • Chore: Maintenance and cleanup

Examples

code
Fix: Handle edge case in user validation
Feature: Add OAuth login support
Update: Improve error messages in API responses
Refactor: Extract validation logic to separate module

PR Body Structure

CRITICAL: The PR body MUST start with "# Changes" - nothing should come before it.

markdown
# Changes

- [Describe specific changes based on commits]
- [Don't be redundant]
- [Use as few bullets as possible to convey the changes that were made]

## Related links

Closes https://github.com/[OWNER]/[REPO]/issues/[ISSUE_NUMBER]

[If part of an epic, add:]
Part of epic: [Epic Title](https://github.com/[OWNER]/[REPO]/issues/[EPIC_NUMBER])

## Screenshots

| Before     | After      |
| ---------- | ---------- |
| PASTE_HERE | PASTE_HERE |

## Pre-Merge Checklist

- [ ] I ran AT tests against this branch

Content Guidelines

Changes Section

  • Analyze commits to create meaningful bullet points describing what was modified
  • Focus on what changed and why it matters
  • Be specific with technical details that help code reviewers
  • Use as few bullets as possible - don't be redundant
  • Explain the reasoning behind changes, not just what changed

Related Links Section

  • Use the exact repository and issue number from the context
  • If the related issue is part of an epic, mention it with a link
  • If no related issue exists, remove this section entirely

Screenshots Section

  • Always include the table structure for before/after screenshots
  • Leave placeholders for the user to paste screenshots

Pre-Merge Checklist

  • Include standard checklist items for the repository
  • For HubSpot Social: "I ran AT tests against this branch"

Special Considerations

No Related Issue

If there's no related issue:

  • Remove the "Related links" section
  • Focus on describing changes from commits

New Branch (No Commits)

If no commits exist yet:

  • Focus on intended changes based on branch name
  • Describe what will be implemented

Custom PR Template

If the repository has a custom PR template:

  • Adapt the structure accordingly
  • Preserve required sections from the template

HubSpot Social Team

For HubSpot Social team repositories:

  • Issues may be in ProductSupport or SocialCoreTeam repos
  • Use the exact repository from the context data
  • Always include the AT tests checklist item

Output Format

Output ONLY the appropriate GitHub CLI command:

For New PRs

bash
gh pr create --title "TITLE_HERE" --body "BODY_HERE" --assignee nhackford --web

For Existing PRs

bash
gh pr edit --title "TITLE_HERE" --body "BODY_HERE"

Critical Requirements

  • Use proper shell escaping for the title and body
  • The PR body MUST start with "# Changes"
  • Escape quotes and special characters properly for shell execution
  • For existing PRs, generate a completely fresh body based on current commits (don't try to merge with existing content)
  • Ensure updated PR content reflects current state and removes any outdated information

Examples

Example: New PR with Related Issue

Input Context:

  • Branch: nh-1234-fix-validation
  • Commits: 3 commits fixing validation logic
  • Issue #1234 in SocialCoreTeam repo

Output:

bash
gh pr create --title "Fix: Handle null values in user validation" --body "# Changes

- Add null checks in validation middleware
- Update error messages for invalid user data
- Add unit tests for edge cases

## Related links

Closes https://github.com/HubSpot/SocialCoreTeam/issues/1234

## Screenshots

| Before     | After      |
| ---------- | ---------- |
| PASTE_HERE | PASTE_HERE |

## Pre-Merge Checklist

- [ ] I ran AT tests against this branch" --assignee nhackford --web

Example: Update Existing PR

Input Context:

  • Existing PR #567
  • 2 new commits added since PR creation

Output:

bash
gh pr edit --title "Feature: Add OAuth login support" --body "# Changes

- Implement OAuth2 flow with GitHub provider
- Add callback endpoint for OAuth redirect
- Update login UI with OAuth button
- Add integration tests for OAuth flow

## Related links

Closes https://github.com/HubSpot/Social/issues/890

## Screenshots

| Before     | After      |
| ---------- | ---------- |
| PASTE_HERE | PASTE_HERE |

## Pre-Merge Checklist

- [ ] I ran AT tests against this branch"