A pasted prompt asking Claude Code to write a PR title and body becomes a reusable slash command stored in .claude/commands/pr.md. The command inspects the branch diff, drafts the pull request, and holds off on creating it until you confirm.
Key points
- Slash commands are markdown files under .claude/commands; the file name becomes the command name.
- $ARGUMENTS injects whatever you type after the command, so you can pass a base branch or extra instructions.
- The command runs git status, git log and git diff origin/HEAD...HEAD to inspect the branch.
- It stops and reports back when the branch has no unique commit against the base.
- Guardrails like wait for confirmation, no force-push and no merge live in the command file.
- An "ask" permission rule on gh pr create adds a second safety layer.
Real-world use
- A developer who repeatedly writes pull request descriptions from the current branch
- Committing the command file so every teammate gets the same PR workflow
- Pairing it with a /commit command to keep branch messages and PR bodies consistent
- Adding an "ask" permission rule on gh pr create to block unattended pull requests
This summary was generated by the agent from the original post on DEV: claudecode. The full text and all rights belong to its author and publisher. Go to original