SuperAPI AI Directory

review-code

Testing & quality

View repository

Updated 10-15 17:32

About this skill

Review Code

Multi-dimensional code review skill that analyzes code across 6 key dimensions and generates structured review reports with actionable recommendations.

Architecture Overview

┌─────────────────────────────────────────────────────────────────┐
│  ⚠️ Phase 0: Specification Study (强制前置)                       │
│              → 阅读 specs/review-dimensions.md                   │
│              → 理解审查维度和问题分类标准                          │
└───────────────┬─────────────────────────────────────────────────┘
                ↓
┌─────────────────────────────────────────────────────────────────┐
│           Orchestrator (状态驱动决策)                             │
│           → 读取状态 → 选择审查动作 → 执行 → 更新状态              │
└───────────────┬─────────────────────────────────────────────────┘
                │
    ┌───────────┼───────────┬───────────┬───────────┐
    ↓           ↓           ↓           ↓           ↓
┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐
│ Collect │ │ Quick   │ │ Deep    │ │ Report  │ │Complete │
│ Context │ │ Scan    │ │ Review  │ │ Generate│ │         │
└─────────┘ └─────────┘ └─────────┘ └─────────┘ └─────────┘
     ↓           ↓           ↓           ↓
┌─────────────────────────────────────────────────────────────────┐
│                     Review Dimensions                            │
│  ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐            │
│  │Correctness│ │Readability│ │Performance│ │ Security │            │
│  └──────────┘ └──────────┘ └──────────┘ └──────────┘            │
│  ┌──────────┐ ┌──────────┐                                       │
│  │ Testing  │ │Architecture│                                      │
│  └──────────┘ └──────────┘                                       │
└─────────────────────────────────────────────────────────────────┘

Project Context: Run ccw spec load --category review for review standards, checklists, and approval gates.

Key Design Principles

  1. Multi-dimensional Review: Covers six major dimensions: correctness, readability, performance, security, test coverage, and architectural consistency
  2. Layered Execution: Rapid scanning identifies high-risk areas, in-depth review focuses on key issues
  3. Structured Report: Classified by severity, providing file locations and fix suggestions
  4. State-driven: Autonomous mode, dynamically selecting the next action based on review progress

⚠️ Mandatory Prerequisites (Mandatory Prerequisites)

⛔ Skipping prohibited: Before performing any review operation,mustfully read the following documents.

Specification Documents (Required Reading)

Document Purpose Priority
specs/review-dimensions.md Review dimension definitions and checkpoints P0 - Highest
specs/issue-classification.md Issue classification and severity standards P0 - Highest
specs/quality-standards.md Review quality standards P1

Template Files (Required Reading Before Generation)

Document Purpose
templates/review-report.md Review report template
templates/issue-template.md Issue record template

Execution Flow

┌─────────────────────────────────────────────────────────────────┐
│  Phase 0: Specification Study (强制前置 - 禁止跳过)               │
│  → Read: specs/review-dimensions.md                              │
│  → Read: specs/issue-classification.md                           │
│  → 理解审查标准和问题分类                                          │
├─────────────────────────────────────────────────────────────────┤
│  Action: collect-context                                         │
│  → 收集目标文件/目录                                               │
│  → 识别技术栈和语言                                                │
│  → Output: state.context (files, language, framework)            │
├─────────────────────────────────────────────────────────────────┤
│  Action: quick-scan                                              │
│  → 快速扫描整体结构                                                │
│  → 识别高风险区域                                                  │
│  → Output: state.risk_areas, state.scan_summary                  │
├─────────────────────────────────────────────────────────────────┤
│  Action: deep-review (per dimension)                             │
│  → 逐维度深入审查                                                  │
│  → 记录发现的问题                                                  │
│  → Output: state.findings[]                                      │
├─────────────────────────────────────────────────────────────────┤
│  Action: generate-report                                         │
│  → 汇总所有发现                                                    │
│  → 生成结构化报告                                                  │
│  → Output: review-report.md                                      │
├─────────────────────────────────────────────────────────────────┤
│  Action: complete                                                │
│  → 保存最终状态                                                    │
│  → 输出审查摘要                                                    │
└─────────────────────────────────────────────────────────────────┘

Directory Setup

const timestamp = new Date().toISOString().slice(0,19).replace(/[-:T]/g, '');
const workDir = `.workflow/.scratchpad/review-code-${timestamp}`;

Bash(`mkdir -p "${workDir}"`);
Bash(`mkdir -p "${workDir}/findings"`);

Output Structure

.workflow/.scratchpad/review-code-{timestamp}/
├── state.json                    # 审查状态
├── context.json                  # 目标上下文
├── findings/                     # 问题发现
│   ├── correctness.json
│   ├── readability.json
│   ├── performance.json
│   ├── security.json
│   ├── testing.json
│   └── architecture.json
└── review-report.md              # 最终审查报告

Review Dimensions

Dimension Focus Areas Key Checks
Correctness Logical correctness Boundary conditions, error handling, null checks
Readability Code readability Naming conventions, function length, comment quality
Performance Performance efficiency Algorithmic complexity, I/O optimization, resource usage
Security Security Injection risks, sensitive information, permission control
Testing Test coverage Test adequacy, boundary coverage, maintainability
Architecture Architectural consistency Design patterns, layered structure, dependency management

Issue Severity Levels

Level Prefix Description Action Required
Critical [C] Blocking issue, must be fixed immediately Must fix before merge
High [H] Important issue, needs to be fixed Should fix
Medium [M] Suggested improvement Consider fixing
Low [L] Optional optimization Nice to have
Info [I] Informational suggestion For reference

Reference Documents

Document Purpose
phases/orchestrator.md Review orchestrator
phases/state-schema.md State structure definition
phases/actions/action-collect-context.md Collect context
phases/actions/action-quick-scan.md Rapid scan
phases/actions/action-deep-review.md In-depth review
phases/actions/action-generate-report.md Generate report
phases/actions/action-complete.md Complete review
specs/review-dimensions.md Review dimension specification
specs/issue-classification.md Issue classification standards
specs/quality-standards.md Quality standards
templates/review-report.md Report template
templates/issue-template.md Issue template