|
| 1 | +--- |
| 2 | +name: pr |
| 3 | +description: Push branch and create a GitHub PR with concise, issue-linked description |
| 4 | +user-invocable: true |
| 5 | +argument-hint: "[#issue]" |
| 6 | +disable-model-invocation: true |
| 7 | +allowed-tools: Bash, Read, Grep, Glob |
| 8 | +--- |
| 9 | + |
| 10 | +# Create Pull Request |
| 11 | + |
| 12 | +Push branch and create a PR with a concise, issue-linked description. |
| 13 | + |
| 14 | +> **IMPORTANT:** This skill MUST be used for ALL pull request creation — even when the user says "create pr" without `/pr`. Never create a PR without following these steps. |
| 15 | +
|
| 16 | +## Current Branch Context |
| 17 | +- Branch: !`git branch --show-current` |
| 18 | +- Commits: !`git log main..HEAD --oneline 2>/dev/null` |
| 19 | +- Changed files: !`git diff main..HEAD --stat 2>/dev/null` |
| 20 | + |
| 21 | +## Arguments |
| 22 | +- `$ARGUMENTS` - Issue reference (optional, e.g., `#42` or `42`). If provided, the PR will be linked to this issue. |
| 23 | + |
| 24 | +## Instructions |
| 25 | + |
| 26 | +1. **Review the branch context above** — the commits and changed files are already loaded. |
| 27 | + |
| 28 | +2. **MANDATORY: Update CHANGELOG.md** — Read `CHANGELOG.md` and check the `## Unreleased` section. If the changes from this branch are NOT already listed there, you MUST update it before proceeding. **Do NOT skip this step. Do NOT proceed to push without verifying.** |
| 29 | + - Add entries under the appropriate subsection (`### Added`, `### Changed`, `### Fixed`, etc.) |
| 30 | + - Reference issue numbers where applicable (e.g., `(Issue #123)`) |
| 31 | + - Commit the update: |
| 32 | + ```bash |
| 33 | + git add CHANGELOG.md && git commit -m "docs: update changelog" |
| 34 | + ``` |
| 35 | + |
| 36 | +3. **Push branch**: |
| 37 | + ```bash |
| 38 | + git push -u origin HEAD |
| 39 | + ``` |
| 40 | + - The `pre-push` git hook automatically runs the full test suite (BE & FE in parallel). |
| 41 | + - If the hook fails, read the output, fix the issue, commit the fix, and retry the push. Do NOT use `--no-verify` to bypass. |
| 42 | + |
| 43 | +4. **Generate PR title**: |
| 44 | + - If `$ARGUMENTS` contains an issue number, fetch the issue title: |
| 45 | + ```bash |
| 46 | + gh issue view <number> --json title -q '.title' |
| 47 | + ``` |
| 48 | + - PR title format: `<type>(<scope>): <short description>` (conventional commit style, under 70 chars) |
| 49 | + - Derive the type from the branch prefix (`feat/` → feat, `fix/` → fix, `docs/` → docs) |
| 50 | + |
| 51 | +5. **Create PR** using the template from `.github/PULL_REQUEST_TEMPLATE.md`: |
| 52 | + ```bash |
| 53 | + gh pr create --title "<title>" --assignee @me --label "<label>" --body "$(cat <<'EOF' |
| 54 | + ## 🤔 Background |
| 55 | +
|
| 56 | + Related #<issue-number> |
| 57 | +
|
| 58 | + <1-2 sentences: motivation and context for the changes> |
| 59 | +
|
| 60 | + ## 💡 Changes |
| 61 | +
|
| 62 | + - <bullet 1: what changed and why> |
| 63 | + - <bullet 2> |
| 64 | + - <bullet 3> (optional) |
| 65 | + - <bullet 4> (optional) |
| 66 | + EOF |
| 67 | + )" |
| 68 | + ``` |
| 69 | +
|
| 70 | + **MANDATORY:** Always follow the PR template structure (`## 🤔 Background` + `## 💡 Changes`). Never use a different format. |
| 71 | +
|
| 72 | + **Assignee:** Always assign to `@me` (the PR creator). |
| 73 | +
|
| 74 | + **Labels:** Add the single most relevant label based on the branch prefix and change context: |
| 75 | + - `bug` — branch starts with `fix/` and addresses a defect |
| 76 | + - `enhancement` — branch starts with `feat/` or adds new functionality |
| 77 | + - `documentation` — branch starts with `docs/` or only changes docs |
| 78 | + - `refactor` — code restructuring with no behavior change |
| 79 | + - `ui` — visual/frontend-only changes |
| 80 | + - `investigation` — spikes, research, or exploratory work |
| 81 | +
|
| 82 | + **Body guidelines:** |
| 83 | + - **Background**: Link the issue with `Related #<number>`, then 1-2 sentences of context. **NEVER use `Closes` or `Fixes`.** |
| 84 | + - **Changes**: 2-4 short bullet points. Focus on *what* and *why*, not implementation details. |
| 85 | + - **No file lists, no class names, no code snippets** in the body. |
| 86 | + - Keep the entire body under 15 lines. |
| 87 | +
|
| 88 | +6. **Move issue to "In Review"** in GitHub Project (if issue number provided): |
| 89 | + ```bash |
| 90 | + # Read project config from .claude/github-project.json |
| 91 | + ITEM_ID=$(gh project item-list PROJECT_NUMBER --owner OWNER --format json \ |
| 92 | + | jq -r '.items[] | select(.content.number == ISSUE_NUMBER) | .id') |
| 93 | +
|
| 94 | + gh project item-edit \ |
| 95 | + --id "$ITEM_ID" \ |
| 96 | + --project-id "PROJECT_ID" \ |
| 97 | + --field-id "STATUS_FIELD_ID" \ |
| 98 | + --single-select-option-id "IN_REVIEW_OPTION_ID" |
| 99 | + ``` |
| 100 | +
|
| 101 | + **Note:** Requires `project` scope. Run `gh auth refresh -s project` if needed. |
| 102 | +
|
| 103 | +7. **Report the PR URL** to the user. |
| 104 | +
|
| 105 | +## Example Usage |
| 106 | +
|
| 107 | +``` |
| 108 | +/pr |
| 109 | +/pr #42 |
| 110 | +/pr 15 |
| 111 | +``` |
0 commit comments