| name | creating-pr |
| description | Creates GitHub Pull Requests with existing PR detection, branch pushing, and intelligent title/body generation. Use when user requests to create pull request, open PR, update PR, push for review, ready for review, send for review, get this reviewed, make a PR, share code, request review, create draft PR, submit for review, run /create-pr command, or mentions "PR", "pull request", "merge request", "code review", "GitHub PR", or "draft". |
| model | haiku |
⚠️ CRITICAL CONSTRAINTS
No Claude Code Footer Policy
YOU MUST NEVER add Claude Code attribution to pull requests.
- ❌ NO "🤖 Generated with [Claude Code]" in PR titles or descriptions
- ❌ NO "Co-Authored-By: Claude noreply@anthropic.com" in PR content
- ❌ NO Claude Code attribution, footer, or branding of any kind
Pull requests are public code review documents and must remain clean and professional.
GitHub PR Creation Workflow
Execute GitHub Pull Request workflows with automatic repository detection, branch management, and intelligent PR content generation.
Usage
This skill is invoked when:
- User runs
/create-pr or /git:create-pr command
- User requests to create a pull request
- User asks to open a PR or push changes for review
How It Works
This skill handles the complete PR workflow:
- Repository Detection - Detect current repository context (root or submodule)
- Branch Validation - Verify not on protected branch, check for uncommitted changes
- Branch Pushing - Ensure branch exists on remote
- Existing PR Detection - Check if PR already exists for current branch
- PR Content Generation - Create title and description from commits
- PR Creation - Create or update PR using GitHub CLI
Supported Arguments
Parse arguments from user input:
- No arguments: Auto-detect repository and create PR to main branch
<scope>: Direct PR for specific repository (root, submodule-name)
--draft: Create as draft PR
--base <branch>: Target branch (default: main)
- Combinations:
<scope> --draft, root --base staging, etc.
Prerequisites
GitHub CLI Required: Must have gh installed and authenticated
gh auth login
PR Creation Workflow Steps
Step 1: Parse Arguments
Extract scope, draft flag, and base branch from user input:
SCOPE=""
DRAFT_FLAG=""
BASE_BRANCH="main"
Step 2: Detect Repository Context
Find monorepo root and determine current repository:
if SUPERPROJECT=$(git rev-parse --show-superproject-working-tree 2>/dev/null) && [ -n "$SUPERPROJECT" ]; then
MONOREPO_ROOT="$SUPERPROJECT"
else
MONOREPO_ROOT=$(git rev-parse --show-toplevel)
fi
CURRENT_DIR=$(pwd)
if [ -n "$SCOPE" ]; then
if [ "$SCOPE" = "root" ]; then
REPO_PATH="$MONOREPO_ROOT"
else
REPO_PATH="$MONOREPO_ROOT/$SCOPE"
fi
else
if [[ "$CURRENT_DIR" == "$MONOREPO_ROOT" ]]; then
REPO_PATH="$MONOREPO_ROOT"
else
REPO_PATH=$(git -C "$CURRENT_DIR" rev-parse --show-toplevel)
fi
[ ! -d ];
>&2
1
Step 3: Validate Branch State
Check current branch and uncommitted changes:
cd "$REPO_PATH"
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [ "$CURRENT_BRANCH" = "main" ] || [ "$CURRENT_BRANCH" = "master" ]; then
echo "❌ Cannot create PR from protected branch: $CURRENT_BRANCH" >&2
echo "" >&2
echo "Please create a feature branch first:" >&2
echo " git checkout -b feature/your-feature-name" >&2
echo "" >&2
exit 1
fi
UNCOMMITTED=$(git status --porcelain)
if [ -n "$UNCOMMITTED" ]; then
echo "❌ Error: You have uncommitted changes" >&2
echo "" >&2
echo "Please commit or stash your changes before creating a PR:" >&2
git status --short
echo "" >&2
exit 1
fi
COMMITS_AHEAD=$(git rev-list --count "$BASE_BRANCH..HEAD" 2>/dev/null || echo "0")
if [ = ];
>&2
>&2
1
Step 4: Push Branch to Remote
Ensure branch exists on remote:
REMOTE_BRANCH=$(git ls-remote --heads origin "$CURRENT_BRANCH" 2>/dev/null)
if [ -z "$REMOTE_BRANCH" ]; then
echo "ℹ️ Branch not on remote, pushing..."
git push -u origin "$CURRENT_BRANCH" || {
echo "❌ Failed to push branch to remote" >&2
exit 1
}
echo "✅ Branch pushed to origin/$CURRENT_BRANCH"
else
LOCAL_HASH=$(git rev-parse HEAD)
REMOTE_HASH=$(git rev-parse "origin/$CURRENT_BRANCH" 2>/dev/null || echo "")
if [ "$LOCAL_HASH" != "$REMOTE_HASH" ]; then
echo "ℹ️ Local branch differs from remote, pushing..."
git push origin "$CURRENT_BRANCH" || {
echo "❌ Failed to push branch to remote" >&2
exit 1
}
echo "✅ Branch updated on remote"
else
echo "ℹ️ Branch already up to date on remote"
fi
fi
Step 5: Check for Existing PR
Detect if PR already exists for this branch:
EXISTING_PR=$(gh pr view "$CURRENT_BRANCH" --json number,title,url 2>/dev/null || echo "")
if [ -n "$EXISTING_PR" ]; then
PR_NUMBER=$(echo "$EXISTING_PR" | jq -r '.number')
PR_TITLE=$(echo "$EXISTING_PR" | jq -r '.title')
PR_URL=$(echo "$EXISTING_PR" | jq -r '.url')
echo ""
echo "ℹ️ Existing PR found:"
echo " #$PR_NUMBER: $PR_TITLE"
echo " $PR_URL"
echo ""
Step 6: Generate PR Title
Analyze commits to create conventional PR title:
COMMITS=$(git log "$BASE_BRANCH..HEAD" --oneline)
COMMIT_COUNT=$(echo "$COMMITS" | wc -l | tr -d ' ')
echo "ℹ️ Analyzing $COMMIT_COUNT commits..."
LATEST_COMMIT=$(git log -1 --pretty=%B)
if echo "$LATEST_COMMIT" | grep -qE '^(feat|fix|docs|refactor|test|chore|perf|ci|build):'; then
COMMIT_TYPE=$(echo "$LATEST_COMMIT" | grep -oE '^[a-z]+' | head -1)
COMMIT_DESC=$(echo "$LATEST_COMMIT" | sed -E 's/^[a-z]+(\([^)]+\))?:\s*//')
else
ALL_COMMITS=$(git log "$BASE_BRANCH..HEAD" --pretty=%B)
if echo "$ALL_COMMITS" | grep -qi "fix\|bug"; then
COMMIT_TYPE="fix"
elif echo | grep -qi ;
COMMIT_TYPE=
| grep -qi ;
COMMIT_TYPE=
| grep -qi ;
COMMIT_TYPE=
| grep -qi ;
COMMIT_TYPE=
COMMIT_TYPE=
COMMIT_DESC=$( | -1 | sed )
PR_TITLE=
Step 7: Generate PR Body
Create PR description with summary and test plan:
PR_BODY="## Summary
"
if [ "$COMMIT_COUNT" -eq 1 ]; then
PR_BODY+="$LATEST_COMMIT
"
else
PR_BODY+="This PR includes $COMMIT_COUNT commits:
"
while IFS= read -r commit; do
PR_BODY+="- $commit
"
done <<< "$COMMITS"
PR_BODY+="
"
fi
PR_BODY+="## Test Plan
- [ ] Code builds successfully
- [ ] Tests pass
- [ ] Manual testing completed
- [ ] Documentation updated (if needed)
## Changes
"
CHANGED_FILES=$(git diff --name-only "$BASE_BRANCH..HEAD")
while IFS= read -r file; do
PR_BODY+="- \`$file\`
"
done <<< "$CHANGED_FILES"
echo ""
echo "Generated PR description:"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "$PR_BODY"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
Step 8: Create PR
Use GitHub CLI to create the PR:
GH_CMD="gh pr create --title \"$PR_TITLE\" --body \"$PR_BODY\" --base \"$BASE_BRANCH\""
if [ "$DRAFT_FLAG" = "--draft" ]; then
GH_CMD+=" --draft"
fi
eval "$GH_CMD" || {
echo "❌ Failed to create PR" >&2
exit 1
}
PR_URL=$(gh pr view --json url -q '.url')
echo ""
echo "✅ Pull Request created successfully!"
echo ""
echo "PR URL: $PR_URL"
echo ""
echo "Next steps:"
echo " - Review PR in browser: gh pr view --web"
echo " - Check CI status: gh pr checks"
echo " - Request reviews: gh pr ready (if draft)"
echo ""
Alternative: Update Existing PR
If updating an existing PR (user chose "Update" in Step 5):
gh pr edit "$PR_NUMBER" --title "$PR_TITLE" --body "$PR_BODY" || {
echo "❌ Failed to update PR" >&2
exit 1
}
echo "✅ Pull Request #$PR_NUMBER updated successfully!"
echo "PR URL: $PR_URL"
PR Title Generation Rules
The skill generates PR titles following conventional commit format:
| Detected Pattern | Type | Example Title |
|---|
| "feat:" in commits | feat | feat: add user authentication |
| "fix:" in commits | fix | fix: resolve login timeout issue |
| "docs:" in commits | docs | docs: update API documentation |
| "refactor:" in commits | refactor | refactor: optimize database queries |
| "test:" in commits | test | test: add integration tests |
| Mentions "bug", "fix" | fix | fix: correct calculation error |
| Mentions "feature", "add" | feat | feat: implement new feature |
| Default | feat | feat: [description from commits] |
Important Notes
-
GitHub CLI Required: Must have gh installed and authenticated
gh auth login
-
Branch Protection: Cannot create PR from main/master branch
-
Existing PRs: Automatically detects and offers to update existing PRs
-
Commit-Based Content: PR title and body generated from commit messages
-
Works Anywhere: Executes from any directory, resolves paths absolutely
-
Submodule Support: Can create PRs for both root repository and submodules
-
Clean PR Content: No Claude Code attribution in PR titles or descriptions
GitHub CLI Commands Used
This skill uses the following gh commands:
gh pr view <branch> --json number,title,url
gh pr create --title "..." --body "..." --base <branch> [--draft]
gh pr edit <number> --title "..." --body "..."
gh pr view --web
gh pr checks
Supporting Documentation
For detailed information, see:
- WORKFLOW.md - Step-by-step PR creation process including repository detection, branch management, and GitHub CLI integration
- EXAMPLES.md - Real-world PR scenarios covering features, bug fixes, drafts, and submodule PRs
- TROUBLESHOOTING.md - Common issues and solutions for GitHub CLI errors, authentication, and branch conflicts