Open a pull request

Claude Code slash command (.claude/commands/pr.md). Pushes the branch if needed, generates a PR title and body from the diff against the base branch, and opens the PR with gh after confirmation.

License: CC0-1.0 · By waxmark · v1 · 2026-11-02

Share on X

Add a trust badge to your README

[![Waxmark](https://waxmark.app/api/badge/pr)](https://waxmark.app/items/pr/scan)
Report
---
description: Generate a PR title and body from this branch's changes and open the pull request with gh
argument-hint: [base-branch, default main] [--draft]
allowed-tools: Bash(git status *), Bash(git branch *), Bash(git log *), Bash(git diff *), Bash(git rev-parse *), Bash(git merge-base *), Bash(git push *), Bash(gh pr *), Bash(gh repo *), Read
disable-model-invocation: true
---

Open a pull request for the current branch.

Arguments: $ARGUMENTS (first token is the base branch, default `main`; `--draft` opens as draft)

Branch and status:
!`git status -sb`

Commits on this branch not on the base (assumes main; adjust if the user passed a base):
!`git log --oneline main..HEAD`

Diff summary:
!`git diff --stat main...HEAD`

Full diff:
!`git diff main...HEAD`

Steps:
1. If a base branch other than `main` was given, re-run the log and diff commands against it before continuing.
2. If there are uncommitted changes, stop and ask whether to commit them first.
3. If `.github/pull_request_template.md` exists, read it and fill its sections. Otherwise use: **Summary** (2-4 sentences: problem, approach, result), **Changes** (bullets grouped by purpose, key files in backticks), **Testing** (only what the diff or commits show evidence of; checkboxes), **Risks and rollout** (migrations, flags, env vars, rollback), and `Closes #N` if an issue is referenced in commits or branch name.
4. Title: a Conventional Commit subject under 70 characters.
5. Show the title and body and ask for confirmation.
6. On yes: push with `git push -u origin HEAD` if the branch has no upstream, write the body to a temp file, then run
   `gh pr create --base <base> --title "<title>" --body-file <tmp> [--draft]`.
7. Print the PR URL.

Never force-push. Never open the PR without showing the body first.
Open a pull request · Waxmark