create-pr
GitHub在git-push后创建或更新GitHub PR。流程包括:检查并选择基准分支,本地审查差异并同步;构建标题、正文及Issue链接;优先复用现有开放PR以避免重复,否则新建。确保内容安全、引用准确,并提供PR URL报告。
Trigger Scenarios
Install
npx skills add Terry-Mao/AICodingFlow --skill create-pr -g -y
SKILL.md
Frontmatter
{
"name": "create-pr",
"description": "Create or update a GitHub pull request from a pushed branch after local review, base-branch sync, validation, and issue linking."
}
create-pr
Use this after git-push when the user asks to create, update, or open a GitHub pull request.
Goal
Create or update a review-ready PR from the current branch after syncing the base branch, reviewing the diff locally, and linking the related task.
Workflow
-
Inspect and choose base Run:
git status --short git branch --show-current git status -sbPrefer the repo's default PR base. If repo guidance names a different base, use that. If the worktree is dirty, pause unless the changes are intentionally excluded from the PR.
-
Review and sync locally Run:
git diff --stat <base>...HEAD git diff <base>...HEADReview the diff for accidental files, secrets, conflict markers, generated churn, and missing tests or docs. Fetch the base branch and make sure it has been merged or rebased into the current branch before creating or updating the PR. If conflicts occur, resolve them locally, rerun relevant validation, commit the resolution, and push through
git-pushso any configuredpre-pushhook runs. -
Build title, body, and issue link Default the title from the issue title or the main commit subject. Infer issue links from the user request, branch name, or commits. Do not invent issue IDs. Keep the body concise and include:
- summary
- validation performed
- issue link such as
Closes #123,Fixes #123, orRefs #123when known
-
Create or update PR Use GitHub CLI when available. First check only for an open PR from the current branch. Do not use
gh pr viewas the existence check because it may resolve a previously merged or closed PR for the same branch name:pr_url="$(gh pr list --state open --head "$branch" --json url --jq '.[0].url' --limit 1)"If
pr_urlis not empty, update that open PR instead of creating a duplicate:gh pr edit "$pr_url" --title "$title" --body-file "$body_file"Before editing an open existing PR, read the current body and preserve user-authored content that is not clearly generated by this workflow. Do not overwrite manual notes, review context, checklist items, or release details just to apply the generated summary. If there is no open PR, create one. A merged or closed PR with the same branch name is not reusable and must not block creation of a new PR:
gh pr create --base "$base" --head "$branch" --title "$title" --body-file "$body_file"Pass generated title/body/base/head values as separate argv-style arguments. Do not paste user-, issue-, branch-, or commit-derived text directly into a shell command line; if using shell variables, populate them without
evalor command substitution and always quote expansions.
If gh is unavailable or not authenticated, report the exact title/body/base/head needed to create or update the PR manually.
Reporting
After creating or finding a PR, report:
- PR URL
- base branch
- head branch
- title
- validation included in the body
- whether the base branch was merged or rebased locally
- remind the user to watch CI, respond to review comments, and keep the PR current by regularly merging or rebasing the base branch
Version History
- e53c5ac Current 2026-07-24 11:35


