# Draft a GitHub pull request in Claude Code with a /pr slash command

> Source: <https://dev.to/vildandenai/draft-a-github-pull-request-in-claude-code-with-a-pr-slash-command-4ai4>
> Published: 2026-11-20 00:56:33+00:00

**Recommendation:** Move repeated PR-drafting prompts into a .claude/commands/pr.md slash command that gathers git status, log and diff, proposes the title and body, and waits for confirmation before running gh pr create.
More in the playbook "Working with AI coding agents": <https://wpnews.pro/playbooks/coding-agents>

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.

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`.

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.

`gh pr create` if you also want a permissions bump.`/commit` command so the branch messages and the PR body stay consistent.
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/](https://justly-mia-429.rehost.page/)
