/cook-zh-tw:pr-create runs instead · from cook-zh-tw
Automates PR creation from Git changes: analyzes diffs, selects labels, preserves templates, and creates draft PRs via GitHub CLI or API.
This skill never runs in Claude Code
It ships in cook-zh-tw at skills/, but /cook-zh-tw:pr-create (a command, or a skill Claude Code finds first) has the same name: typing it, or Claude choosing it, runs that one instead.
不再推薦:請優先使用
/pr-create-smart生成高質量的 PR 描述草稿,然後使用 gh/GUI 創建 PR。本命令属于“端到端自動創建 PR(保留模板、自動打標簽、創建 Draft)”的旧方案,仅為兼容保留。
基于 Git 變更分析的自動 PR 創建,實現高效的 Pull Request 工作流程。
# 基于變更分析的自動 PR 創建
git add . && git commit -m "feat: 實現用戶認證功能"
"分析變更內容並使用適当的描述和標簽創建 Draft PR"
# 保留現有模板的更新
cp .github/PULL_REQUEST_TEMPLATE.md pr_body.md
"完全保留模板結構並補充變更內容"
# 逐步提升質量
gh pr ready
"質量確認完成後,更改為 Ready for Review"
# 1. 創建分支並提交
git checkout main && git pull
git checkout -b feat-user-profile
git add . && git commit -m "feat: 實現用戶檔案功能"
git push -u origin feat-user-profile
# 2. PR 創建
"請按以下步骤創建 PR:
1. 使用 git diff --cached 確認變更內容
2. 使用 .github/PULL_REQUEST_TEMPLATE.md 創建描述
3. 從變更內容選擇最多 3 個適当的標簽
4. 創建 Draft PR(保留 HTML 注釋)"
# 3. CI 確認後轉為 Ready
"CI 通過後將 PR 更改為 Ready for Review"
# 遵循準則的命名規則: {type}-{subject}
git checkout main
git pull
git checkout -b feat-user-authentication
# 確認分支 (顯示當前分支名)
git branch --show-current
# 暂存變更
git add .
# 遵循準則的提交消息
git commit -m "feat: 實現用戶認證 API"
# 首次推送 (設置 upstream)
git push -u origin feat-user-authentication
# 後續推送
git push
步骤 1: 分析變更內容
# 獲取文件變更 (確認已暂存的變更)
git diff --cached --name-only
# 內容分析 (最多 1000 行)
git diff --cached | head -1000
步骤 2: 自動生成描述
# 模板處理優先級
# 1. 現有 PR 描述 (完全保留)
# 2. .github/PULL_REQUEST_TEMPLATE.md
# 3. 默認模板
cp .github/PULL_REQUEST_TEMPLATE.md pr_body.md
# 保留 HTML 注釋·分隔線,仅補充空白部分
步骤 3: 自動選擇標簽
# 獲取可用標簽 (非交互式)
"從 .github/labels.yml 或 GitHub 倉庫獲取可用標簽,根據變更內容自動選擇適当的標簽"
# 通過模式匹配自動選擇 (最多 3 個)
# - 文檔: *.md, docs/ → documentation|docs
# - 測試: test, spec → test|testing
# - Bug 修復: fix|bug → bug|fix
# - 新功能: feat|feature → feature|enhancement
步骤 4: 通過 GitHub API 創建 PR(保留 HTML 注釋)
# PR 創建
"使用以下資訊創建 Draft PR:
- 標題: 從提交消息自動生成
- 描述: 使用 .github/PULL_REQUEST_TEMPLATE.md 適当填寫
- 標簽: 從變更內容自動選擇 (最多 3 個)
- 基礎分支: main
- 完全保留 HTML 注釋"
方法 B: GitHub MCP(備用)
// 保留 HTML 注釋的 PR 創建
mcp__github__create_pull_request({
owner: "organization",
repo: "repository",
base: "main",
head: "feat-user-authentication",
title: "feat: 實現用戶認證",
body: prBodyContent, // 包含 HTML 注釋的完整內容
draft: true,
maintainer_can_modify: true,
});
*.md, README, docs/ → documentation|docs|doctest, spec → test|testing.github/, *.yml, Dockerfile → ci|build|infra|opspackage.json, pubspec.yaml → dependencies|depsfix|bug|error|crash|修復 → bug|fixfeat|feature|add|implement|新功能|實現 → feature|enhancement|featrefactor|clean|重構 → refactor|cleanup|cleanperformance|perf|optimize → performance|perfsecurity|secure → security.github/PULL_REQUEST_TEMPLATE.md{type}-{subject}
示例:
- feat-user-profile
- fix-login-error
- refactor-api-client
{type}: {description}
示例:
- feat: 實現用戶認證 API
- fix: 修復登錄錯誤
- docs: 更新 README
.github/PULL_REQUEST_TEMPLATE.md 結構<!-- Copilot review rule --> 等<!-- ... -->--- 等結構重要: GitHub CLI (gh pr edit) 會自動轉義 HTML 注釋,在 Shell 處理中可能混入 EOF < /dev/null 等非法字符串。
根本解決方案:
# 變更後重新提交
git add .
git commit -m "fix: 基于審查反饋的更正"
git push
gh pr edit 會轉義 HTML 注釋,混入非法字符串--field 選項進行適当的轉義處理.github/labels.yml 定義外的標簽gh pr checks 確認狀態gh pr readyWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
pr-automation, git-workflow, pull-request, draft-pr, labeling
npx claudepluginhub wasabeef/claude-code-cookbook --plugin cook-zh-tw2 plugins ship this exact skill · first indexed Jul 16, 2026
39 skills in this plugin
/analyze-dependencies分析專案依賴關係並評估架構健全性分析專案依賴關係並評估架構健全性。「分析依賴關係」「檢測循環依賴」「架構問題?」「檢查模組耦合」「查找層違規」等觸發。/analyze-performance基於 Core Web Vitals 的效能分析和 UX 評分基於 Core Web Vitals 的效能分析和 UX 評分。「分析效能」「改善速度」「檢查 Core Web Vitals」「頁面速度」等觸發。/check-fact透過程式碼庫和文件驗證資訊準確性透過程式碼庫和文件驗證資訊準確性。「這個資訊對嗎?」「事實檢查」「驗證這個」等觸發。/check-prompt評估並改進 AI 提示詞品質評估並改進 AI 提示詞品質。「檢查提示詞」「評估提示詞品質」「改進提示詞」等觸發。/commit-message從暫存變更生成提交訊息從暫存變更生成提交訊息。「生成提交訊息」「建議 commit message」「寫個提交資訊」等觸發。/context7透過 Context7 MCP 搜尋技術文件透過 Context7 MCP 搜尋技術文件。「查文件」「查看官方文件」「函式庫怎麼用?」等觸發。Other plugins' skills for the same job