|
| 1 | +--- |
| 2 | +description: Create a pull request with a release note style description, appropriate title, and labels based on the change type. |
| 3 | +--- |
| 4 | + |
| 5 | +# PR |
| 6 | + |
| 7 | +The user input to you can be provided directly by the agent or as a command argument - you **MUST** consider it before proceeding with the prompt (if not empty). |
| 8 | + |
| 9 | +## User input |
| 10 | + |
| 11 | +$ARGUMENTS |
| 12 | + |
| 13 | +**Purpose**: Create or update a pull request with a release note style description and title, automatically applying the appropriate labels based on the change type specified. |
| 14 | + |
| 15 | +## Supported Change Types |
| 16 | + |
| 17 | +| Type | Icon | Labels | Description | |
| 18 | +|------|------|--------|-------------| |
| 19 | +| Major | 🌟 | `Major` | Breaking changes that affect compatibility | |
| 20 | +| Minor | 🚀 | `Minor` | New features or enhancements | |
| 21 | +| Patch | 🩹 | `Patch` | Small fixes or improvements | |
| 22 | +| Fix | 🪲 | `Fix`, `Patch` | Bug fixes | |
| 23 | +| Docs | đź“– | `Docs` | Documentation changes only | |
| 24 | + |
| 25 | +## Execution Steps |
| 26 | + |
| 27 | +1. **Detect repository mode**: |
| 28 | + - Run `git remote -v` to check configured remotes. |
| 29 | + - **If `upstream` remote exists**: Fork mode - use upstream owner/repo for all GitHub operations |
| 30 | + - **If only `origin` remote exists**: Origin mode - use origin owner/repo for all GitHub operations |
| 31 | + - Parse the URLs to extract owner and repo name: `https://github.com/<owner>/<repository>.git`. |
| 32 | + - If in doubt, ask the user to clarify which repository to target. |
| 33 | + |
| 34 | +2. **Determine the change type**: |
| 35 | + 1. Parse the user input to identify the change type (Major, Minor, Patch, Fix, or Docs) |
| 36 | + 2. If nothing is provided, evaluate the code changes to infer the type: |
| 37 | + - **Major**: Changes that break backward compatibility (e.g., removing public APIs, changing method signatures) |
| 38 | + - **Minor**: New features or enhancements that do not break existing functionality |
| 39 | + - **Patch**: Bug fixes or small improvements that do not add new features |
| 40 | + - **Fix**: Specifically for bug fixes |
| 41 | + - **Docs**: Only documentation changes |
| 42 | + |
| 43 | +3. **Get current branch information**: |
| 44 | + - Determine the current branch name |
| 45 | + - Verify there are changes to commit (if uncommitted changes exist, stage and commit them first) |
| 46 | + - Push the branch to remote if not already pushed. |
| 47 | + |
| 48 | +4. **Retrieve linked issue information** (if available): |
| 49 | + - Attempt to find the GitHub issue number associated with the current branch |
| 50 | + - If found, retrieve the issue title from the target repository |
| 51 | + - Use the issue title as the PR title (with appropriate icon prefix) |
| 52 | + - If no issue is found, ask the user to provide one of the following: |
| 53 | + - the number of the issue to link to the PR |
| 54 | + - if a new issue should be raised for this PR |
| 55 | + - Stop if the user cannot provide either of these. |
| 56 | + |
| 57 | +5. **Generate PR title**: |
| 58 | + - **If issue title retrieved**: Use format `<Icon> <Issue Title>` |
| 59 | + - Examples: |
| 60 | + - `🚀 Add support for custom module templates` |
| 61 | + - `🪲 [Fix]: Resolve null reference in parameter validation` |
| 62 | + - `đź“– [Docs]: Update installation guide with prerequisites` |
| 63 | + |
| 64 | +6. **Generate release note style description**: |
| 65 | + - Start with a concise summary paragraph describing **what changes for the user** of the code |
| 66 | + - Focus on user-facing impact, not implementation details |
| 67 | + - Use present tense and active voice |
| 68 | + - Structure: |
| 69 | + * **Leading paragraph**: Clear summary of the change and its benefit to users |
| 70 | + * **If issue linked**: Add `- Fixes #<issue-number>` after the leading paragraph |
| 71 | + * **Optional additional context**: Briefly explain why this change was needed |
| 72 | + * **What's Changed**: Bullet points of key changes (user-facing) |
| 73 | + - Keep it concise - this should read like a release note entry |
| 74 | + - DO NOT add a title or heading before the leading paragraph |
| 75 | + - Avoid implementation details unless necessary for understanding |
| 76 | + |
| 77 | +7. **Create or update the pull request**: |
| 78 | + - **Check if PR already exists** for this branch in the target repository |
| 79 | + - **If PR exists**: Update the title, description, and labels |
| 80 | + - **If PR does not exist**: Create a new PR |
| 81 | + - Set PR to target the default branch (main/master) |
| 82 | + - Open as a **draft PR** (or keep as draft if updating) |
| 83 | + - **Use GitHub MCP tools** to perform these operations: |
| 84 | + ``` |
| 85 | + # Create PR (if not exists) |
| 86 | + mcp_github_github_create_pull_request |
| 87 | +
|
| 88 | + # Update PR (if exists) |
| 89 | + mcp_github_github_update_pull_request |
| 90 | +
|
| 91 | + # Add labels to PR |
| 92 | + mcp_github_github_add_labels_to_issue (PRs are issues in GitHub API) |
| 93 | + ``` |
| 94 | +
|
| 95 | +8. **Apply labels to the PR**: |
| 96 | + - Add the **change type label** based on the type specified (Major, Minor, Patch, Fix, or Docs) |
| 97 | + - For Fix type, add both `Fix` and `Patch` labels |
| 98 | + - If currently in a feature workflow phase (e.g., Planning, Implementation), also apply that phase label |
| 99 | + - Use GitHub MCP to add labels in the target repository |
| 100 | +
|
| 101 | +9. **Confirm completion**: |
| 102 | + - Display the PR URL to the user |
| 103 | + - Summarize the PR title, type, and labels applied |
| 104 | + - If in fork mode, remind the user that the PR was created in the upstream repository |
| 105 | +
|
| 106 | +**Example Usage**: |
| 107 | +- `/PR` - Create a PR for the current changes |
| 108 | +- `/PR Minor` - Create a PR for a new feature |
| 109 | +- `/PR Fix` - Create a PR for a bug fix |
| 110 | +- `/PR Docs` - Create a PR for documentation changes |
| 111 | +- `/PR Major` - Create a PR for breaking changes |
| 112 | +- `/PR Patch` - Create a PR for small improvements |
| 113 | +
|
| 114 | +**Notes**: |
| 115 | +- This command commits and pushes changes if there are uncommitted changes |
| 116 | +- The PR is always created as a draft to allow for review before marking as ready |
| 117 | +- Labels can be manually adjusted after PR creation if needed |
| 118 | +- The description should be written from the user's perspective, focusing on impact not implementation |
0 commit comments