|
| 1 | +--- |
| 2 | +name: create-pr |
| 3 | +description: Create a GitHub PR with a well-formatted description including summary, categorized changes, and attention areas |
| 4 | +argument-hint: [special instructions] |
| 5 | +disable-model-invocation: true |
| 6 | +--- |
| 7 | + |
| 8 | +# Create Pull Request |
| 9 | + |
| 10 | +Create a well-formatted GitHub pull request for the current branch. |
| 11 | + |
| 12 | +## Arguments |
| 13 | + |
| 14 | +`$ARGUMENTS` can be used for special instructions, such as: |
| 15 | +- Specifying a base branch: "use base branch: develop" |
| 16 | +- Guiding the summary: "emphasize the performance improvements in the summary" |
| 17 | +- Adding context: "this is part of the auth refactor epic" |
| 18 | +- Any other guidance for PR creation |
| 19 | + |
| 20 | +Default base branch: `main` (unless specified in arguments) |
| 21 | + |
| 22 | +## Step 1: Gather Information |
| 23 | + |
| 24 | +Run these commands in parallel to understand the changes: |
| 25 | + |
| 26 | +1. **Current branch**: `git branch --show-current` |
| 27 | +2. **Uncommitted changes**: `git status --porcelain` |
| 28 | +3. **Commits on branch**: `git log origin/main..HEAD --oneline` |
| 29 | +4. **File changes summary**: `git diff --stat origin/main..HEAD` |
| 30 | +5. **Full diff**: `git diff origin/main..HEAD` |
| 31 | +6. **Recent commit style**: `git log -5 --oneline` (to match PR title convention) |
| 32 | + |
| 33 | +**Important checks:** |
| 34 | +- If uncommitted changes exist, warn the user and ask if they want to commit first |
| 35 | +- If no commits ahead of main, inform the user there's nothing to PR |
| 36 | +- If branch isn't pushed, you'll push it in Step 4 |
| 37 | + |
| 38 | +## Step 2: Analyze and Categorize Changes |
| 39 | + |
| 40 | +### By Change Type (from commits and diff) |
| 41 | +- ✨ **Added**: New files, features, capabilities |
| 42 | +- 🔧 **Changed**: Modified existing functionality |
| 43 | +- 🗑️ **Removed**: Deleted files or features |
| 44 | +- 🐛 **Fixed**: Bug fixes |
| 45 | +- 📚 **Docs**: Documentation updates |
| 46 | +- 🧪 **Tests**: Test additions/modifications |
| 47 | + |
| 48 | +### Identify Attention Areas 🔍 |
| 49 | +Flag for special reviewer attention: |
| 50 | +- Files with significant changes (>100 lines) |
| 51 | +- Changes to base classes, interfaces, or public API |
| 52 | +- New dependencies (`pyproject.toml`, `requirements.txt`) |
| 53 | +- Configuration schema changes |
| 54 | +- Security-related changes |
| 55 | + |
| 56 | +## Step 3: Generate PR Title |
| 57 | + |
| 58 | +Use conventional commit format matching the repo style: |
| 59 | +- `feat:` for new features |
| 60 | +- `fix:` for bug fixes |
| 61 | +- `docs:` for documentation |
| 62 | +- `refactor:` for refactoring |
| 63 | +- `chore:` for maintenance |
| 64 | +- `test:` for test changes |
| 65 | + |
| 66 | +If commits have mixed types, use the primary/most significant type. |
| 67 | + |
| 68 | +## Step 4: Create the PR |
| 69 | + |
| 70 | +1. **Push branch** (if needed): |
| 71 | + ```bash |
| 72 | + git push -u origin <branch-name> |
| 73 | + ``` |
| 74 | + |
| 75 | +2. **Create PR** using this template: |
| 76 | + |
| 77 | +```markdown |
| 78 | +## 📋 Summary |
| 79 | + |
| 80 | +[1-2 sentence overview of what this PR accomplishes] |
| 81 | + |
| 82 | +## 🔄 Changes |
| 83 | + |
| 84 | +### ✨ Added |
| 85 | +- [New features/files - link to key files when helpful] |
| 86 | + |
| 87 | +### 🔧 Changed |
| 88 | +- [Modified functionality - reference commits for specific changes] |
| 89 | + |
| 90 | +### 🗑️ Removed |
| 91 | +- [Deleted items] |
| 92 | + |
| 93 | +### 🐛 Fixed |
| 94 | +- [Bug fixes - if applicable] |
| 95 | + |
| 96 | +## 🔍 Attention Areas |
| 97 | + |
| 98 | +> ⚠️ **Reviewers:** Please pay special attention to the following: |
| 99 | +
|
| 100 | +- `path/to/critical/file.py` - [Why this needs attention] |
| 101 | + |
| 102 | +--- |
| 103 | +🤖 *Generated with AI* |
| 104 | +``` |
| 105 | + |
| 106 | +3. **Execute**: |
| 107 | + ```bash |
| 108 | + gh pr create --title "<title>" --body "$(cat <<'EOF' |
| 109 | + <body> |
| 110 | + EOF |
| 111 | + )" |
| 112 | + ``` |
| 113 | +
|
| 114 | +4. **Return the PR URL** to the user. |
| 115 | +
|
| 116 | +## Section Guidelines |
| 117 | +
|
| 118 | +- **Summary**: Always include - be concise and focus on the "why" |
| 119 | +- **Changes**: Group by type, omit empty sections |
| 120 | +- **Attention Areas**: Only include if there are genuinely important items; omit for simple PRs |
| 121 | +- **Links**: Include links to code and commits where helpful for reviewers: |
| 122 | + - Link to specific files: `[filename](path/to/file.py)` - GitHub auto-links files in the repo |
| 123 | + - Link to specific lines: `[description](path/to/file.py#L42-L50)` for key code sections |
| 124 | + - Reference commits: `abc1234` - GitHub auto-links commit SHAs |
| 125 | + - For multi-commit PRs, reference individual commits when describing specific changes |
| 126 | +
|
| 127 | +## Edge Cases |
| 128 | +
|
| 129 | +- **No changes**: Inform user there's nothing to create a PR for |
| 130 | +- **Uncommitted work**: Warn and ask before proceeding |
| 131 | +- **Large PRs** (>20 files): Summarize by directory/module |
| 132 | +- **Single commit**: PR title can match commit message |
0 commit comments