claude-code/claude-zh/commands/code-review.md

41 lines
1.1 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 程式碼審查 (Code Review)
對未提交的變更進行全面的安全與品質審查:
1. 獲取已變更的檔案:`git diff --name-only HEAD`
2. 針對每個變更的檔案,檢查以下項目:
**安全問題 (極高優先級 - CRITICAL):**
- 硬編碼的憑據、API 金鑰、Token
- SQL 注入漏洞
- XSS 漏洞
- 缺少輸入驗證
- 不安全的依賴項
- 路徑遍歷 (Path traversal) 風險
**程式碼品質 (高優先級 - HIGH):**
- 函式超過 50 行
- 檔案超過 800 行
- 嵌套深度超過 4 層
- 缺少錯誤處理
- `console.log` 語句
- TODO/FIXME 註釋
- 公共 API 缺少 JSDoc
**最佳實踐 (中優先級 - MEDIUM):**
- 可變模式 (Mutation patterns應優先使用不可變資料結構)
- 程式碼/註釋中的 Emoji 使用
- 新程式碼缺少測試
- 無障礙設計 (a11y) 問題
3. 產生報告,包含:
- 嚴重程度CRITICAL, HIGH, MEDIUM, LOW
- 檔案位置與行號
- 問題描述
- 建議的修復方案
4. 如果發現 CRITICAL 或 HIGH 層級的問題,則禁止提交 (Block commit)
絕對不要核准帶有安全漏洞的程式碼!