Draft a GitHub pull request in Claude Code with a /pr slash command
If you keep pasting the branch diff and "write a PR title and body, then wait" into Claude Code, turn that prompt into a slash command. The file name becomes the command; $ARGUMENTS lets you name the base branch or add extra instructions.
The command
Save this as .claude/commands/pr.md:
--- description: "Draft a GitHub pull request from the current branch" argument-hint: "[base branch | extra instructions]" --- Draft a GitHub pull request for the current branch. Do not create it until I confirm. 1. Run `git status -sb`, `git log --oneline -15`, and `git diff origin/HEAD...HEAD` (or `main...HEAD` if `origin/HEAD` is missing). If there is no unique commit versus the base, stop and say so. 2. If I passed arguments (`$ARGUMENTS`), treat the first token as a base branch when it looks like one (`main`, `master`, `develop`, or `origin/...`). Treat the rest as extra instructions. 3. Propose a PR title and a body with a short summary, a test plan, and any follow-ups. Do not add AI attribution unless I ask. 4. Show the title and body and wait for me to confirm before running `gh pr create`. Never force-push, never merge, and never add reviewers I did not name. Use it as /pr, /pr main, or /pr develop include a migration note.
Why this beats a pasted prompt
Slash commands are markdown files in .claude/commands. Claude Code injects the file as the prompt and replaces $ARGUMENTS with whatever you type after the command. Keeping "wait for confirm" and "never force-push or merge" in the command reduces unattended PR creation.
Tips
- Pair this with an "ask" permission rule for
gh pr createif you also want a permissions bump. - Commit the command file so every teammate gets the same workflow.
- Pair with a
/commitcommand so the branch messages and the PR body stay consistent.
Want the rest of the setup?
I keep copy-ready Claude Code configs (CLAUDE.md templates, slash commands, hooks, permission rules) in Vildanden Agent Config. There's a free sample: https://justly-mia-429.rehost.page/