一键导入
code-reviewer
Automated code review that checks code quality, Clean Architecture compliance, DDD patterns, coding standards, and spec traceability.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Automated code review that checks code quality, Clean Architecture compliance, DDD patterns, coding standards, and spec traceability.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
從規格目錄的 acceptance.yaml 生成/維護 BDD/ezSpec 測試。使用類似 Gherkin 語法,AI 自動產生 step definition(開發人員不需要手寫),驗收測試規格即為 Executable Specification。
在單元測試通過後觸發。透過引入人工錯誤(Mutants)來「測試你的測試」,確保測試案例具有足夠的錯誤偵測能力,建立對驗證機制的信任(Trust the Verification)。
驗證規格檔案的完整性與一致性,確保所有必要的規格元素都已定義且符合標準格式。
Replace with description of the skill and when Claude should use it.
協調多個 AI 模型(ChatGPT、Gemini、Codex、QWEN、Claude)進行三角驗證,確保「Specification == Program == Test」一致性。過濾假警報後輸出報告,大幅減少人工介入時間。
處理跨 Frame 的複雜業務流程,協調多個 Sub-agent (command/query/reactor) 完成 Saga/Choreography 模式的分散式交易。當需求涉及多個狀態變更、事件反應與查詢的組合時使用。
| name | code-reviewer |
| description | Automated code review that checks code quality, Clean Architecture compliance, DDD patterns, coding standards, and spec traceability. |
multi-model-reviewer 協作時architecture_checks:
layer_dependency:
name: "依賴方向"
rule: "外層只能依賴內層,內層不得依賴外層"
layers:
- adapter (外) → usecase → entity (內)
violations:
- "Entity 不得 import UseCase"
- "UseCase 不得 import Adapter"
package_structure:
name: "套件結構"
rule: "符合 {aggregate}/{layer}/{component} 結構"
expected:
- "{aggregate}/adapter/in/web/"
- "{aggregate}/adapter/out/persistence/"
- "{aggregate}/entity/"
- "{aggregate}/usecase/port/"
- "{aggregate}/usecase/service/"
ddd_checks:
aggregate_root:
name: "Aggregate Root 識別"
rule: "Aggregate Root 必須控制子實體的生命週期"
markers:
- "@AggregateRoot annotation"
- "private constructor for child entities"
value_object:
name: "Value Object 不變性"
rule: "Value Object 必須 immutable"
checks:
- "record class 或 final fields"
- "no setters"
- "equals/hashCode based on all fields"
domain_event:
name: "Domain Event 標準"
rule: "符合 domain-event-standard.yaml"
checks:
- "sealed interface DomainEvent"
- "includes standard metadata"
- "occurredOn timestamp"
參考對應的編碼標準:
| 語言 | 參考文件 |
|---|---|
| Java | skills/coding-standards/references/JAVA_CLEAN_ARCH.md |
| TypeScript | skills/coding-standards/references/TYPESCRIPT.md |
| Go | skills/coding-standards/references/GOLANG.md |
| Rust | skills/coding-standards/references/RUST.md |
usecase_checks:
- id: UC1
name: "單一職責"
rule: "一個 Service 只處理一個 Use Case"
- id: UC2
name: "Port 依賴"
rule: "透過 Port interface 依賴外部資源"
- id: UC3
name: "輸入驗證"
rule: "Input DTO 在 UseCase 層驗證"
- id: UC4
name: "Domain Event 發布"
rule: "狀態變更後發布對應 Domain Event"
- id: UC5
name: "交易邊界"
rule: "Aggregate 操作在單一交易內完成"
aggregate_checks:
- id: AG1
name: "Invariant 保護"
rule: "所有 public 方法必須維護 invariants"
- id: AG2
name: "私有建構子"
rule: "Child Entity 使用 private/package constructor"
- id: AG3
name: "狀態封裝"
rule: "不直接暴露可變集合"
- id: AG4
name: "Factory Method"
rule: "複雜物件使用 Factory 創建"
adapter_checks:
- id: AD1
name: "Port 實作"
rule: "Adapter 必須實作對應的 Port interface"
- id: AD2
name: "依賴注入"
rule: "透過 Constructor Injection"
- id: AD3
name: "錯誤轉換"
rule: "Infrastructure 錯誤轉換為 Domain 錯誤"
╔═══════════════════════════════════════════════════════════════════╗
║ CODE REVIEW REPORT ║
╠═══════════════════════════════════════════════════════════════════╣
║ File: CreateWorkflowService.java ║
║ Aggregate: Workflow ║
║ Layer: usecase/service ║
╠═══════════════════════════════════════════════════════════════════╣
║ ║
║ ✅ UC1: Single Responsibility PASS ║
║ ✅ UC2: Port Dependency PASS ║
║ ✅ UC3: Input Validation PASS ║
║ ⚠️ UC4: Domain Event Publication WARNING ║
║ └─ Event 'WorkflowCreated' missing 'metadata' field ║
║ ✅ UC5: Transaction Boundary PASS ║
║ ║
╠═══════════════════════════════════════════════════════════════════╣
║ TOTAL: 4/5 PASS, 1 WARNING ║
╚═══════════════════════════════════════════════════════════════════╝
review_issues:
- id: CR-001
file: "CreateWorkflowService.java"
line: 45
severity: warning
check: UC4
message: "Domain Event 'WorkflowCreated' missing 'metadata' field"
current_code: |
return new WorkflowCreated(
workflow.getId(),
workflow.getBoardId(),
workflow.getName()
);
suggested_fix: |
return new WorkflowCreated(
workflow.getId(),
workflow.getBoardId(),
workflow.getName(),
EventMetadata.now() // Add metadata
);
spec_reference: "aggregate.yaml#domain_events.WorkflowCreated"
┌─────────────────────┐
│ code-reviewer │ ◄── 本 Skill
│ (代碼審查) │
└──────────┬──────────┘
│
┌───────────────────┼───────────────────┐
│ │ │
▼ ▼ ▼
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ arch-guard │ │coding-standards │ │ multi-model- │
│ (架構守護) │ │ (編碼標準) │ │ reviewer │
└─────────────────┘ └─────────────────┘ └─────────────────┘
language: java
architecture: clean-architecture
checks:
architecture:
enabled: true
strict: true
coding_standards:
enabled: true
config: ".coding-standards.yaml"
spec_compliance:
enabled: true
spec_dir: "docs/specs/"
ignore:
files:
- "**/test/**"
- "**/generated/**"
rules:
- UC5 # Skip transaction check for specific cases
severity_thresholds:
error: 0 # Block if any errors
warning: 5 # Block if > 5 warnings