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)
- •subject (default):
- •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. Seesections.mdfor 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
- •Branch validation: If the context shows you're on a default branch (main/master) and no
$0argument 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. - •Stage changes if not already staged:
- •With
$0:"${CLAUDE_PLUGIN_ROOT}/scripts/worktree/git.sh" "$0" add . - •Without
$0:git add .
- •With
- •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 "..."
- •With
- •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
- •With
- •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)"
- •Write the body to a temp file first (e.g.,
GitLab Notes
For advanced GitLab features (stacking, username lookup), load gitlab:merge-request.