create-pull-request
它能做什么
这个技能指导提交 GitHub 拉取请求的步骤,从检查分支到撰写描述。它面向希望自己的更改得到审查的开发者。
适用场景
- ✓有人要求提交拉取请求或提交更改以供审查的时候。
- ✓分支上的提交需要为审查者提供清晰摘要的时候。
- ✓项目有需要遵循的拉取请求模板的时候。
技能链接
https://github.com/cline/cline/blob/main/.agents/skills/create-pull-request/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我的更改在一个分支上。请帮我在 GitHub 上提交一个带有清晰描述的拉取请求吗?”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会检查 GitHub 命令行工具 gh 是否已安装并登录,查看分支上的提交,并填写项目的拉取请求模板。然后它会使用 gh 工具创建拉取请求。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Create Pull Request
This skill guides you through creating a well-structured GitHub pull request that follows project conventions and best practices.
Prerequisites Check
Before proceeding, verify the following:
1. Check if gh CLI is installed
gh --version
If not installed, inform the user:
The GitHub CLI (
gh) is required but not installed. Please install it:
- macOS:
brew install gh- Other: https://cli.github.com/
2. Check if authenticated with GitHub
gh auth status
If not authenticated, guide the user to run gh auth login.
3. Verify clean working directory
git status
If there are uncommitted changes, ask the user whether to:
- Commit them as part of this PR
- Stash them temporarily
- Discard them (with caution)
Gather Context
1. Identify the current branch
git branch --show-current
Ensure you're not on main or master. If so, ask the user to create or switch to a feature branch.
2. Find the base branch
git remote show origin | grep "HEAD branch"
This is typically main or master.
3. Analyze recent commits relevant to this PR
git log origin/main..HEAD --oneline --no-decorate
Review these commits to understand:
- What changes are being introduced
- The scope of the PR (single feature/fix or multiple changes)
- Whether commits should be squashed or reorganized
4. Review the diff
git diff origin/main..HEAD --stat
This shows which files changed and helps identify the type of change.
Information Gathering
Before creating the PR, you need the following information. Check if it can be inferred from:
- Commit messages
- Branch name (e.g.,
fix/issue-123,feature/new-login) - Changed files and their content
If any critical information is missing, use ask_followup_question to ask the user:
Required Information
- Related Issue Number: Look for patterns like
#123,fixes #123, orcloses #123in commit messages - Description: What problem does this solve? Why were these changes made?
- Type of Change: Bug fix, new feature, breaking change, refactor, cosmetic, documentation, or workflow
- Test Procedure: How was this tested? What could break?
Example clarifying question
If the issue number is not found:
I couldn't find a related issue number in the commit messages or branch name. What GitHub issue does this PR address? (Enter the issue number, e.g., "123" or "N/A" for small fixes)
Git Best Practices
Before creating the PR, consider these best practices:
Commit Hygiene
- Atomic commits: Each commit should represent a single logical change
- Clear commit messages: Follow conventional commit format when possible
- No merge commits: Prefer rebasing over merging to keep history clean
Branch Management
Rebase on latest main (if needed):
git fetch origin git rebase origin/mainSquash if appropriate: If there are many small "WIP" commits, consider interactive rebase:
git rebase -i origin/mainOnly suggest this if commits appear messy and the user is comfortable with rebasing.
Push Changes
Ensure all commits are pushed:
git push origin HEAD
If the branch was rebased, you may need:
git push origin HEAD --force-with-lease
Create the Pull Request
IMPORTANT: Read and use the PR template at .github/pull_request_template.md. The PR body format must strictly match the template structure. Do not deviate from the template format.
When filling out the template:
- Replace
#XXXXwith the actual issue number, or keep as#XXXXif no issue exists (for small fixes) - Fill in all sections with relevant information gathered from commits and context
- Mark the appropriate "Type of Change" checkbox(es)
- Complete the "Pre-flight Checklist" items that apply
Create PR with gh CLI
Use a temporary file for the PR body to avoid shell escaping issues, newline problems, and other command-line flakiness:
Write the PR body to a temporary file:
/tmp/pr-body.mdCreate the PR using the file:
gh pr create --title "PR_TITLE" --body-file /tmp/pr-body.md --base mainClean up the temporary file:
rm /tmp/pr-body.md
For draft PRs:
gh pr create --title "PR_TITLE" --body-file /tmp/pr-body.md --base main --draft
Why use a file?
常见问题
需要先设置什么?
这个技能要求先安装并登录 GitHub 命令行工具 gh。
如果有未提交的更改怎么办?
这个技能说,应先询问是提交、暂存还是丢弃它们,然后再继续。
可以从 main 分支提交拉取请求吗?
不可以。这个技能说,如果当前在 main 分支,应先切换到功能分支。
详情
作者的原始描述
Create a GitHub pull request following project conventions. Use when the user asks to create a PR, submit changes for review, or open a pull request. Handles commit analysis, branch management, PR template usage, and PR creation using the gh CLI tool.
repo: cline/cline
热度
- GitHub 星标
- 71k
- 排名
- #3106
- 许可证
- Apache-2.0
- 更新时间
- 2026/11/2
评论
- …