# gh-pr > Create or update GitHub Pull Requests with the gh CLI, including deciding whether to create a new PR or only push based on existing PR merge status. Use when the user asks to open/create/edit a PR, generate a PR body/template, or says 'PRを出して/PR作成/gh pr'. Defaults: base=develop, head=current branch (same-branch only; never create/switch branches). - Author: Akio Jinsenji - Repository: akiojin/claude-worktree - Version: 20260208174227 - Stars: 0 - Forks: 0 - Last Updated: 2026-02-08 - Source: https://github.com/akiojin/claude-worktree - Web: https://mule.run/skillshub/@@akiojin/claude-worktree~gh-pr:20260208174227 --- --- name: gh-pr description: "Create or update GitHub Pull Requests with the gh CLI, including deciding whether to create a new PR or only push based on existing PR merge status. Use when the user asks to open/create/edit a PR, generate a PR body/template, or says 'PRを出して/PR作成/gh pr'. Defaults: base=develop, head=current branch (same-branch only; never create/switch branches)." --- # GH PR ## Overview Create or update GitHub Pull Requests with the gh CLI using a detailed body template and strict same-branch rules. ## Decision rules (must follow) 1. **Do not create or switch branches.** Always use the current branch as the PR head. 2. **Check for an existing PR for the current head branch.** - `gh pr list --head
--state all --json number,state,mergedAt,updatedAt,url,title` 3. **If no PR exists** → create a new PR. 4. **If any PR exists and is NOT merged** (`mergedAt` is null) → push only and finish (do **not** create a new PR). - This applies to OPEN or CLOSED (unmerged) PRs. - Only update title/body/labels if the user explicitly requests changes. 5. **If all PRs for the head are merged** → create a new PR from the same head branch. 6. **If multiple PRs exist for the head** → use the most recently updated PR for reporting, but the create vs push decision is based on `mergedAt`. ## Workflow (recommended) 1. **Confirm repo + branches** - Repo root: `git rev-parse --show-toplevel` - Current branch (head): `git rev-parse --abbrev-ref HEAD` - Base branch defaults to `develop` unless user specifies. 2. **Check existing PR for head branch** - Use decision rules above to pick action. - Treat `mergedAt` as the source of truth for "merged". 3. **Ensure the head branch is pushed** - If no upstream: `git push -u origin ` - Otherwise: `git push` 4. **Collect PR inputs (for new PR or explicit update)** - Title, Summary, Context, Changes, Testing, Risk/Impact, Deployment, Screenshots, Related Links, Notes - Optional: labels, reviewers, assignees, draft 5. **Build PR body from template** - Read `references/pr-body-template.md` and fill placeholders. - If info is missing, keep TODO markers and explicitly mention them in the response. 6. **Create or update the PR** - Create: `gh pr create -B