creating-pr
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese⚠️ CRITICAL CONSTRAINTS
⚠️ 关键约束
No Claude Code Footer Policy
禁止添加Claude Code页脚政策
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.
绝对不得在拉取请求中添加Claude Code署名。
- ❌ 禁止 在PR标题或描述中添加「🤖 Generated with [Claude Code]」
- ❌ 禁止 在PR内容中添加「Co-Authored-By: Claude noreply@anthropic.com」
- ❌ 禁止 任何形式的Claude Code署名、页脚或品牌标识
拉取请求是公开的代码评审文档,必须保持简洁专业。
GitHub PR Creation Workflow
GitHub PR 创建工作流
Execute GitHub Pull Request workflows with automatic repository detection, branch management, and intelligent PR content generation.
执行GitHub Pull Request工作流,支持自动仓库检测、分支管理和智能PR内容生成。
Usage
使用场景
This skill is invoked when:
- User runs or
/create-prcommand/git:create-pr - User requests to create a pull request
- User asks to open a PR or push changes for review
当以下情况触发本功能:
- 用户运行/create-pr或/git:create-pr命令
- 用户请求创建拉取请求
- 用户要求打开PR或推送变更待审核
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
本功能处理完整的PR工作流:
- 仓库检测 - 检测当前仓库上下文(根仓库或子模块)
- 分支验证 - 验证当前分支不是保护分支,检查是否有未提交的变更
- 分支推送 - 确保分支已推送到远程仓库
- 现有PR检测 - 检查当前分支是否已有对应的PR
- PR内容生成 - 根据提交记录创建标题和描述
- PR创建 - 使用GitHub CLI创建或更新PR
Supported Arguments
支持的参数
Parse arguments from user input:
- No arguments: Auto-detect repository and create PR to main branch
- : Direct PR for specific repository (root, submodule-name)
<scope> - : Create as draft PR
--draft - : Target branch (default: main)
--base <branch> - Combinations: ,
<scope> --draft, etc.root --base staging
从用户输入中解析参数:
- 无参数:自动检测仓库,创建指向main分支的PR
- :为特定仓库创建PR(root、子模块名称)
<scope> - :创建草稿PR
--draft - :指定目标分支(默认:main)
--base <branch> - 组合参数:、
<scope> --draft等root --base staging
Prerequisites
前置条件
GitHub CLI Required: Must have installed and authenticated
ghbash
undefined必须安装GitHub CLI:需要安装并完成身份验证
ghbash
undefinedInstall GitHub CLI (if not installed)
安装GitHub CLI(如果未安装)
macOS: brew install gh
macOS: brew install gh
Linux: See https://cli.github.com/
Linux: 查看 https://cli.github.com/
Authenticate
身份验证
gh auth login
undefinedgh auth login
undefinedPR Creation Workflow Steps
PR创建工作流步骤
Step 1: Parse Arguments
步骤1:解析参数
Extract scope, draft flag, and base branch from user input:
bash
undefined从用户输入中提取范围、草稿标记和基准分支:
bash
undefinedParse arguments
Parse arguments
SCOPE=""
DRAFT_FLAG=""
BASE_BRANCH="main"
SCOPE=""
DRAFT_FLAG=""
BASE_BRANCH="main"
Example parsing:
Example parsing:
"root --draft" → SCOPE="root", DRAFT_FLAG="--draft", BASE_BRANCH="main"
"root --draft" → SCOPE="root", DRAFT_FLAG="--draft", BASE_BRANCH="main"
"--base staging" → SCOPE="", DRAFT_FLAG="", BASE_BRANCH="staging"
"--base staging" → SCOPE="", DRAFT_FLAG="", BASE_BRANCH="staging"
"my-service --draft --base develop" → SCOPE="my-service", DRAFT_FLAG="--draft", BASE_BRANCH="develop"
"my-service --draft --base develop" → SCOPE="my-service", DRAFT_FLAG="--draft", BASE_BRANCH="develop"
undefinedundefinedStep 2: Detect Repository Context
步骤2:检测仓库上下文
Find monorepo root and determine current repository:
bash
undefined找到单体仓库根目录并确定当前仓库:
bash
undefinedFind monorepo root (handles submodules)
Find monorepo root (handles submodules)
if SUPERPROJECT=$(git rev-parse --show-superproject-working-tree 2>/dev/null) && [ -n "$SUPERPROJECT" ]; then
# We're in a submodule
MONOREPO_ROOT="$SUPERPROJECT"
else
# We're in root or standalone repo
MONOREPO_ROOT=$(git rev-parse --show-toplevel)
fi
if SUPERPROJECT=$(git rev-parse --show-superproject-working-tree 2>/dev/null) && [ -n "$SUPERPROJECT" ]; then
# We're in a submodule
MONOREPO_ROOT="$SUPERPROJECT"
else
# We're in root or standalone repo
MONOREPO_ROOT=$(git rev-parse --show-toplevel)
fi
Get current working directory
Get current working directory
CURRENT_DIR=$(pwd)
CURRENT_DIR=$(pwd)
Determine repository context
Determine repository context
if [ -n "$SCOPE" ]; then
# User specified scope
if [ "$SCOPE" = "root" ]; then
REPO_PATH="$MONOREPO_ROOT"
else
REPO_PATH="$MONOREPO_ROOT/$SCOPE"
fi
else
# Auto-detect from current directory
# If in submodule, use submodule path
# If in root, use root path
if [[ "$CURRENT_DIR" == "$MONOREPO_ROOT" ]]; then
REPO_PATH="$MONOREPO_ROOT"
else
# Find which submodule we're in
REPO_PATH=$(git -C "$CURRENT_DIR" rev-parse --show-toplevel)
fi
fi
if [ -n "$SCOPE" ]; then
# User specified scope
if [ "$SCOPE" = "root" ]; then
REPO_PATH="$MONOREPO_ROOT"
else
REPO_PATH="$MONOREPO_ROOT/$SCOPE"
fi
else
# Auto-detect from current directory
# If in submodule, use submodule path
# If in root, use root path
if [[ "$CURRENT_DIR" == "$MONOREPO_ROOT" ]]; then
REPO_PATH="$MONOREPO_ROOT"
else
# Find which submodule we're in
REPO_PATH=$(git -C "$CURRENT_DIR" rev-parse --show-toplevel)
fi
fi
Validate repository
Validate repository
if [ ! -d "$REPO_PATH/.git" ]; then
echo "❌ Error: Not a valid git repository: $REPO_PATH" >&2
exit 1
fi
undefinedif [ ! -d "$REPO_PATH/.git" ]; then
echo "❌ Error: Not a valid git repository: $REPO_PATH" >&2
exit 1
fi
undefinedStep 3: Validate Branch State
步骤3:验证分支状态
Check current branch and uncommitted changes:
bash
undefined检查当前分支和未提交的变更:
bash
undefinedChange to repository directory
Change to repository directory
cd "$REPO_PATH"
cd "$REPO_PATH"
Get current branch
Get current branch
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
Check if on protected branch
Check if on protected branch
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
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
Check for uncommitted changes
Check for uncommitted changes
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
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
Check if branch has commits ahead of base
Check if branch has commits ahead of base
COMMITS_AHEAD=$(git rev-list --count "$BASE_BRANCH..HEAD" 2>/dev/null || echo "0")
if [ "$COMMITS_AHEAD" = "0" ]; then
echo "❌ Error: No commits to create PR from" >&2
echo "Current branch '$CURRENT_BRANCH' has no commits ahead of '$BASE_BRANCH'" >&2
exit 1
fi
echo "ℹ️ Branch: $CURRENT_BRANCH ($COMMITS_AHEAD commits ahead of $BASE_BRANCH)"
undefinedCOMMITS_AHEAD=$(git rev-list --count "$BASE_BRANCH..HEAD" 2>/dev/null || echo "0")
if [ "$COMMITS_AHEAD" = "0" ]; then
echo "❌ Error: No commits to create PR from" >&2
echo "Current branch '$CURRENT_BRANCH' has no commits ahead of '$BASE_BRANCH'" >&2
exit 1
fi
echo "ℹ️ Branch: $CURRENT_BRANCH ($COMMITS_AHEAD commits ahead of $BASE_BRANCH)"
undefinedStep 4: Push Branch to Remote
步骤4:推送分支到远程仓库
Ensure branch exists on remote:
bash
undefined确保分支已存在于远程仓库:
bash
undefinedCheck if branch exists on remote
Check if 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
# Check if local is behind remote
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"
fifi
undefinedREMOTE_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
# Check if local is behind remote
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"
fifi
undefinedStep 5: Check for Existing PR
步骤5:检查现有PR
Detect if PR already exists for this branch:
bash
undefined检测当前分支是否已有对应的PR:
bash
undefinedCheck for existing PR using GitHub CLI
Check for existing PR using GitHub CLI
EXISTING_PR=$(gh pr view "$CURRENT_BRANCH" --json number,title,url 2>/dev/null || echo "")
if [ -n "$EXISTING_PR" ]; then
# PR exists - extract info
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 ""
# Use AskUserQuestion to ask user what to do
# Options:
# 1. Update PR (regenerate title/body and update)
# 2. View PR in browser (open URL)
# 3. Cancel (do nothing)
# If user chooses "Update PR":
# - Generate new title and body (Steps 6-7)
# - Update PR using: gh pr edit "$PR_NUMBER" --title "..." --body "..."
# - Show success message
# If user chooses "View PR":
# - Open PR URL in browser: gh pr view --web
# If user chooses "Cancel":
# - Exit gracefullyfi
undefinedEXISTING_PR=$(gh pr view "$CURRENT_BRANCH" --json number,title,url 2>/dev/null || echo "")
if [ -n "$EXISTING_PR" ]; then
# PR exists - extract info
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 ""
# Use AskUserQuestion to ask user what to do
# Options:
# 1. Update PR (regenerate title/body and update)
# 2. View PR in browser (open URL)
# 3. Cancel (do nothing)
# If user chooses "Update PR":
# - Generate new title and body (Steps 6-7)
# - Update PR using: gh pr edit "$PR_NUMBER" --title "..." --body "..."
# - Show success message
# If user chooses "View PR":
# - Open PR URL in browser: gh pr view --web
# If user chooses "Cancel":
# - Exit gracefullyfi
undefinedStep 6: Generate PR Title
步骤6:生成PR标题
Analyze commits to create conventional PR title:
bash
undefined分析提交记录以创建符合规范的PR标题:
bash
undefinedGet all commits from base branch to current branch
Get all commits from base branch to current branch
COMMITS=$(git log "$BASE_BRANCH..HEAD" --oneline)
COMMIT_COUNT=$(echo "$COMMITS" | wc -l | tr -d ' ')
echo "ℹ️ Analyzing $COMMIT_COUNT commits..."
COMMITS=$(git log "$BASE_BRANCH..HEAD" --oneline)
COMMIT_COUNT=$(echo "$COMMITS" | wc -l | tr -d ' ')
echo "ℹ️ Analyzing $COMMIT_COUNT commits..."
Get the first commit message (most recent)
Get the first commit message (most recent)
LATEST_COMMIT=$(git log -1 --pretty=%B)
LATEST_COMMIT=$(git log -1 --pretty=%B)
Detect commit type from latest commit or analyze all commits
Detect commit type from latest commit or analyze all commits
Try to extract type from conventional commit format
Try to extract type from conventional commit format
if echo "$LATEST_COMMIT" | grep -qE '^(feat|fix|docs|refactor|test|chore|perf|ci|build):'; then
# Extract type and description from conventional commit
COMMIT_TYPE=$(echo "$LATEST_COMMIT" | grep -oE '^[a-z]+' | head -1)
COMMIT_DESC=$(echo "$LATEST_COMMIT" | sed -E 's/^[a-z]+(([^)]+))?:\s*//')
else
# Analyze changes to determine type
ALL_COMMITS=$(git log "$BASE_BRANCH..HEAD" --pretty=%B)
if echo "$ALL_COMMITS" | grep -qi "fix\|bug"; then
COMMIT_TYPE="fix"
elif echo "$ALL_COMMITS" | grep -qi "feat\|feature\|add"; then
COMMIT_TYPE="feat"
elif echo "$ALL_COMMITS" | grep -qi "docs\|documentation"; then
COMMIT_TYPE="docs"
elif echo "$ALL_COMMITS" | grep -qi "refactor"; then
COMMIT_TYPE="refactor"
elif echo "$ALL_COMMITS" | grep -qi "test"; then
COMMIT_TYPE="test"
else
COMMIT_TYPE="feat"
fi
# Generate description from branch name or commit
COMMIT_DESC=$(echo "$LATEST_COMMIT" | head -1 | sed 's/^\s*//')fi
if echo "$LATEST_COMMIT" | grep -qE '^(feat|fix|docs|refactor|test|chore|perf|ci|build):'; then
# Extract type and description from conventional commit
COMMIT_TYPE=$(echo "$LATEST_COMMIT" | grep -oE '^[a-z]+' | head -1)
COMMIT_DESC=$(echo "$LATEST_COMMIT" | sed -E 's/^[a-z]+(([^)]+))?:\s*//')
else
# Analyze changes to determine type
ALL_COMMITS=$(git log "$BASE_BRANCH..HEAD" --pretty=%B)
if echo "$ALL_COMMITS" | grep -qi "fix\|bug"; then
COMMIT_TYPE="fix"
elif echo "$ALL_COMMITS" | grep -qi "feat\|feature\|add"; then
COMMIT_TYPE="feat"
elif echo "$ALL_COMMITS" | grep -qi "docs\|documentation"; then
COMMIT_TYPE="docs"
elif echo "$ALL_COMMITS" | grep -qi "refactor"; then
COMMIT_TYPE="refactor"
elif echo "$ALL_COMMITS" | grep -qi "test"; then
COMMIT_TYPE="test"
else
COMMIT_TYPE="feat"
fi
# Generate description from branch name or commit
COMMIT_DESC=$(echo "$LATEST_COMMIT" | head -1 | sed 's/^\s*//')fi
Generate PR title (capitalize first letter)
Generate PR title (capitalize first letter)
PR_TITLE="$COMMIT_TYPE: $COMMIT_DESC"
echo "ℹ️ Generated PR title: $PR_TITLE"
undefinedPR_TITLE="$COMMIT_TYPE: $COMMIT_DESC"
echo "ℹ️ Generated PR title: $PR_TITLE"
undefinedStep 7: Generate PR Body
步骤7:生成PR正文
Create PR description with summary and test plan:
bash
undefined创建包含摘要和测试计划的PR描述:
bash
undefinedGenerate PR body with summary from commits
Generate PR body with summary from commits
PR_BODY="## Summary
"
PR_BODY="## Summary
"
Add commit summaries
Add commit summaries
if [ "$COMMIT_COUNT" -eq 1 ]; then
# Single commit - use full message
PR_BODY+="$LATEST_COMMIT
"
else
# Multiple commits - list them
PR_BODY+="This PR includes $COMMIT_COUNT commits:
"
while IFS= read -r commit; do
PR_BODY+="- $commit
"
done <<< "$COMMITS"
PR_BODY+="
"
fi
if [ "$COMMIT_COUNT" -eq 1 ]; then
# Single commit - use full message
PR_BODY+="$LATEST_COMMIT
"
else
# Multiple commits - list them
PR_BODY+="This PR includes $COMMIT_COUNT commits:
"
while IFS= read -r commit; do
PR_BODY+="- $commit
"
done <<< "$COMMITS"
PR_BODY+="
"
fi
Add test plan section
Add test plan section
PR_BODY+="## Test Plan
- Code builds successfully
- Tests pass
- Manual testing completed
- Documentation updated (if needed)
PR_BODY+="## Test Plan
- Code builds successfully
- Tests pass
- Manual testing completed
- Documentation updated (if needed)
Changes
Changes
"
"
List changed files
List changed files
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 "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
undefinedCHANGED_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 "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
undefinedStep 8: Create PR
替代方案:更新现有PR
Use GitHub CLI to create the PR:
bash
undefined如果更新现有PR(用户在步骤5中选择“更新”):
bash
undefinedIMPORTANT: No Claude Code attribution in PR content
Update PR title and body
Build gh pr create command
—
GH_CMD="gh pr create --title "$PR_TITLE" --body "$PR_BODY" --base "$BASE_BRANCH""
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"
undefinedAdd draft flag if specified
PR标题生成规则
if [ "$DRAFT_FLAG" = "--draft" ]; then
GH_CMD+=" --draft"
fi
本功能遵循规范提交格式生成PR标题:
| 检测到的模式 | 类型 | 标题示例 |
|---|---|---|
| 提交中包含"feat:" | | feat: add user authentication |
| 提交中包含"fix:" | | fix: resolve login timeout issue |
| 提交中包含"docs:" | | docs: update API documentation |
| 提交中包含"refactor:" | | refactor: optimize database queries |
| 提交中包含"test:" | | test: add integration tests |
| 提及"bug"、"fix" | | fix: correct calculation error |
| 提及"feature"、"add" | | feat: implement new feature |
| 默认 | | feat: [description from commits] |
Execute PR creation
重要说明
eval "$GH_CMD" || {
echo "❌ Failed to create PR" >&2
exit 1
}
-
必须安装GitHub CLI:需要安装并完成身份验证
ghbashgh auth login -
分支保护:无法从main/master分支创建PR
-
现有PR处理:自动检测现有PR并提供更新选项
-
基于提交的内容:PR标题和正文由提交消息生成
-
全目录支持:可在任何目录执行,自动解析绝对路径
-
子模块支持:可为根仓库和子模块创建PR
-
简洁PR内容:PR标题和描述中不得包含Claude Code署名
Get PR URL
使用的GitHub CLI命令
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 ""
undefined本功能使用以下命令:
ghbash
undefinedAlternative: Update Existing PR
Check for existing PR
If updating an existing PR (user chose "Update" in Step 5):
bash
undefinedgh pr view <branch> --json number,title,url
Update PR title and body
Create new PR
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"
undefinedgh pr create --title "..." --body "..." --base <branch> [--draft]
PR Title Generation Rules
Update existing PR
The skill generates PR titles following conventional commit format:
| Detected Pattern | Type | Example Title |
|---|---|---|
| "feat:" in commits | | feat: add user authentication |
| "fix:" in commits | | fix: resolve login timeout issue |
| "docs:" in commits | | docs: update API documentation |
| "refactor:" in commits | | refactor: optimize database queries |
| "test:" in commits | | test: add integration tests |
| Mentions "bug", "fix" | | fix: correct calculation error |
| Mentions "feature", "add" | | feat: implement new feature |
| Default | | feat: [description from commits] |
gh pr edit <number> --title "..." --body "..."
Important Notes
View PR in browser
-
GitHub CLI Required: Must haveinstalled and authenticated
ghbashgh 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
gh pr view --web
GitHub CLI Commands Used
Check PR status
This skill uses the following commands:
ghbash
undefinedgh pr checks
undefinedCheck for existing PR
相关文档
gh pr view <branch> --json number,title,url
如需详细信息,请查看:
- WORKFLOW.md - PR创建流程分步指南,包括仓库检测、分支管理和GitHub CLI集成
- EXAMPLES.md - 实际PR场景示例,涵盖功能开发、Bug修复、草稿PR和子模块PR
- TROUBLESHOOTING.md - GitHub CLI错误、身份验证和分支冲突等常见问题及解决方案
Create new PR
—
gh pr create --title "..." --body "..." --base <branch> [--draft]
—
Update existing PR
—
gh pr edit <number> --title "..." --body "..."
—
View PR in browser
—
gh pr view --web
—
Check PR status
—
gh pr checks
undefined—
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
—