pr
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese/pr — 總結工作並維護 PR
/pr — Summarize work and maintain PR
請依照以下步驟執行:
ECC 資源感知: 若有可用的 code-reviewer 或 security-reviewer agent,Step 2 可委派更深度審查。
Please follow the steps below:
ECC Resource Awareness: If there are available code-reviewer or security-reviewer Agent, Step 2 can delegate for deeper review.
Step 1: 分析當前工作
Step 1: Analyze current work
1a. Git 分析
1a. Git Analysis
- 執行 和
git status(staged + unstaged)了解未 commit 的變更git diff - 執行 查看近期 commit 風格
git log - 關鍵步驟 — 確認 PR 完整範圍:
- 執行 查看 PR 包含的所有 commits
git log --oneline <base-branch>..HEAD - 執行 查看 PR 涉及的所有檔案
gh pr diff <PR-number> --name-only - 如果已有 open PR,執行 讀取現有 description
gh pr view <PR-number> --json body
- 執行
- Run and
git status(staged + unstaged) to understand uncommitted changesgit diff - Run to check recent commit style
git log - Key step — Confirm full scope of PR:
- Run to view all commits included in the PR
git log --oneline <base-branch>..HEAD - Run to view all files involved in the PR
gh pr diff <PR-number> --name-only - If there is already an open PR, run to read the existing description
gh pr view <PR-number> --json body
- Run
1b. 對話脈絡分析
1b. Conversation Context Analysis
回顧本次對話的完整內容,提取以下資訊:
- 動機:使用者最初提出的問題或需求是什麼?
- 討論過程:過程中探索了哪些方案?做了哪些比較或調查?
- 決策點:哪些地方有多個選擇?最終為什麼選擇這個方案?
- 放棄的嘗試:有沒有試過但放棄的做法?為什麼放棄?
- 隱含知識:對話中出現但不會反映在 diff 裡的重要 context(例如:調查數據、外部工具比較、效能考量)
- 業界/學術依據:技術決策是否有引用業界標準(RFC、OWASP 等)或學術研究?方案是否基於標準化解決方案?
⚠️ 常見錯誤:
- 只看
會遺漏 PR 中其他 commits 的內容git diff- 只看 diff 不看對話會遺漏「為什麼這樣做」的決策脈絡
- PR description 必須同時反映 what changed(diff) 和 why it changed(對話 context)
Review the full content of this conversation and extract the following information:
- Motivation: What was the original problem or requirement raised by the user?
- Discussion process: What solutions were explored during the process? What comparisons or investigations were done?
- Decision points: Where there were multiple options? Why was this solution finally chosen?
- Abandoned attempts: Are there any practices that were tried but abandoned? Why were they abandoned?
- Implicit knowledge: Important context that appears in the conversation but will not be reflected in the diff (e.g. survey data, external tool comparisons, performance considerations)
- Industry/academic basis: Does the technical decision reference industry standards (RFC, OWASP, etc.) or academic research? Is the solution based on standardized solutions?
⚠️ Common mistakes:
- Only looking at
will miss the content of other commits in the PRgit diff- Only looking at diff not conversation will miss the decision context of "why this was done"
- PR description must reflect both what changed (diff) and why it changed (conversation context)
1c. 總結
1c. Summary
綜合 git 分析 + 對話脈絡,總結本次工作的目的、做了什麼、為什麼這樣做。
Combine git analysis + conversation context to summarize the purpose, what was done, and why it was done of this work.
Step 2: Quick Review
Step 2: Quick Review
對所有變更進行快速 code review,檢查以下項目:
Conduct a quick code review of all changes, checking the following items:
檢查清單
Checklist
- 安全性:是否有敏感資訊外洩(API keys、secrets、.env 內容)
- 正確性:邏輯是否正確、有無明顯 bug
- 遺漏:是否有 debug code(console.log、debugger)未清除
- 型別:TypeScript 型別是否正確、有無 濫用
any - 樣式:是否符合專案既有 coding style
- Security: Is there any sensitive information leakage (API keys, secrets, .env content)
- Correctness: Is the logic correct, are there any obvious bugs
- Omissions: Are there any debug codes (console.log, debugger) not cleared
- Types: Are TypeScript types correct, is there any abuse of
any - Style: Does it conform to the existing coding style of the project
輸出格式
Output format
用簡潔的表格或清單呈現 review 結果:
- ✅ 沒問題的項目一句帶過
- ⚠️ 有疑慮但不阻擋的項目說明原因
- ❌ 必須修正的問題列出檔案和行號
Present the review results in a concise table or list:
- ✅ Passed items are mentioned in one sentence
- ⚠️ Items with concerns but not blocking explain the reason
- ❌ Problems that must be fixed list the file and line number
互動確認
Interactive confirmation
Review 完成後,使用 AskUserQuestion 詢問使用者:
- 繼續 PR 流程:review 結果沒問題,繼續 commit → push → PR
- 先修正問題:先處理 review 發現的問題,修完再重新執行
/pr
如果使用者選擇「先修正問題」,則根據 review 結果逐一修正,修正完後重新從 Step 1 開始。
After the review is completed, use AskUserQuestion to ask the user:
- Continue PR process: The review result is okay, continue commit → push → PR
- Fix problems first: Deal with the problems found in the review first, and re-run after the fix is completed
/pr
If the user chooses "Fix problems first", fix them one by one according to the review results, and restart from Step 1 after the fix is completed.
Step 3: Commit 當前變更
Step 3: Commit current changes
- 如果有未 commit 的變更,根據變更內容撰寫 commit message
- 使用 conventional commits 格式(feat / fix / chore / refactor / test / docs)
- commit message 使用英文
- 確保不要 commit 敏感檔案(.env, credentials 等)
- If there are uncommitted changes, write a commit message based on the content of the changes
- Use conventional commits format (feat / fix / chore / refactor / test / docs)
- Commit message uses English
- Ensure that sensitive files (.env, credentials, etc.) are not committed
Step 4: 推送到遠端
Step 4: Push to remote
- 確認當前 branch 是否有對應的 remote tracking branch
- 如果沒有,使用 推送
git push -u origin <branch> - 如果有,使用 推送
git push
- Confirm whether the current branch has a corresponding remote tracking branch
- If not, use to push
git push -u origin <branch> - If yes, use to push
git push
Step 5: 建立或更新 PR
Step 5: Create or update PR
Base Branch 防護(強制執行)
Base Branch Protection (Mandatory)
PR 的 base branch 禁止直接指向主要的 production branch(如 、)。
mastermain執行以下檢查:
- 讀取專案的 branch 策略(如果有 或類似文件)
skills/git-workflow/SKILL.md - 如果專案有定義預設的 base branch(如 、
hotfix),自動使用該 branchdevelop - 如果使用者明確要求指向 或
master→ 必須中斷並警告:main- 使用 AskUserQuestion 提醒:「依照專案規範,PR 不建議直接指向 master/main。確定要繼續嗎?」
- 提供選項:「改為 [專案預設 base branch](推薦)」/「我確定要指向 master/main」
- 只有使用者明確確認後才能繼續
- 如果專案沒有特別的 branch 策略,使用 repo 的 default branch
bash
undefinedThe base branch of the PR is prohibited from directly pointing to the main production branch (such as , ).
mastermainPerform the following checks:
- Read the project's branch policy (if there is or similar files)
skills/git-workflow/SKILL.md - If the project has a defined default base branch (such as ,
hotfix), use that branch automaticallydevelop - If the user explicitly requests to point to or
master→ must interrupt and warn:main- Use AskUserQuestion to remind: "According to project specifications, PR is not recommended to point directly to master/main. Are you sure you want to continue?"
- Provide options: "Change to [project default base branch] (recommended)" / "I confirm to point to master/main"
- Only continue after the user explicitly confirms
- If the project has no special branch policy, use the repo's default branch
bash
undefined範例:專案規範 base branch 為 hotfix
Example: Project specification base branch is hotfix
gh pr create --base hotfix ...
gh pr create --base hotfix ...
禁止(除非使用者明確確認)
Prohibited (unless explicitly confirmed by the user)
gh pr create --base master ...
undefinedgh pr create --base master ...
undefined判斷邏輯
Judgment Logic
- 如果提供了 PR 號碼(),更新該 PR
$ARGUMENTS - 如果沒有提供號碼,檢查當前 branch 是否已有 open PR
- 有 → 更新該 PR description
- 沒有 → 建立新 PR(使用專案規範的 base branch)
- If a PR number is provided (), update that PR
$ARGUMENTS - If no number is provided, check if there is already an open PR for the current branch
- Yes → Update the PR description
- No → Create a new PR (using the project-specified base branch)
PR Description 格式
PR Description Format
PR description 必須包含以下區塊,使用繁體中文撰寫:
markdown
undefinedThe PR description must include the following sections, written in Traditional Chinese:
markdown
undefinedSummary
Summary
<!-- 1-3 句話說明這個 PR 的目的和背景脈絡 -->
<!-- 重點:讓 reviewer 30 秒內理解「為什麼要做這件事」 -->
<!-- 1-3 句話說明這個 PR 的目的和背景脈絡 -->
<!-- 重點:讓 reviewer 30 秒內理解「為什麼要做這件事」 -->
Context(對話脈絡)
Context(對話脈絡)
<!-- 這是最重要的區塊 — 從對話中提取 reviewer 需要知道的 context -->
<!-- 來源:Step 1b 的對話脈絡分析結果 -->
<!--
必須包含:
- 使用者的原始需求(不只是最終實作,而是「為什麼要做這件事」)
- 過程中的調查/比較(例如:比較了 3 個框架,選了 X 因為 Y)
- 關鍵決策點和取捨(例如:選擇性採用而非全面導入,因為...)
- 放棄的方案和原因(例如:考慮過 Semcheck 但太早期)
- 不會出現在 diff 中的重要數據(例如:審計發現 145+ 檔案使用 Bootstrap)
- 技術方案的業界/學術依據(例如:採用 OAuth 2.0 因為 RFC 6749、選擇 bcrypt 因為 OWASP 建議)
-->
<!-- 目標:reviewer 不需要問「為什麼這樣做?」就能從這裡找到答案 -->
<!-- 這是最重要的區塊 — 從對話中提取 reviewer 需要知道的 context -->
<!-- 來源:Step 1b 的對話脈絡分析結果 -->
<!--
必須包含:
- 使用者的原始需求(不只是最終實作,而是「為什麼要做這件事」)
- 過程中的調查/比較(例如:比較了 3 個框架,選了 X 因為 Y)
- 關鍵決策點和取捨(例如:選擇性採用而非全面導入,因為...)
- 放棄的方案和原因(例如:考慮過 Semcheck 但太早期)
- 不會出現在 diff 中的重要數據(例如:審計發現 145+ 檔案使用 Bootstrap)
- 技術方案的業界/學術依據(例如:採用 OAuth 2.0 因為 RFC 6749、選擇 bcrypt 因為 OWASP 建議)
-->
<!-- 目標:reviewer 不需要問「為什麼這樣做?」就能從這裡找到答案 -->
Changes
Changes
<!-- 按主題分類列出變更,涵蓋 PR 的所有 commits(不只是當次對話的工作) -->
<!-- 用 git log <base-branch>..HEAD 確認完整範圍 -->
<!-- 用 git diff <base-branch>..HEAD --diff-filter=D --name-only 確認刪除的檔案 -->
<!-- 每個主題明確標示:新增了什麼、刪除了什麼、修改了什麼 -->
<!-- 按主題分類列出變更,涵蓋 PR 的所有 commits(不只是當次對話的工作) -->
<!-- 用 git log <base-branch>..HEAD 確認完整範圍 -->
<!-- 用 git diff <base-branch>..HEAD --diff-filter=D --name-only 確認刪除的檔案 -->
<!-- 每個主題明確標示:新增了什麼、刪除了什麼、修改了什麼 -->
Test plan
Test plan
<!-- 測試計畫,checkbox 格式 -->
🤖 Generated with Claude Code
undefined<!-- 測試計畫,checkbox 格式 -->
🤖 Generated with Claude Code
undefinedContext 區塊撰寫要點
Key points for writing Context block
資訊來源(按優先順序):
- 對話脈絡(Step 1b)— 使用者的原始意圖、討論過程、決策理由
- Git diff — 實際變更了什麼
- Commit messages — 每個 commit 的目的
必須包含:
- 觸發這次工作的原因(bug report、feature request、tech debt)
- 過程中的調查和比較結果(數據、框架比較、技術評估)
- 做過但放棄的嘗試(如果有的話),以及放棄的原因
- 關鍵決策點(為什麼選 A 不選 B)
- 最終方案的設計考量
- 不會出現在 diff 中但 reviewer 需要知道的 context
常見遺漏(從對話中提取,diff 看不到的):
- 「調查了 4 個框架,根據 GitHub stars 和功能比較選了 X」
- 「審計發現 145+ 個檔案受影響,所以分 4 個 phase」
- 「考慮過全面導入但太重,改為選擇性採用」
- 「這個工具只有 111 stars,太早期所以自己寫」
目標: reviewer 不需要問「為什麼這樣做?」就能從 PR description 找到答案
Information sources (in order of priority):
- Conversation context (Step 1b) — user's original intention, discussion process, decision reason
- Git diff — what was actually changed
- Commit messages — purpose of each commit
Must include:
- The reason that triggered this work (bug report, feature request, tech debt)
- Investigation and comparison results in the process (data, framework comparison, technical evaluation)
- Attempts that were made but abandoned (if any), and the reasons for abandonment
- Key decision points (why choose A instead of B)
- Design considerations of the final solution
- Context that will not appear in the diff but reviewers need to know
Common omissions (extracted from conversation, not visible in diff):
- "Investigated 4 frameworks, chose X based on GitHub stars and feature comparison"
- "Audit found that more than 145 files are affected, so divided into 4 phases"
- "Considered full implementation but it is too heavy, changed to selective adoption"
- "This tool only has 111 stars, it is too early so we wrote it ourselves"
Goal: Reviewers can find the answer from the PR description without asking "Why did you do this?"
Step 6: 確認結果
Step 6: Confirm results
- 輸出 PR URL
- 確認 PR description 已更新
- 如果有相關的其他 PR(如 feature → develop、develop → master),檢查是否需要同步更新
- Output PR URL
- Confirm that the PR description has been updated
- If there are other related PRs (such as feature → develop, develop → master), check whether synchronous update is required
使用方式
Usage
/pr # 自動偵測是否有 open PR,沒有就建新的
/pr 7195 # 更新指定 PR 的 description
/pr # Automatically detect if there is an open PR, create a new one if not
/pr 7195 # Update the description of the specified PR