Command in version-control
pr
Take the current branch from uncommitted work to an open pull request: commit outstanding changes with the git-commit rules if asked, push with upstream tracking, write the PR title and body with the pr-description skill from the full branch diff, link the issue, and open it with gh against the right base. Confirms before pushing and before creating. Use when a branch is ready for review or when asked to open a PR.
- Arguments
- [--draft] [--base BRANCH] [issue number or title hint]
- Model
- inherit
- Allowed tools
- Read, Grep, Glob, Bash(git:*), Bash(gh:*)
Install
As a plugin
Bundled in the git plugin. Add the marketplace once, then install the bundle; it updates with the marketplace.
/plugin marketplace add KhaledSaeed18/dotclaude/plugin install git@dotclaudeAs a single item
Run from the project root; the command lands under .claude/. Copy it to ~/.claude/ to make it global.
npx shadcn@latest add KhaledSaeed18/dotclaude/prFiles installed
.claude/commands/pr.md
What it does
Context
Options: $ARGUMENTS
Branch, upstream, and default base:
!git branch --show-current 2>/dev/null; git rev-parse --abbrev-ref @{upstream} 2>/dev/null || echo "(no upstream)"; gh repo view --json defaultBranchRef --jq .defaultBranchRef.name 2>/dev/null
Uncommitted:
!git status --short 2>/dev/null | head -20
Commits on this branch:
!git log --oneline $(git merge-base HEAD origin/main 2>/dev/null || git merge-base HEAD main 2>/dev/null)..HEAD 2>/dev/null
Existing PR for this branch:
!gh pr view --json number,url,state 2>/dev/null || echo "(none)"
Task
- Refuse on a protected branch. If the current branch is the default branch (or
main/master/develop), stop and ask for a feature branch; do not create one silently. - If a PR already exists, print its URL and offer to update the body instead of creating a duplicate.
- Uncommitted changes: if any, ask whether to commit them first. If yes, apply the
git-commitskill for one commit (explicit staging, repo rules, no AI mentions). If no, proceed with what is committed and say the working tree still has changes. - Push with
git push -u origin <branch>after confirming the branch and remote. A rejected push (non-fast-forward) is reported, never forced. - Write the PR with the
pr-descriptionskill fromgit diff <base>...HEADand the commit messages: a title under 70 characters in the repo's convention, and a body with what changed, why, risk, and how it was tested. If a PR template exists (.github/pull_request_template.md), fill its sections instead. If the arguments include an issue number, addCloses #<n>. - Show the title, body, base, and draft status, then ask for a yes before
gh pr create --base <base> --title ... --body-file ...(--draftwhen asked). Base defaults to the repo's default branch. - Report the PR URL. Do not enable auto-merge, request reviewers, or add labels unless asked.
Inspired by
The role and scope follow the commit-commands plugin's /commit-push-pr command in Anthropic's claude-code repository. That repository is not open-licensed, so nothing is copied from it; every line here was written for this registry.
This is the command as installed, rendered from its source on GitHub. Read it as Markdown.
More in version-control
- clean-branchesList local Git branches that are fully merged or stale and delete them safely after showing what would be removed, protecting main, master, develop, and...
- commitCreate one well-formed commit from the current changes using the git-commit skill's rules: inspect the diff, honour the repo's commitlint and hooks, stage...
- changelogGenerate a changelog or release notes from Git history, grouped by change type, written in user-facing language, with issue/PR links and breaking changes...
- finish-branchWrap up a completed development branch by verifying tests pass, detecting the workspace state, then presenting clear merge / PR / keep / discard options...
- git-commitCommit work the right way by gathering full repo state, respecting the project's commitlint/pre-commit/branch rules, staging only understood files, and...
- git-undoRecover safely from Git mistakes such as discard, unstage, amend, reset, revert, restore lost commits via reflog, recover deleted branches, and fix bad...