Create Pull Request
Create a pull request from the current branch with proper formatting and issue linking.
Command Options
All flags are optional. By default, the issue number is inferred from the branch name and the PR is created as ready-to-review.
--issue N: Override automatic issue linking with a specific issue number (or comma-separated list: --issue 123,175)
--skip-issue-link: Skip issue linking entirely
--draft: Create PR as draft
Your task
Verify prerequisites:
- Confirm current branch is not
main/master
- Check that branch has commits ahead of base branch
- Ensure branch is pushed to remote (push if needed)
Generate PR title:
- Use branch name as fallback
- If single commit ahead: use commit message as title
- If multiple commits: create descriptive title based on branch name and commit themes
- Follow Conventional Commits format from global CLAUDE.md
Analyze commits for description:
- Get commit history:
git log origin/<base-branch>..HEAD --oneline (use the base branch identified in step 1)
- Group commits by type (feat, fix, docs, etc.)
- Identify patterns and overall theme
Create comprehensive description:
- Summary section: 2-3 bullet points describing what this PR does
- Changes section: Categorized list of changes from commits
- Testing section: How the changes should be tested
- Notes section: Any implementation details or decisions
Update ROADMAP:
- Check if the work corresponds to a checkbox item in
docs/prd/ROADMAP.md
- If a matching item exists, mark it complete (
[x]) and commit the change to the branch before creating the PR
- If no matching item exists, skip this step
Identify and link related issues (discover → classify → confirm; don't rely on recall):
- If
--skip-issue-link: skip this step entirely.
- Determine the primary issue(s) P:
--issue N (accepts a comma-separated list, e.g. --issue 123,175) → use directly as Close targets; skip discovery.
- Otherwise extract from the branch name (
fix/gh-123-... → P=123). If none can be determined, warn and ask whether to proceed with no linking.
- Discover candidates mechanically (do not depend on having read the issue earlier in the session):
- Fetch the primary issue's body and comments:
gh issue view P --json number,title,body,comments
- Extract every
#<number> reference from that output.
- For each referenced issue M, get its state:
gh issue view M --json number,title,state — drop anything already closed or that is a PR.
- Classify each open candidate by the language around the mention:
closes / fixes / resolves #M, or M is an unchecked task-list item this PR completes → Close (Closes #M)
part of / blocked by / relates to / see / parent #M → Reference (Refs #M, no closing keyword)
- ambiguous → default to Reference and flag it
- Confirm before creating the PR:
- Only the primary issue P, no other open candidates → proceed silently with
Closes #P.
- More than one candidate, or any ambiguous one → print a short table (issue · title · proposed Close/Ref) and ask for a one-line confirm/override first.
- Format: one keyword per line so GitHub parses them all —
Closes #N per close target, Refs #N per reference.
Create the PR:
- Use
gh pr create with generated title and description
- Set base branch (usually main/master)
- Default to ready (no
--draft flag) unless --draft flag is explicitly passed
Confirm and validate:
- Show PR URL and title
- Confirm issue linking (e.g., "✅ Linked to issue #123" or "⚠️ No issues linked")
- Cross-check linking: every Close/Ref target identified in step 6 actually appears in the final description. If one is missing, warn before the PR is considered done (guards against silently dropping a second issue).
- Validate PR metadata (warn, don't block): confirm the title follows Conventional Commits and the description contains a closing keyword (
Closes #N). If either is missing, surface a warning so it can be fixed before review. (These checks previously lived in the retired /review-pr.)
PR Description Template
## Summary
- What this PR does
- Key changes made
## Changes
- List of changes from commits
## Testing
- [ ] Tests pass
- [ ] Manual testing done
Closes #123
Example Usage
# Default: Automatically detects issue from branch name (e.g., fix/gh-123-description)
/create-pr
# Explicit issue linking (when branch name doesn't contain an issue number)
/create-pr --issue 123
# Explicit multi-issue linking (PR closes more than one issue)
/create-pr --issue 123,175
# Skip issue linking entirely
/create-pr --skip-issue-link
1---2name: create-pr3description: Create a pull request with auto-generated description, issue linking, ROADMAP updates, and PR-metadata validation.4---56# Create Pull Request78Create a pull request from the current branch with proper formatting and issue linking.910## Command Options1112All flags are optional. By default, the issue number is inferred from the branch name and the PR is created as ready-to-review.1314- `--issue N`: Override automatic issue linking with a specific issue number (or comma-separated list: `--issue 123,175`)15- `--skip-issue-link`: Skip issue linking entirely16- `--draft`: Create PR as draft1718## Your task19201. **Verify prerequisites**:21 - Confirm current branch is not `main`/`master`22 - Check that branch has commits ahead of base branch23 - Ensure branch is pushed to remote (push if needed)24252. **Generate PR title**:26 - Use branch name as fallback27 - If single commit ahead: use commit message as title28 - If multiple commits: create descriptive title based on branch name and commit themes29 - Follow Conventional Commits format from global CLAUDE.md30313. **Analyze commits for description**:32 - Get commit history: `git log origin/<base-branch>..HEAD --oneline` (use the base branch identified in step 1)33 - Group commits by type (feat, fix, docs, etc.)34 - Identify patterns and overall theme35364. **Create comprehensive description**:37 - **Summary section**: 2-3 bullet points describing what this PR does38 - **Changes section**: Categorized list of changes from commits39 - **Testing section**: How the changes should be tested40 - **Notes section**: Any implementation details or decisions41425. **Update ROADMAP**:43 - Check if the work corresponds to a checkbox item in `docs/prd/ROADMAP.md`44 - If a matching item exists, mark it complete (`[x]`) and commit the change to the branch before creating the PR45 - If no matching item exists, skip this step46476. **Identify and link related issues** (discover → classify → confirm; don't rely on recall):48 - **If `--skip-issue-link`**: skip this step entirely.49 - **Determine the primary issue(s) P:**50 - `--issue N` (accepts a comma-separated list, e.g. `--issue 123,175`) → use directly as Close targets; skip discovery.51 - Otherwise extract from the branch name (`fix/gh-123-...` → P=123). If none can be determined, warn and ask whether to proceed with no linking.52 - **Discover candidates mechanically** (do not depend on having read the issue earlier in the session):53 - Fetch the primary issue's body and comments: `gh issue view P --json number,title,body,comments`54 - Extract every `#<number>` reference from that output.55 - For each referenced issue M, get its state: `gh issue view M --json number,title,state` — drop anything already closed or that is a PR.56 - **Classify each open candidate by the language around the mention:**57 - `closes` / `fixes` / `resolves #M`, or M is an unchecked task-list item this PR completes → **Close** (`Closes #M`)58 - `part of` / `blocked by` / `relates to` / `see` / `parent #M` → **Reference** (`Refs #M`, no closing keyword)59 - ambiguous → default to **Reference** and flag it60 - **Confirm before creating the PR:**61 - Only the primary issue P, no other open candidates → proceed silently with `Closes #P`.62 - More than one candidate, or any ambiguous one → print a short table (issue · title · proposed Close/Ref) and ask for a one-line confirm/override first.63 - **Format:** one keyword per line so GitHub parses them all — `Closes #N` per close target, `Refs #N` per reference.64657. **Create the PR**:66 - Use `gh pr create` with generated title and description67 - Set base branch (usually main/master)68 - **Default to ready** (no `--draft` flag) unless `--draft` flag is explicitly passed69708. **Confirm and validate**:71 - Show PR URL and title72 - Confirm issue linking (e.g., "✅ Linked to issue #123" or "⚠️ No issues linked")73 - **Cross-check linking:** every Close/Ref target identified in step 6 actually appears in the final description. If one is missing, warn before the PR is considered done (guards against silently dropping a second issue).74 - **Validate PR metadata (warn, don't block):** confirm the title follows Conventional Commits and the description contains a closing keyword (`Closes #N`). If either is missing, surface a warning so it can be fixed before review. (These checks previously lived in the retired `/review-pr`.)7576## PR Description Template7778```markdown79## Summary8081- What this PR does82- Key changes made8384## Changes8586- List of changes from commits8788## Testing8990- [ ] Tests pass91- [ ] Manual testing done9293Closes #12394```9596## Example Usage9798```bash99# Default: Automatically detects issue from branch name (e.g., fix/gh-123-description)100/create-pr101102# Explicit issue linking (when branch name doesn't contain an issue number)103/create-pr --issue 123104105# Explicit multi-issue linking (PR closes more than one issue)106/create-pr --issue 123,175107108# Skip issue linking entirely109/create-pr --skip-issue-link110```