npx skills add https://github.com/cline/cline --skill create-pull-request此技能指导您创建结构良好、遵循项目规范和最佳实践的 GitHub 拉取请求。
在继续之前,请验证以下内容:
gh CLI 是否已安装gh --version
如果未安装,请告知用户:
GitHub CLI (
gh) 是必需的但未安装。请安装它:
- macOS:
brew install gh- 其他平台: https://cli.github.com/
gh auth status
如果未认证,请引导用户运行 gh auth login。
git status
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
如果有未提交的更改,询问用户是否要:
git branch --show-current
确保您不在 main 或 master 分支上。如果是,请要求用户创建或切换到功能分支。
git remote show origin | grep "HEAD branch"
这通常是 main 或 master。
git log origin/main..HEAD --oneline --no-decorate
审查这些提交以了解:
git diff origin/main..HEAD --stat
这将显示哪些文件发生了更改,并有助于识别更改类型。
在创建 PR 之前,您需要以下信息。检查是否可以从以下来源推断:
fix/issue-123、feature/new-login)如果缺少任何关键信息,请使用 ask_followup_question 询问用户:
#123、fixes #123 或 closes #123 的模式如果未找到 issue 编号:
我在提交消息或分支名称中找不到相关的 issue 编号。此 PR 解决了哪个 GitHub issue?(输入 issue 编号,例如 "123",或对于小修复输入 "N/A")
在创建 PR 之前,请考虑以下最佳实践:
基于最新的 main 进行变基(如果需要):
git fetch origin git rebase origin/main
适当情况下压缩提交 : 如果有很多小的 "WIP" 提交,请考虑交互式变基:
git rebase -i origin/main
仅当提交看起来混乱且用户熟悉变基操作时才建议此操作。
确保所有提交都已推送:
git push origin HEAD
如果分支已变基,您可能需要:
git push origin HEAD --force-with-lease
重要提示 : 阅读并使用 .github/pull_request_template.md 处的 PR 模板。PR 正文格式必须严格匹配模板结构。不得偏离模板格式。
填写模板时:
#XXXX 替换为实际的 issue 编号,如果不存在 issue(对于小修复),则保持为 #XXXX使用临时文件存储 PR 正文,以避免 shell 转义问题、换行问题和其他命令行不稳定性:
将 PR 正文写入临时文件:
/tmp/pr-body.md
使用该文件创建 PR:
gh pr create --title "PR_TITLE" --body-file /tmp/pr-body.md --base main
清理临时文件:
rm /tmp/pr-body.md
对于草稿 PR:
gh pr create --title "PR_TITLE" --body-file /tmp/pr-body.md --base main --draft
为什么使用文件? 通过 --body 直接传递包含换行符、特殊字符和复选框的复杂 Markdown 内容容易出错。--body-file 标志可以可靠地处理所有内容。
创建 PR 后:
gh pr edit --add-reviewer USERNAME
* 如果需要,添加标签:gh pr edit --add-label "bug" * 询问用户是否打算在其他分支上工作
* 首先推送分支:`git push -u origin HEAD`
* 显示现有 PR:`gh pr view`
* 询问他们是否想更新它
4. 合并冲突 : 分支与基准分支冲突
* 指导用户解决冲突或进行变基
在最终确定之前,请确保:
gh CLI 已安装并完成认证每周安装次数
170
代码仓库
GitHub 星标数
58.8K
首次出现
2026年1月22日
安全审计
安装于
opencode138
codex135
gemini-cli134
github-copilot131
kimi-cli108
amp108
This skill guides you through creating a well-structured GitHub pull request that follows project conventions and best practices.
Before proceeding, verify the following:
gh CLI is installedgh --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/
gh auth status
If not authenticated, guide the user to run gh auth login.
git status
If there are uncommitted changes, ask the user whether to:
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.
git remote show origin | grep "HEAD branch"
This is typically main or master.
git log origin/main..HEAD --oneline --no-decorate
Review these commits to understand:
git diff origin/main..HEAD --stat
This shows which files changed and helps identify the type of change.
Before creating the PR, you need the following information. Check if it can be inferred from:
fix/issue-123, feature/new-login)If any critical information is missing, use ask_followup_question to ask the user:
#123, fixes #123, or closes #123 in commit messagesIf 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)
Before creating the PR, consider these best practices:
Rebase on latest main (if needed):
git fetch origin
git rebase origin/main
Squash if appropriate : If there are many small "WIP" commits, consider interactive rebase:
git rebase -i origin/main
Only suggest this if commits appear messy and the user is comfortable with rebasing.
Ensure all commits are pushed:
git push origin HEAD
If the branch was rebased, you may need:
git push origin HEAD --force-with-lease
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:
#XXXX with the actual issue number, or keep as #XXXX if no issue exists (for small fixes)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.md
Create the PR using the file:
gh pr create --title "PR_TITLE" --body-file /tmp/pr-body.md --base main
Clean 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? Passing complex markdown with newlines, special characters, and checkboxes directly via --body is error-prone. The --body-file flag handles all content reliably.
After creating the PR:
gh pr edit --add-reviewer USERNAMEgh pr edit --add-label "bug"No commits ahead of main : The branch has no changes to submit
Branch not pushed : Remote doesn't have the branch
git push -u origin HEADPR already exists : A PR for this branch already exists
gh pr viewMerge conflicts : Branch conflicts with base
Before finalizing, ensure:
gh CLI is installed and authenticatedWeekly Installs
170
Repository
GitHub Stars
58.8K
First Seen
Jan 22, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode138
codex135
gemini-cli134
github-copilot131
kimi-cli108
amp108
agent-browser 浏览器自动化工具 - Vercel Labs 命令行网页操作与测试
150,000 周安装
房地产专家系统:MLS集成、虚拟看房、AI估值与物业管理技术解决方案
206 周安装
TypeScript/JavaScript 开发技能 - 掌握 Metabase 开源项目开发流程与工具
206 周安装
Upstash Redis SDK 完整指南 - Redis-JS 安装、使用与性能优化教程
206 周安装
Tavily API 网络搜索技能 - 实现网页爬取、内容提取和智能研究功能
206 周安装
企业合规助手:GDPR、CCPA等隐私法规合规指南与数据处理协议审查清单
206 周安装
DeepSpeed 开发助手:官方文档指南、API 使用与性能优化教程
207 周安装