一键导入
create-pr
Create or update a GitHub PR with automatic template detection and filling
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Create or update a GitHub PR with automatic template detection and filling
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | create-pr |
| description | Create or update a GitHub PR with automatic template detection and filling |
| argument-hint | [--draft] [--force] [<title>] |
Create (or update) a GitHub pull request using gh, auto-detecting and filling any PR template.
--draft — create the PR as a draft--force — skip preview and confirmation; create or update immediately<title> — optional title hint; if omitted, derive from commitsExample invocations:
/create-pr/create-pr --draft/create-pr --force/create-pr Add support for webhook retries/create-pr --draft Fix race condition in job queue/create-pr --force --draft Fix race condition in job queueExtract from user input:
draft = true if --draft is presentforce = true if --force is presenttitle_hint = remaining text after stripping --draft and --force, or empty stringDetermine the base branch and gather context. The base is normally the repo's default branch, but for stacked PRs (e.g. created with gt) it's the parent branch in the stack.
head=$(git rev-parse --abbrev-ref HEAD) # current branch
default_branch=$(bash "$HOME/.dotfiles/bin/lib/git-default-branch.sh") # default branch (bare name)
If the helper is not available or default_branch is empty, tell the user and stop.
Pick the base in this precedence:
# 1. If a PR already exists for this head, honor its base — never silently
# retarget it. Use `gh pr list --head` (queries the API by branch name)
# rather than `gh pr view`, which depends on local upstream tracking and
# can miss PRs in worktrees or after re-clones.
existing_pr=$(gh pr list --head "$head" --state open --json number,baseRefName --jq '.[0]' 2>/dev/null || true)
existing_base=$(printf '%s' "$existing_pr" | jq -r '.baseRefName // empty' 2>/dev/null || true)
# 2. Ask gt for the parent (current gt stores stack metadata in
# .git/.graphite_cache_persist, not in git config). Gate on `command -v gt`
# so the skill works for users without gt installed.
gt_parent=""
if command -v gt >/dev/null 2>&1; then
gt_parent=$(gt parent 2>/dev/null || true)
fi
if [ -n "$existing_base" ]; then
base="$existing_base"
stacked=$([ "$base" != "$default_branch" ] && echo true || echo false)
elif [ -n "$gt_parent" ] && [ "$gt_parent" != "$default_branch" ]; then
base="$gt_parent"
stacked=true
else
base="$default_branch"
stacked=false
fi
Then, using $base, run in parallel:
git log origin/$base..HEAD --oneline # commits on this branch
git diff origin/$base...HEAD # full diff vs base
gh pr list --head "$head" --state open --json number,title,body,isDraft,url --jq '.[0]' # existing PR, if any
If a PR already exists, note its number and URL — you will update it rather than create a new one (see Step 8). Use gh pr list --head rather than gh pr view: it queries by branch name (reliable in worktrees and after re-clones) instead of relying on local upstream tracking.
Check these locations in order and stop at the first match:
.github/pull_request_template.md.github/PULL_REQUEST_TEMPLATE.md.github/PULL_REQUEST_TEMPLATE/ — use default.md if it exists, otherwise the only file present; if multiple files with no clear default, ask the user which to usedocs/pull_request_template.mdpull_request_template.mdCheck for a saved manual test plan (produced by /test-plan):
test_plan_path=".context/test-plan.md"
[ -f "$test_plan_path" ] && test_plan_content=$(cat "$test_plan_path")
If the file exists, hold its full contents for use in Step 5. If not, skip — the body composition step writes its own short test plan instead.
Title:
title_hint is non-empty, use it as the title (trim and keep under 70 characters)Body:
If a template was found, fill each section using the commits and diff:
<<'EOF'), which is literal; write `foo` not \`foo\`, and $var not \$varPR description voice — write the way an engineer talks, not the way an LLM writes:
If no template was found, write:
Embedding the saved test plan (if test_plan_content is set):
If a saved test plan was detected in Step 4, embed it inside the PR's testing section. Locate the testing section by matching the first heading whose title contains any of: Test plan, Testing, How did you test, QA. If no such heading exists in the template, append a ## Test plan section at the end.
Insert this block as the section's content (replacing any auto-generated test plan you would otherwise have written):
<details>
<summary>Manual test plan</summary>
<contents of .context/test-plan.md verbatim, with any leading `## Test plan` heading stripped>
</details>
Notes:
## Test plan (or equivalent) heading from the file contents before insertion — the surrounding section heading already provides that context- [ ] checkbox format exactly; do not re-wrap or reformat<details> and </details> so GitHub renders the collapsible block correctly<details> block rather than stacking themIf force is true, skip to Step 7 immediately — do not show a preview or ask for confirmation.
Otherwise, display the proposed PR to the user. When stacked=true, include the base in the header so the non-default target is obvious:
Title: <title>
Base: <base> # only show this line when stacked=true; append " (stacked)"
Draft: yes/no
<body>
Ask: "Create this PR? Reply yes to confirm, or describe any changes to make."
Wait for confirmation. If the user requests edits, apply them and show the updated preview before proceeding.
When stacked=true, the parent branch must already exist on origin — GitHub can't open a PR against a base it doesn't have. Check first:
if [ "$stacked" = "true" ] && [ -z "$(git ls-remote --heads origin "$base")" ]; then
echo "Parent branch '$base' is not on origin yet. Push it first (e.g. 'gt submit --stack' or 'git push origin $base') and re-run."
exit 1
fi
Don't push the parent automatically — that's a stack-wide action and belongs to gt.
Then push HEAD:
git push --set-upstream origin HEAD
If the push fails, report the error and stop.
New PR:
gh pr create \
--base <base> \
--title "<title>" \
--body "$(cat <<'EOF'
<body>
EOF
)" \
[--draft if draft=true]
Existing PR (found in Step 2 — note the existing body may already contain a <details><summary>Manual test plan</summary>…</details> block; replace it with the new one rather than appending):
gh pr edit <number> \
--title "<title>" \
--body "$(cat <<'EOF'
<body>
EOF
)"
If draft=true and the existing PR is not already a draft:
gh pr ready --undo <number>
If draft=false and the existing PR is a draft:
gh pr ready <number>
On success, display the PR URL. On failure, show the full error output and stop — do not retry silently.
Monitor CI checks after pushing, detect flaky vs legit failures, and auto-fix
End-of-day counterpart to wake-me-up. Reads today's morning briefing at ~/dev/ai/notes/wake-me-up/{date}.md, asks the user what they shipped or resolved, drafts a Slack wrap-up post in the user's voice, shows the draft for explicit confirmation, then posts it on the user's behalf via the Slack MCP. Appends the posted summary back to the briefing file so the file is a full day record. Use when the user says "/closing-time", "wrap the day", "end of day post", or wants help summarizing what they did.
Commit staged/unstaged changes with a well-crafted commit message.
Plan, implement, and iteratively review a task end-to-end using Claude + Copilot reviewers in a linear flow.
Investigate what it would take to upgrade a library from its currently pinned version to a target version (or "latest"). Produces a migration assessment — version delta, breaking changes that apply to us, impacted files, estimated blast radius, suggested rollout — and STOPS there. Does not perform the upgrade unless the user explicitly asks. Use when the user says "investigate updating <pkg> from X to Y", "investigate updating <pkg> to latest", "we are behind on <pkg>", or "let's update <pkg> to version N".
Shepherds a PR through the repetitive loop: run qa-swarm when there are substantive changes, triage qa-swarm findings, triage AI/bot review comments, keep the branch current with its base, watch CI, and apply the `stamphog` label once green. Use when the user says "/pr-shepherd", "shepherd this PR", "babysit this PR", or wants the whole review loop driven automatically. Accepts an optional PR number or URL as argument.