/zcf-pr
Create pull request based on current branch changes
$ npx -y skills add UfoMiao/zcf --skill zcf-pr --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/zcf-pr
Context preview
The summary Claude sees to decide when to auto-load this skill.
Create pull request based on current branch changes
SKILL.md
zcf-pr.SKILL.mdname: zcf-pr
description: Create pull request based on current branch changes
disable-model-invocation: true
allowed-tools: Read(**), Exec(git, pnpm, node, date, cat, gh)
ZCF PR - Create Pull Request from Current Branch
Create pull request based on current branch changes and generate standardized PR description.
Usage
/zcf-pr [--base <branch>] [--draft] [--title <title>]
Parameters
- `--base <branch>`: Target base branch (default: main)
- `--draft`: Create as draft pull request
- `--title <title>`: Custom PR title
Context
- Analyze current branch changes since divergence from base branch
- Generate PR description following project template
- Support both English and Chinese descriptions
- Auto-detect change types and categorize appropriately
- Create PR using GitHub CLI with comprehensive template
Your Role
You are a professional pull request management assistant responsible for:
1. Analyzing branch changes 2. Categorizing change types automatically 3. Generating standardized PR descriptions 4. Creating pull requests with proper templates
Execution Flow
Parse arguments: $ARGUMENTS
1. Parameter Parsing
BASE_BRANCH="main"
IS_DRAFT=false
CUSTOM_TITLE=""
# Parse arguments
while [[ $# -gt 0 ]]; do
case $1 in
--base)
BASE_BRANCH="$2"
shift 2
;;
--draft)
IS_DRAFT=true
shift
;;
--title)
CUSTOM_TITLE="$2"
shift 2
;;
*)
echo "❌ Unknown parameter: $1"
echo "Usage: /zcf-pr [--base <branch>] [--draft] [--title <title>]"
echo "Examples:"
echo " /zcf-pr # Create PR to main"
echo " /zcf-pr --base develop # Create PR to develop"
echo " /zcf-pr --draft # Create draft PR"
echo " /zcf-pr --title 'Bug Fix' # Custom title"
exit 1
;;
esac
done
echo "🚀 Creating PR from current branch to $BASE_BRANCH"
if [ "$IS_DRAFT" = true ]; then
echo "📝 Creating as draft PR"
fi
if [ -n "$CUSTOM_TITLE" ]; then
echo "📝 Custom title: $CUSTOM_TITLE"
fi2. Check Working Directory Status
# Check if we're in a git repository
if [ ! -d ".git" ]; then
echo "❌ Error: Not in a git repository"
exit 1
fi
# Get current branch
CURRENT_BRANCH=$(git branch --show-current)
if [ -z "$CURRENT_BRANCH" ]; then
echo "❌ Error: Could not determine current branch"
exit 1
fi
# Check if current branch is same as base branch
if [ "$CURRENT_BRANCH" = "$BASE_BRANCH" ]; then
echo "❌ Error: Cannot create PR from $BASE_BRANCH to $BASE_BRANCH"
echo "Please switch to a feature branch first"
exit 1
fi
# Check for uncommitted changes
if ! git diff --quiet || ! git diff --cached --quiet; then
echo "⚠️ Warning: You have uncommitted changes"
echo "Please commit your changes before creating a PR"
echo ""
git status --short
echo ""
echo "Run the following commands to commit your changes:"
echo " git add ."
echo " git commit -m 'Your commit message'"
exit 1
fi
echo "✅ Branch status OK: $CURRENT_BRANCH"
3. Analyze Branch Changes
# Check if base branch exists
if ! git rev-parse --verify "$BASE_BRANCH" >/dev/null 2>&1; then
echo "❌ Error: Base branch '$BASE_BRANCH' does not exist"
exit 1
fi
# Get commit history since divergence
echo "📊 Analyzing changes from $BASE_BRANCH..."
# Find common ancestor
MERGE_BASE=$(git merge-base "$BASE_BRANCH" HEAD)
if [ -z "$MERGE_BASE" ]; then
echo "❌ Error: Could not find common ancestor with $BASE_BRANCH"
exit 1
fi
# Get commits since divergence
COMMITS=$(git log $MERGE_BASE..HEAD --oneline)
COMMIT_COUNT=$(echo "$COMMITS" | wc -l | tr -d ' ')
if [ "$COMMIT_COUNT" -eq 0 ]; then
echo "❌ Error: No commits found since divergence from $BASE_BRANCH"
exit 1
fi
echo "📝 Found $COMMIT_COUNT commit(s):"
echo "$COMMITS"
echo ""
# Analyze file changes
echo "📁 File change statistics:"
git diff --stat $MERGE_BASE..HEAD
# Get changed files
CHANGED_FILES=$(git diff --name-only $MERGE_BASE..HEAD)
echo ""
echo "📋 Changed files:"
echo "$CHANGED_FILES"
4. Categorize Changes
# Analyze changes to determine type and scope
echo ""
echo "🔍 Analyzing change categories..."
BUG_FIX=false
NEW_FEATURE=false
BREAKING_CHANGE=false
DOCUMENTATION=false
TESTS=false
# Analyze commits for change indicators
if echo "$COMMITS" | grep -E "(fix|bug|error|issue|problem)" >/dev/null; then
BUG_FIX=true
fi
if echo "$COMMITS" | grep -E "(feat|add|new|create|implement)" >/dev/null; then
NEW_FEATURE=true
fi
if echo "$COMMITS" | grep -E "(break|change|remove|delete|major)" >/dev/null; then
BREAKING_CHANGE=true
fi
if echo "$CHANGED_FILES" | grep -E "\.(md|txt|rst)$" >/dev/null; then
DOCUMENTATION=true
fi
if echo "$CHANGED_FILES" | grep -E "(test|spec)\." >/dev/null; then
TESTS=true
fi
# Show analysis results
echo "📊 Change type analysis:"
if [ "$BUG_FIX" = true ]; then echo " ✅ Bug fix detected"; fi
if [ "$NEW_FEATURE" = true ]; then echo " ✅ New feature detected"; fi
if [ "$BREAKING_CHANGE" = true ]; then echo " ✅ Breaking change detected"; fi
if [ "$DOCUMENTATION" = true ]; then echo " ✅ Documentation update detected"; fi
if [ "$TESTS" = true ]; then echo " ✅ Test updates detected"; fi
5. Generate PR Title
# Generate PR title
if [ -n "$CUSTOM_TITLE" ]; then
PR_TITLE="$CUSTOM_TITLE"
else
# Auto-generate title from first commit
FIRST_COMMIT=$(echo "$COMMITS" | tail -1)
# Clean up commit message for PR title
if echo "$FIRST_COMMIT" | grep -E "^(feat|fix|docs|style|refactor|test|chore)(\(.+\))?: " >/dev/null; then
# Use conventional commit format
PR_TITLE=$(echo "$FIRST_COMMIT" | sed 's/^[a-f0-9]\+ //')
else
# Fallback to simple format
PR_TITLE="$CURRENT_BRANCH"
fi
fi
echo "📝 PR Title: $PR_TITLE"6. Generate PR Description
# Generate comprehensive PR description
echo "📋 Generating PR description..."
# Generate change su
Read more
name: zcf-pr description: Create pull request based on current branch changes disable-model-invocation: true allowed-tools: Read(**), Exec(git, pnpm, node, date, cat, gh)
ZCF PR - Create Pull Request from Current Branch
Create pull request based on current branch changes and generate standardized PR description.
Usage
/zcf-pr [--base <branch>] [--draft] [--title <title>]
Parameters
- `--base <branch>`: Target base branch (default: main)
- `--draft`: Create as draft pull request
- `--title <title>`: Custom PR title
Context
- Analyze current branch changes since divergence from base branch
- Generate PR description following project template
- Support both English and Chinese descriptions
- Auto-detect change types and categorize appropriately
- Create PR using GitHub CLI with comprehensive template
Your Role
You are a professional pull request management assistant responsible for:
1. Analyzing branch changes 2. Categorizing change types automatically 3. Generating standardized PR descriptions 4. Creating pull requests with proper templates
Execution Flow
Parse arguments: $ARGUMENTS
1. Parameter Parsing
BASE_BRANCH="main"
IS_DRAFT=false
CUSTOM_TITLE=""
# Parse arguments
while [[ $# -gt 0 ]]; do
case $1 in
--base)
BASE_BRANCH="$2"
shift 2
;;
--draft)
IS_DRAFT=true
shift
;;
--title)
CUSTOM_TITLE="$2"
shift 2
;;
*)
echo "❌ Unknown parameter: $1"
echo "Usage: /zcf-pr [--base <branch>] [--draft] [--title <title>]"
echo "Examples:"
echo " /zcf-pr # Create PR to main"
echo " /zcf-pr --base develop # Create PR to develop"
echo " /zcf-pr --draft # Create draft PR"
echo " /zcf-pr --title 'Bug Fix' # Custom title"
exit 1
;;
esac
done
echo "🚀 Creating PR from current branch to $BASE_BRANCH"
if [ "$IS_DRAFT" = true ]; then
echo "📝 Creating as draft PR"
fi
if [ -n "$CUSTOM_TITLE" ]; then
echo "📝 Custom title: $CUSTOM_TITLE"
fi2. Check Working Directory Status
# Check if we're in a git repository if [ ! -d ".git" ]; then echo "❌ Error: Not in a git repository" exit 1 fi # Get current branch CURRENT_BRANCH=$(git branch --show-current) if [ -z "$CURRENT_BRANCH" ]; then echo "❌ Error: Could not determine current branch" exit 1 fi # Check if current branch is same as base branch if [ "$CURRENT_BRANCH" = "$BASE_BRANCH" ]; then echo "❌ Error: Cannot create PR from $BASE_BRANCH to $BASE_BRANCH" echo "Please switch to a feature branch first" exit 1 fi # Check for uncommitted changes if ! git diff --quiet || ! git diff --cached --quiet; then echo "⚠️ Warning: You have uncommitted changes" echo "Please commit your changes before creating a PR" echo "" git status --short echo "" echo "Run the following commands to commit your changes:" echo " git add ." echo " git commit -m 'Your commit message'" exit 1 fi echo "✅ Branch status OK: $CURRENT_BRANCH"
3. Analyze Branch Changes
# Check if base branch exists if ! git rev-parse --verify "$BASE_BRANCH" >/dev/null 2>&1; then echo "❌ Error: Base branch '$BASE_BRANCH' does not exist" exit 1 fi # Get commit history since divergence echo "📊 Analyzing changes from $BASE_BRANCH..." # Find common ancestor MERGE_BASE=$(git merge-base "$BASE_BRANCH" HEAD) if [ -z "$MERGE_BASE" ]; then echo "❌ Error: Could not find common ancestor with $BASE_BRANCH" exit 1 fi # Get commits since divergence COMMITS=$(git log $MERGE_BASE..HEAD --oneline) COMMIT_COUNT=$(echo "$COMMITS" | wc -l | tr -d ' ') if [ "$COMMIT_COUNT" -eq 0 ]; then echo "❌ Error: No commits found since divergence from $BASE_BRANCH" exit 1 fi echo "📝 Found $COMMIT_COUNT commit(s):" echo "$COMMITS" echo "" # Analyze file changes echo "📁 File change statistics:" git diff --stat $MERGE_BASE..HEAD # Get changed files CHANGED_FILES=$(git diff --name-only $MERGE_BASE..HEAD) echo "" echo "📋 Changed files:" echo "$CHANGED_FILES"
4. Categorize Changes
# Analyze changes to determine type and scope echo "" echo "🔍 Analyzing change categories..." BUG_FIX=false NEW_FEATURE=false BREAKING_CHANGE=false DOCUMENTATION=false TESTS=false # Analyze commits for change indicators if echo "$COMMITS" | grep -E "(fix|bug|error|issue|problem)" >/dev/null; then BUG_FIX=true fi if echo "$COMMITS" | grep -E "(feat|add|new|create|implement)" >/dev/null; then NEW_FEATURE=true fi if echo "$COMMITS" | grep -E "(break|change|remove|delete|major)" >/dev/null; then BREAKING_CHANGE=true fi if echo "$CHANGED_FILES" | grep -E "\.(md|txt|rst)$" >/dev/null; then DOCUMENTATION=true fi if echo "$CHANGED_FILES" | grep -E "(test|spec)\." >/dev/null; then TESTS=true fi # Show analysis results echo "📊 Change type analysis:" if [ "$BUG_FIX" = true ]; then echo " ✅ Bug fix detected"; fi if [ "$NEW_FEATURE" = true ]; then echo " ✅ New feature detected"; fi if [ "$BREAKING_CHANGE" = true ]; then echo " ✅ Breaking change detected"; fi if [ "$DOCUMENTATION" = true ]; then echo " ✅ Documentation update detected"; fi if [ "$TESTS" = true ]; then echo " ✅ Test updates detected"; fi
5. Generate PR Title
# Generate PR title
if [ -n "$CUSTOM_TITLE" ]; then
PR_TITLE="$CUSTOM_TITLE"
else
# Auto-generate title from first commit
FIRST_COMMIT=$(echo "$COMMITS" | tail -1)
# Clean up commit message for PR title
if echo "$FIRST_COMMIT" | grep -E "^(feat|fix|docs|style|refactor|test|chore)(\(.+\))?: " >/dev/null; then
# Use conventional commit format
PR_TITLE=$(echo "$FIRST_COMMIT" | sed 's/^[a-f0-9]\+ //')
else
# Fallback to simple format
PR_TITLE="$CURRENT_BRANCH"
fi
fi
echo "📝 PR Title: $PR_TITLE"6. Generate PR Description
# Generate comprehensive PR description echo "📋 Generating PR description..." # Generate change su
Repo: UfoMiao/zcf
Other skills on zcf.
- /zcf-add-sponsor
Quickly add a new corporate sponsor to ZCF — sponsor list by default, with optional API preset and documentation ad placements
Open skill - /zcf-release
Automate version release and code commit using changeset
Open skill - /zcf-update-docs
Automatically check code changes since last tag and update documentation in docs/ directory (en, zh-CN, ja-JP) and CLAUDE.md to ensure consistency with actual code implementation
Open skill - /bmad-init
Initialize or update BMad-Method (V6) in your project
Open skill - /feat
Add New Feature
Open skill - /git-clean-branches
Safely find and clean up merged or stale Git branches with dry-run mode and custom base/protected branches support
Open skill

