Token导航 LogoToken导航TokenDH.com
待分类需要联网github未标认证来源可访问许可证需确认审计提醒

create-pr创建公关

Agent Skill

create-pr 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

269

周安装

11

GitHub Stars

公开资料未说明

下载量

87
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:create-pr(创建公关)
来源仓库:https://github.com/tenfyzhong/skills-hub
仓库路径:skills/create-pr
安装命令:
npx skills add https://github.com/tenfyzhong/skills-hub --skill create-pr
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/tenfyzhong/skills-hub --skill create-pr

简介

create-pr 用于处理 GitHub 仓库的 Pull Request 协作流程。

  • 适合在 Codex、Claude、Cursor 等宿主中需要创建或审查 PR 时使用。
  • 它支持自动提取提交信息、添加审稿人和处理 CI 检查结果。
  • 使用前需确保已配置 gh CLI 身份验证和远程仓库写入权限。
  • 遇到变基冲突时应暂停自动化流程并手动解决合并问题。

SKILL.md

Create PR Skill

Create a Pull Request from the current branch with intelligent remote detection and PR content generation.

Prerequisites Check (MUST verify first)

Before proceeding, verify:

# 1. Check if in a git repository
git rev-parse --is-inside-work-tree

# 2. Check if gh CLI is available and authenticated
gh auth status

# 3. Check current branch is not main/master
CURRENT_BRANCH=$(git branch --show-current)
DEFAULT_BRANCH=$(git remote show origin | grep 'HEAD branch' | cut -d' ' -f5)
if [ "$CURRENT_BRANCH" = "$DEFAULT_BRANCH" ]; then
  echo "ERROR: Cannot create PR from default branch"
  exit 1
fi

# 4. Check for uncommitted changes (warn user if any)
git status --porcelain

If checks fail, STOP and inform the user:

  • Not in git repo → "This skill requires a git repository. Please navigate to a git project."
  • gh not authenticated → "Please run gh auth login first."
  • On default branch → "You are on the default branch. Please checkout a feature branch first."
  • Uncommitted changes → "You have uncommitted changes. Please commit or stash them first."

Input

The user may optionally provide:

  • Target base branch (defaults to main/master)
  • Draft mode flag
  • Specific reviewers

Workflow

Step 1: Detect Repository Configuration

# Get all remotes
git remote -v

# Get current branch name
CURRENT_BRANCH=$(git branch --show-current)

# Detect default branch (main or master)
DEFAULT_BRANCH=$(gh repo view --json defaultBranchRef -q '.defaultBranchRef.name')

# Get repository info
gh repo view --json owner,name,isFork,parent

Step 2: Identify Upstream and Fork Remotes

Determine the remote configuration:

# List all remotes with their URLs
git remote -v

# Check if this repo is a fork
IS_FORK=$(gh repo view --json isFork -q '.isFork')

# If it's a fork, get parent info
if [ "$IS_FORK" = "true" ]; then
  PARENT_OWNER=$(gh repo view --json parent -q '.parent.owner.login')
  PARENT_NAME=$(gh repo view --json parent -q '.parent.name')
fi

Remote Classification Logic:

ScenarioUpstream RemotePush Remote
Single remote (origin)originorigin
Fork: origin=fork, upstream=parentupstreamorigin
Fork: origin=parent, fork remote existsoriginfork remote
Multiple remotes, one is forknon-fork remotefork remote

Detection Algorithm:

# Get current user's GitHub username
CURRENT_USER=$(gh api user -q '.login')

# For each remote, check if it belongs to current user
for remote in $(git remote); do
  REMOTE_URL=$(git remote get-url $remote)
  # Extract owner from URL (handles both HTTPS and SSH)
  REMOTE_OWNER=$(echo "$REMOTE_URL" | sed -E 's/.*[:/]([^/]+)\/[^/]+\.git$/\1/' | sed 's/\.git$//')

  if [ "$REMOTE_OWNER" = "$CURRENT_USER" ]; then
    FORK_REMOTE=$remote
  else
    UPSTREAM_REMOTE=$remote
  fi
done

# Default fallback
UPSTREAM_REMOTE=${UPSTREAM_REMOTE:-origin}
FORK_REMOTE=${FORK_REMOTE:-origin}

Step 3: Sync Upstream Default Branch

# Fetch latest from upstream
git fetch $UPSTREAM_REMOTE $DEFAULT_BRANCH

# Update local default branch
git checkout $DEFAULT_BRANCH
git pull $UPSTREAM_REMOTE $DEFAULT_BRANCH

# Return to feature branch
git checkout $CURRENT_BRANCH

Step 4: Update Current Branch with Upstream

# Rebase current branch onto latest default branch
git rebase $UPSTREAM_REMOTE/$DEFAULT_BRANCH

# If rebase fails, inform user
if [ $? -ne 0 ]; then
  echo "Rebase failed. Please resolve conflicts manually."
  git rebase --abort
  exit 1
fi

Step 5: Push Branch to Remote

Check if branch exists on remote and push:

# Check if branch exists on the push remote
REMOTE_BRANCH_EXISTS=$(git ls-remote --heads $FORK_REMOTE $CURRENT_BRANCH | wc -l)

if [ "$REMOTE_BRANCH_EXISTS" -eq 0 ]; then
  # Branch doesn't exist, push with upstream tracking
  git push -u $FORK_REMOTE $CURRENT_BRANCH
else
  # Branch exists, force push (after rebase) with lease for safety
  git push --force-with-lease $FORK_REMOTE $CURRENT_BRANCH
fi

Important: Always use --force-with-lease instead of --force for safety.

Step 6: Gather PR Content Information

# Get all commits between default branch and current branch
git log $UPSTREAM_REMOTE/$DEFAULT_BRANCH..HEAD --pretty=format:"%h %s%n%b" --no-merges

# Get the diff summary
git diff --stat $UPSTREAM_REMOTE/$DEFAULT_BRANCH..HEAD

# Get the full diff for analysis
git diff $UPSTREAM_REMOTE/$DEFAULT_BRANCH..HEAD

# Get list of changed files
git diff --name-only $UPSTREAM_REMOTE/$DEFAULT_BRANCH..HEAD

Step 7: Check for PR Template

# Check for PR template in common locations
PR_TEMPLATE=""
for template_path in \
  ".github/pull_request_template.md" \
  ".github/PULL_REQUEST_TEMPLATE.md" \
  "docs/pull_request_template.md" \
  "PULL_REQUEST_TEMPLATE.md"; do
  if [ -f "$template_path" ]; then
    PR_TEMPLATE="$template_path"
    break
  fi
done

# Also check for template directory
if [ -z "$PR_TEMPLATE" ] && [ -d ".github/PULL_REQUEST_TEMPLATE" ]; then
  # Use default template if exists
  if [ -f ".github/PULL_REQUEST_TEMPLATE/default.md" ]; then
    PR_TEMPLATE=".github/PULL_REQUEST_TEMPLATE/default.md"
  fi
fi

# Read template content if found
if [ -n "$PR_TEMPLATE" ]; then
  cat "$PR_TEMPLATE"
fi

Step 8: Generate PR Title and Description

Title Generation Rules:

  1. If single commit: Use commit message subject line
  2. If multiple commits: Summarize the overall change
  3. Follow conventional commit format if project uses it: <type>(<scope>): <description>
  4. Keep under 72 characters

Description Generation:

If PR template exists, fill in the template sections:

Common Template SectionHow to Fill
## Summary / ## DescriptionSummarize changes from commits and diff
## Changes / ## WhatList key changes from diff
## Why / ## MotivationExtract from commit bodies or infer from changes
## TestingList test files changed or suggest manual testing
## ScreenshotsLeave placeholder if UI changes detected
## ChecklistLeave checkboxes for user to complete
Fixes # / Closes #Extract issue references from commits

If no template, generate structured description:

## Summary

[2-3 sentences summarizing what this PR does]

## Changes

- [Key change 1]
- [Key change 2]
- [Key change 3]

## Testing

[How the changes were tested or should be tested]

---
[Any issue references found in commits]

Step 9: Create the Pull Request

# Determine the base repository for the PR
if [ "$IS_FORK" = "true" ]; then
  # For forks, create PR against parent repo
  BASE_REPO="$PARENT_OWNER/$PARENT_NAME"
  gh pr create \
    --repo "$BASE_REPO" \
    --base "$DEFAULT_BRANCH" \
    --head "$CURRENT_USER:$CURRENT_BRANCH" \
    --title "$PR_TITLE" \
    --body "$PR_BODY"
else
  # For non-forks, create PR in same repo
  gh pr create \
    --base "$DEFAULT_BRANCH" \
    --head "$CURRENT_BRANCH" \
    --title "$PR_TITLE" \
    --body "$PR_BODY"
fi

Use HEREDOC for body to preserve formatting:

gh pr create --title "$PR_TITLE" --body "$(cat <<'EOF'
## Summary

[Generated summary here]

## Changes

- Change 1
- Change 2

EOF
)"

Step 10: Report Results

After PR creation, provide:

# Get PR URL and details
gh pr view --json url,number,title,state

Output Format


PR Created Successfully

PR: #[NUMBER] - [TITLE] URL: [PR_URL] Base: [BASE_BRANCH] ← Head: [HEAD_BRANCH] Remote: Pushed to [FORK_REMOTE]

Summary

[Brief description of what the PR contains]

Files Changed

FileChanges
path/to/file.ts+[additions] -[deletions]

Next Steps

  • Review the PR description and edit if needed
  • Add reviewers if required
  • Wait for CI checks to pass
  • Address any review comments

Error Handling

SituationAction
No commits ahead of base"No changes to create PR. Your branch is up to date with [base]."
Rebase conflicts"Rebase failed due to conflicts. Please resolve manually and re-run."
Push rejected"Push failed. Check if you have write access to the remote."
PR already exists"A PR already exists for this branch: [URL]. Opening existing PR."
No remote access"Cannot access remote. Check your authentication with gh auth status."
Fork detection failed"Could not determine fork relationship. Please specify the target repo."

Advanced Options

Draft PR

gh pr create --draft --title "$PR_TITLE" --body "$PR_BODY"

Add Reviewers

gh pr create --reviewer "user1,user2" --title "$PR_TITLE" --body "$PR_BODY"

Add Labels

gh pr create --label "enhancement,needs-review" --title "$PR_TITLE" --body "$PR_BODY"

Link to Issue

If commits reference issues (e.g., "Fixes #123"), automatically add to PR body:

# Extract issue references from commits
ISSUES=$(git log $UPSTREAM_REMOTE/$DEFAULT_BRANCH..HEAD --pretty=format:"%B" | grep -oE "(Fixes|Closes|Resolves) #[0-9]+" | sort -u)

Important Notes

  1. Safety First: Always use --force-with-lease instead of --force when pushing after rebase
  2. Fork Awareness: Automatically detect and handle fork workflows
  3. Template Respect: Always check for and use PR templates when available
  4. Conventional Commits: If project uses conventional commits, follow the format
  5. Issue Linking: Preserve issue references from commit messages
  6. Review Before Submit: Show generated title/description for user approval before creating PR

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

37.48%
按下载量换算33

Claude

29.19%
按下载量换算25

Cursor

18.09%
按下载量换算16

Gemini CLI

8.07%
按下载量换算7

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

可疑

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills