{"slug": "draft-a-github-pull-request-in-claude-code-with-a-pr-slash-command", "title": "Draft a GitHub pull request in Claude Code with a /pr slash command", "summary": "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.", "body_md": "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.\n\nSave this as `.claude/commands/pr.md`:\n\n```\n---\ndescription: \"Draft a GitHub pull request from the current branch\"\nargument-hint: \"[base branch | extra instructions]\"\n---\n\nDraft a GitHub pull request for the current branch. Do not create it until I confirm.\n\n1. 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.\n2. 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.\n3. 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.\n4. 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.\n```\n\nUse it as `/pr`, `/pr main`, or `/pr develop include a migration note`.\n\nSlash 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.\n\n`gh pr create` if you also want a permissions bump.`/commit` command so the branch messages and the PR body stay consistent.\nI 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/)", "url": "https://wpnews.pro/news/draft-a-github-pull-request-in-claude-code-with-a-pr-slash-command", "canonical_source": "https://dev.to/vildandenai/draft-a-github-pull-request-in-claude-code-with-a-pr-slash-command-4ai4", "published_at": "2026-11-20 00:56:33+00:00", "updated_at": "2026-11-20 01:13:16.318656+00:00", "lang": "en", "topics": ["ai-tools", "ai-agents", "developer-tools", "ai-products"], "entities": ["Claude Code", "GitHub", "Anthropic", "Vildanden Agent Config"], "also_reported_by": [], "takeaway": "Packaging a repeated PR-drafting prompt into a .claude/commands/pr.md slash command with $ARGUMENTS for the base branch and explicit 'wait for confirm, never force-push or merge' rules cuts unattended PR creation.", "recommendation": {"advice": "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.", "playbook": "coding-agents", "playbook_url": "https://wpnews.pro/playbooks/coding-agents"}, "alternates": {"html": "https://wpnews.pro/news/draft-a-github-pull-request-in-claude-code-with-a-pr-slash-command", "markdown": "https://wpnews.pro/news/draft-a-github-pull-request-in-claude-code-with-a-pr-slash-command.md", "text": "https://wpnews.pro/news/draft-a-github-pull-request-in-claude-code-with-a-pr-slash-command.txt", "jsonld": "https://wpnews.pro/news/draft-a-github-pull-request-in-claude-code-with-a-pr-slash-command.jsonld"}}