AgentSkillsCN

pull-request:create

按照规范的格式与内容准则,创建Pull Request、Merge Request或Change Request。 当用户希望创建、打开或提交PR、MR或CR时,此工具均可派上用场——即便是在完成代码提交之后,亦可随时调用。

SKILL.md
--- frontmatter
name: pull-request:create
description: |
  Create a pull request, merge request, or change request with proper formatting and content guidelines.
  Invoke when the user wants to create, open, or submit a PR, MR, or CR—including after committing changes.

allowed-tools: Bash(bun:${CLAUDE_PLUGIN_ROOT}/scripts/*), Bash(${CLAUDE_PLUGIN_ROOT}/scripts/worktree/*), Bash(gh:*), Bash(git:*), Bash(glab:*), mcp__github

Create Pull Request

Context

  • Provider: !bun "${CLAUDE_PLUGIN_ROOT}/scripts/detect-provider.ts" "$0"
  • Branch: !"${CLAUDE_PLUGIN_ROOT}/scripts/worktree/git.sh" "$0" branch --show-current
  • Status: !"${CLAUDE_PLUGIN_ROOT}/scripts/worktree/git.sh" "$0" status --short
  • Log: !"${CLAUDE_PLUGIN_ROOT}/scripts/worktree/git.sh" "$0" log --oneline -20
  • Diff: !"${CLAUDE_PLUGIN_ROOT}/scripts/worktree/git.sh" "$0" diff HEAD

Title

  • Check the log above to determine the repo's commit style:
    • subject (default): ${subject}: ${summary} (e.g., api: add timeout to request)
    • conventional: ${type}: ${summary} (e.g., fix: add timeout to request)
  • Keep under 50 characters, max 100
  • Use imperative mood, lowercase except proper nouns

Body

  • Start with 1-3 sentences summarizing the change (no preceding header)
  • Wrap all code identifiers with backticks: function names, class names, file paths, endpoints, status codes, etc.
  • Use ## sections for larger changes. See sections.md for detailed guidance on:
    • ## Issue - Root cause analysis and issue linking
    • ## Changes - High-level description of changes
    • ## Testing - Test coverage insights
    • ## References - Related links and issues

Issue Handling

When an issue is referenced:

  • ONLY reference the issue in the PR body (e.g., Closes #123, Fixes #456)
  • NEVER modify the issue directly - no comments, labels, milestones, or assignees

Workflow

  1. Branch validation: If the context shows you're on a default branch (main/master) and no $0 argument was provided, stop and tell the user to specify the target branch: /pull-request:create <branch>. When a branch argument is provided, all git/gh/glab commands must run in that branch's worktree using the wrapper scripts.
  2. Stage changes if not already staged:
    • With $0: "${CLAUDE_PLUGIN_ROOT}/scripts/worktree/git.sh" "$0" add .
    • Without $0: git add .
  3. Commit if there are no commits yet on the branch. Follow the same format for the commit message as for the pull request title (conventional or subject-oriented based on repo standard):
    • With $0: "${CLAUDE_PLUGIN_ROOT}/scripts/worktree/git.sh" "$0" commit -m "..."
    • Without $0: git commit -m "..."
  4. Push the branch to remote:
    • With $0: "${CLAUDE_PLUGIN_ROOT}/scripts/worktree/git.sh" "$0" push -u origin "$0"
    • Without $0: git push -u origin HEAD
  5. Create the PR/MR:
    • Write the body to a temp file first (e.g., tmp/pr-body-<branch>.md)
    • Include the branch name in the filename to avoid conflicts with concurrent agents
    • GitHub with $0: "${CLAUDE_PLUGIN_ROOT}/scripts/worktree/gh.sh" "$0" pr create --title "..." --body-file tmp/pr-body-<branch>.md
    • GitHub without $0: gh pr create --title "..." --body-file tmp/pr-body-<branch>.md
    • GitLab with $0: "${CLAUDE_PLUGIN_ROOT}/scripts/worktree/glab.sh" "$0" mr create --title "..." --description "$(cat tmp/pr-body-<branch>.md)"
    • GitLab without $0: glab mr create --title "..." --description "$(cat tmp/pr-body-<branch>.md)"

GitLab Notes

For advanced GitLab features (stacking, username lookup), load gitlab:merge-request.