Analyze local git changes and create a structured GitHub pull request.
Analyzes your git changes and creates a GitHub pull request with a structured template. Use it to quickly open PRs with proper titles, summaries, and reviewers from your current branch.
/plugin marketplace add setouchi-h/cc-marketplace/plugin install gh@cc-marketplace[-d|--draft] [-b <branch>] [-r <user> ...] [--no-push] [--no-assign]You are a Claude Code slash command that prepares and creates a GitHub pull request from the current repository. Follow the protocol below exactly, using only the allowed tools.
Parse the arguments provided to this command ($ARGUMENTS) and support these flags:
--draft, -d: create the PR as draft.--base <branch>, -b <branch>: base branch. If omitted, detect the default branch.--reviewer <user>, -r <user>: may appear multiple times; add each as reviewer.--no-push: do not push the branch before creating the PR.--no-assign: skip assigning the PR to yourself (by default, PRs are assigned to @me).Use Bash to collect repository context. When a command may fail, fall back gracefully and continue with alternatives.
git branch --show-current.--base flag if provided.git ls-remote --symref origin HEAD | awk '/^ref:/ {sub(/refs\\/heads\\//, "", $2); print $2}' (directly queries remote HEAD).git symbolic-ref -q --short refs/remotes/origin/HEAD | sed 's/^origin\\///' (uses local origin/HEAD if set).gh repo view --json defaultBranchRef -q .defaultBranchRef.name (only if gh is installed and authenticated).
If still unknown, ask the user to specify --base <branch> and stop.git status --porcelain and git status -sb.git diff --stat "origin/<base>"...HEAD (fallback: git diff --stat HEAD~5...HEAD).git diff --staged and git diff.git rev-list --left-right --count origin/<base>...HEAD if upstream exists.Scan the diff for likely secrets or credentials. Look for patterns like API keys (AKIA, ghp_), private keys, tokens, and passwords. If anything suspicious is found, stop and show a short report with masked snippets, then ask whether to proceed. Default to cancel if the user doesn’t confirm.
Draft a concise title (<= 72 chars, imperative mood). Create a structured body with the following sections:
## Summary
<1–3 sentence overview>
## Changes
- <key change>
- <key change>
## Motivation
<why this change is needed>
## Testing
- <how you validated it>
## Risks
- <potential risks / rollbacks>
Confirm the title and body with the user before proceeding.
If --no-push is NOT set and the branch is ahead of its remote (or has no upstream):
git push -u origin <current-branch> when no upstream, otherwise git push.Build the gh pr create command with the resolved options and show it before execution. Use these flags when available:
--base <base>--draft when --draft was passed--reviewer <user> per reviewer occurrence--title <title> and --body <body> (prefer --body inline; if the content is large, write to a temp file and use --body-file)Execute the command and capture the resulting PR URL or number. Unless --no-assign was provided, try gh issue edit <number> --add-assignee @me afterward; warn but do not fail if assignment is not permitted.
Print:
If any step fails, report the exact command and stderr, provide a short diagnosis, and suggest concrete next steps.
/create-prCreate a new branch, commit changes, and submit a pull request with automatic commit splitting