一键导入
code-reviewer
Comprehensive code review checking quality, security, and best practices. Triggers: CR, review, 審查, 檢查, check, 看一下, PR, code review, 品質, inspect, 檢視, 看看, 幫看, lint, quality check, 品質檢查, pull request, merge request, MR, diff, 程式碼審查.
菜单
Comprehensive code review checking quality, security, and best practices. Triggers: CR, review, 審查, 檢查, check, 看一下, PR, code review, 品質, inspect, 檢視, 看看, 幫看, lint, quality check, 品質檢查, pull request, merge request, MR, diff, 程式碼審查.
Deep comprehensive code audit across quality, security, architecture compliance, test coverage, and documentation sync. Triggers: AUDIT, 審計, audit, 全面審查, deep review, 深度審查, 健檢, health check, 程式碼審計, codebase audit, 完整檢查, full check.
Check health, freshness, and consistency of all Skills, copilot-instructions.md, chatmodes, and bylaws. Triggers: SHC, health, 健康檢查, skill check, freshness, 翻新, 過期, stale, 檢查 skill, instruction check, audit skills, 技能檢查.
Structured bug fixing workflow with root cause analysis and regression prevention. Triggers: BF, 修 bug, fix bug, debug, 除錯, 錯誤, error, 問題, issue, 修復, fix, 故障, fault, 異常, exception, 失敗, failure, 不能用, broken, 壞掉.
Auto-update CHANGELOG.md following Keep a Changelog format. Triggers: CL, changelog, 變更, 版本, version, 更新日誌, whatsnew, release notes, 發布說明, 變更紀錄, history, 歷史, 更新紀錄, 新功能, new features, breaking changes.
Proactively detect and execute code refactoring to maintain DDD architecture and code quality. Triggers: RF, refactor, 重構, 拆分, split, 模組化, modularize, 太長, cleanup, 整理, clean, 優化, optimize, extract, 提取, simplify, 簡化, 複雜度, complexity, 重組, reorganize, 改善, improve.
Complete code review workflow for PR/MR with multiple reviewers and automated checks. Triggers: PRW, 審查流程, review workflow, PR review, MR review, pull request, merge request, 程式碼審查流程, full review, 完整審查.
name: code-reviewer description: Comprehensive code review checking quality, security, and best practices. Triggers: CR, review, 審查, 檢查, check, 看一下, PR, code review, 品質, inspect, 檢視, 看看, 幫看, lint, quality check, 品質檢查, pull request, merge request, MR, diff, 程式碼審查. version: 2.2.0 category: quality compatibility:
對程式碼進行全面審查,檢查品質、安全性、效能和最佳實踐。
詢問或推斷審查目標:
read_file("path/to/file.py")grep_search 取得概覽semantic_search("功能名稱")get_changed_files()# Ruff - 快速 linter (取代 flake8 + isort + pyupgrade)
uv run ruff check src/ --output-format=concise
# Mypy - 型別檢查
uv run mypy src/ --ignore-missing-imports
# Bandit - 安全性檢查
uv run bandit -r src/ -ll
# Vulture - 死碼偵測
uv run vulture src/ --min-confidence 80
| 檢查項目 | 標準 | 工具輔助 |
|---|---|---|
| 命名清晰度 | 名稱應描述用途 | 人工審查 |
| 函數長度 | < 50 行 | grep_search |
| 類別大小 | < 300 行 | grep_search |
| 複雜度 | McCabe < 10 | ruff --select=C901 |
| DRY 原則 | 無重複程式碼 | semantic_search |
| SOLID 原則 | 單一職責等 | 人工審查 |
| 風險類型 | 檢查方式 | 嚴重程度 |
|---|---|---|
| SQL 注入 | 搜尋 raw SQL | 🔴 Critical |
| XSS | 搜尋未轉義輸出 | 🔴 Critical |
| 硬編碼密碼 | grep "password|secret|key" | 🔴 Critical |
| 路徑遍歷 | 搜尋未驗證路徑 | 🟠 High |
| 日誌洩漏 | 搜尋敏感資料輸出 | 🟡 Medium |
| 問題類型 | 偵測方式 |
|---|---|
| N+1 查詢 | 搜尋迴圈內的 DB 呼叫 |
| 無謂迴圈 | 審查巢狀迴圈 |
| 記憶體洩漏 | 檢查資源釋放 |
| 阻塞操作 | 審查 I/O 操作 |
參考 ddd-architect 規則:
# 程式碼審查報告
📁 審查範圍:`src/domain/`, `src/application/`
📅 日期:2026-01-15
👤 審查者:AI Assistant
---
## 📈 總覽
| 指標 | 分數 | 說明 |
| ---- | ---- | ---- |
| 品質 | 8/10 | 命名清晰,部分函數過長 |
| 安全 | 9/10 | 無明顯漏洞 |
| 效能 | 7/10 | 存在 N+1 查詢風險 |
| 架構 | 8/10 | 符合 DDD,但有小違規 |
---
## ✅ 優點
1. **清晰的領域模型**:User entity 封裝良好
2. **完整的錯誤處理**:使用自定義例外
3. **良好的測試覆蓋**:核心邏輯有單元測試
---
## ⚠️ 問題發現
### 🔴 Critical (必須修復)
#### 1. SQL 注入風險
- **位置**:[user_repository.py](src/infrastructure/repositories/user_repository.py#L45)
- **問題**:使用字串拼接建立 SQL
- **建議**:使用參數化查詢
```python
# ❌ 現有
query = f"SELECT * FROM users WHERE name = '{name}'"
# ✅ 建議
query = "SELECT * FROM users WHERE name = ?"
cursor.execute(query, (name,))
authenticate() 函數 65 行
---
## 🔄 與其他 Skills 整合
| Skill | 整合方式 |
| ----- | -------- |
| `code-refactor` | 發現問題後調用進行重構 |
| `security-reviewer` | 深入安全審查時調用 |
| `test-generator` | 發現測試不足時調用 |
| `ddd-architect` | 架構違規時參考 |
---
## ⚠️ 注意事項
1. **避免過度批評**:指出問題同時肯定優點
2. **提供具體建議**:不只說「這裡有問題」,要說「建議這樣改」
3. **標註嚴重程度**:區分 Critical/High/Medium/Low
4. **考慮上下文**:原型專案和生產專案標準不同
5. **可操作性**:每個問題應有明確的修復方向