cd /news/ai-tools/draft-a-github-pull-request-in-claud… · home › topics › ai-tools › article
[ARTICLE · art-172944] src=dev.to ↗ pub= topic=ai-tools verified=true sentiment=↑ positive

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

A developer published a reusable Claude Code slash command, saved as .claude/commands/pr.md, that drafts a GitHub pull request from the current branch by running git status, log and diff, then proposing a title and body with a summary, test plan and follow-ups. The command uses $ARGUMENTS to accept a base branch or extra instructions and is written to wait for confirmation before running gh pr create, with explicit rules against force-pushing, merging or adding unnamed reviewers.

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 playbook: Working with AI coding agents
by read1 min views2 publishedNov 20, 2026

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/

── more in #ai-tools 4 stories · sorted by recency
── more on @claude code 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/draft-a-github-pull-…] indexed:0 read:1min 2026-11-20 · —