|
| 1 | +--- |
| 2 | +description: Create a pull request — runs precommit, commits any changes, detects issue numbers in branch names, and enables automerge by default. |
| 3 | +allowed-tools: Bash, Read, Edit, Write, Glob, Grep |
| 4 | +--- |
| 5 | + |
| 6 | +## Context |
| 7 | + |
| 8 | +- Current branch: !`git branch --show-current` |
| 9 | +- Git status: !`git status --short` |
| 10 | +- Git diff (staged + unstaged): !`git diff HEAD` |
| 11 | +- Recent commits: !`git log --oneline -5` |
| 12 | + |
| 13 | +## Your task |
| 14 | + |
| 15 | +Arguments (optional PR title or extra instructions): $ARGUMENTS |
| 16 | + |
| 17 | +Follow these steps in order: |
| 18 | + |
| 19 | +### Step 1 — Run pre-PR checks and fix issues |
| 20 | + |
| 21 | +This project has no single precommit command. Run the same checks CI enforces, in order, and fix any errors or warnings before proceeding. Repeat each until it passes cleanly: |
| 22 | + |
| 23 | +1. TypeScript: `bunx tsc --noEmit` |
| 24 | +2. Biome (lint + format): `bun run lint` — use `bun run lint:fix` to auto-fix where possible |
| 25 | +3. Tests: `bun run test -- --ci` |
| 26 | + |
| 27 | +If you changed any GraphQL operations or the schema, also run `bun run codegen` and include the regenerated files. |
| 28 | + |
| 29 | +### Step 2 — Commit any uncommitted changes |
| 30 | + |
| 31 | +If there are staged or unstaged changes after precommit passes: |
| 32 | +1. Stage all changed tracked files: `git add -u` |
| 33 | +2. Draft a concise commit message that describes the changes (focus on "why", not "what") |
| 34 | +3. Create the commit |
| 35 | + |
| 36 | +### Step 3 — Push the branch |
| 37 | + |
| 38 | +Push the current branch to origin: |
| 39 | +``` |
| 40 | +git push -u origin HEAD |
| 41 | +``` |
| 42 | + |
| 43 | +### Step 4 — Determine PR description |
| 44 | + |
| 45 | +Check the current branch name for a GitHub issue number pattern (e.g. `123-fix-something`, `feature/456-add-widget`, `fix-789`). |
| 46 | + |
| 47 | +- If an issue number is found, append `Closes #<number>` to the PR body. |
| 48 | +- If no issue number is found, omit the closing reference. |
| 49 | + |
| 50 | +### Step 5 — Create the pull request |
| 51 | + |
| 52 | +Use `gh pr create` with: |
| 53 | +- Title: derived from $ARGUMENTS if provided, otherwise infer from the commit messages on the branch vs main |
| 54 | +- Body: brief summary of changes, plus `Closes #<number>` if applicable (use a HEREDOC to pass the body) |
| 55 | +- Base branch: `main` |
| 56 | + |
| 57 | +Example: |
| 58 | +```bash |
| 59 | +gh pr create --base main --title "..." --body "$(cat <<'EOF' |
| 60 | +## Summary |
| 61 | +- <bullet points> |
| 62 | +
|
| 63 | +Closes #<number> |
| 64 | +EOF |
| 65 | +)" |
| 66 | +``` |
| 67 | + |
| 68 | +### Step 6 — Enable automerge |
| 69 | + |
| 70 | +Unless $ARGUMENTS contains "no-automerge" or "no automerge", enable automerge after the PR is created: |
| 71 | +```bash |
| 72 | +gh pr merge --auto --squash |
| 73 | +``` |
| 74 | + |
| 75 | +If the repo does not support automerge (command fails), note this to the user but do not treat it as a fatal error. |
0 commit comments