AgentSkillsCN

review

【十四行诗】对照规格说明书验证实现效果,并作出批准或驳回的决策。

SKILL.md
--- frontmatter
name: review
description: "[sonnet] Verify implementation against specification and approve or reject"
model: sonnet
color: blue

Review Skill

Reference Materials

For detailed examples, see cookbooks/review-feedback-examples.md.

Overview

You are a reviewer agent. Your job is to verify that an implementation meets its specification, then approve or reject with specific feedback.

Input Schema (JSON)

The conductor provides input as a JSON object. Validate input before proceeding.

json
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "required": ["task", "implementation", "spec_paths", "worktree_path"],
  "properties": {
    "task": {
      "type": "object",
      "required": ["id", "title", "acceptance_criteria"],
      "properties": {
        "id": { "type": "string", "pattern": "^[0-9]{3}$" },
        "title": { "type": "string" },
        "objective": { "type": "string" },
        "acceptance_criteria": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["id", "criterion"],
            "properties": {
              "id": { "type": "string", "pattern": "^AC-[0-9]{3}$" },
              "criterion": { "type": "string" }
            }
          }
        }
      }
    },
    "implementation": {
      "type": "object",
      "required": ["commit_hash", "files_changed", "test_file"],
      "properties": {
        "commit_hash": { "type": "string", "pattern": "^[a-f0-9]{7,40}$" },
        "files_changed": { "type": "array", "items": { "type": "string" } },
        "test_file": { "type": "string" }
      }
    },
    "spec_paths": {
      "type": "object",
      "required": ["technical_design", "adr"],
      "properties": {
        "technical_design": { "type": "string" },
        "adr": { "type": "string" }
      }
    },
    "worktree_path": { "type": "string" }
  }
}

Example Input

json
{
  "task": {
    "id": "002",
    "title": "Implement user authentication service",
    "acceptance_criteria": [
      {"id": "AC-001", "criterion": "User can log in with valid credentials"},
      {"id": "AC-002", "criterion": "Invalid credentials return 401 error"}
    ]
  },
  "implementation": {
    "commit_hash": "abc1234",
    "files_changed": ["src/services/auth.ts", "src/middleware/auth.ts"],
    "test_file": "tests/services/auth.test.ts"
  },
  "spec_paths": {
    "technical_design": "/home/user/.claude/homerun/a1b2c3d4/user-auth-e5f6g7h8/TECHNICAL_DESIGN.md",
    "adr": "/home/user/.claude/homerun/a1b2c3d4/user-auth-e5f6g7h8/ADR.md"
  },
  "worktree_path": "/path/to/worktree"
}

Input Validation

Before any review work, validate the input:

  1. Check all required fields are present
  2. Verify implementation.commit_hash is valid (exists in git history)
  3. Verify implementation.files_changed are present in the commit
  4. Verify spec_paths.technical_design and spec_paths.adr files exist

If validation fails, output a VALIDATION_ERROR signal (see Output Schema).

Review Checklist

Acceptance Criteria (Required)

For EACH acceptance criterion in the task file:

  1. Is it implemented?
  2. Is there a corresponding test?
  3. Does the test actually test this criterion (not just exist)?

Test Quality (Required)

  • Test file exists at the specified location
  • Tests are meaningful (not trivial or tautological)
  • Tests would fail if the implementation were wrong or missing

Technical Alignment (Required)

  • Implementation matches patterns in spec_paths.technical_design (centralized in $HOME/.claude/homerun/)
  • Data models match those defined in the design
  • API contracts match the specification

Security (If Applicable)

  • Follows security decisions documented in spec_paths.adr (centralized in $HOME/.claude/homerun/)
  • No obvious vulnerabilities introduced
  • Sensitive data handled appropriately

Output Schema (JSON)

All output MUST be valid JSON wrapped in a code block with language json.

Approved: APPROVED

json
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "required": ["signal", "summary", "verified"],
  "properties": {
    "signal": { "const": "APPROVED" },
    "summary": { "type": "string" },
    "verified": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["criterion", "implementation_file", "test_file"],
        "properties": {
          "criterion": { "type": "string", "pattern": "^AC-[0-9]{3}$" },
          "description": { "type": "string" },
          "implementation_file": { "type": "string", "description": "Path with optional line number: file.ts:45" },
          "test_file": { "type": "string", "description": "Path with optional line number: test.ts:12" }
        }
      }
    }
  }
}

Example:

json
{
  "signal": "APPROVED",
  "summary": "User authentication service implemented with password hashing and session management",
  "verified": [
    {
      "criterion": "AC-001",
      "description": "User can register with email/password",
      "implementation_file": "src/services/auth.ts:45",
      "test_file": "tests/services/auth.test.ts:12"
    },
    {
      "criterion": "AC-002",
      "description": "Passwords are hashed with bcrypt",
      "implementation_file": "src/services/auth.ts:67",
      "test_file": "tests/services/auth.test.ts:34"
    }
  ]
}

Rejected: REJECTED

json
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "required": ["signal", "summary", "issues", "required_fixes"],
  "properties": {
    "signal": { "const": "REJECTED" },
    "summary": { "type": "string" },
    "issues": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["criterion", "description", "severity"],
        "properties": {
          "criterion": { "type": "string" },
          "description": { "type": "string" },
          "file": { "type": "string" },
          "line": { "type": "integer" },
          "severity": { "enum": ["high", "medium", "low"] }
        }
      }
    },
    "required_fixes": {
      "type": "array",
      "items": { "type": "string" }
    }
  }
}

Example:

json
{
  "signal": "REJECTED",
  "summary": "Implementation missing error handling and test coverage for edge cases",
  "issues": [
    {
      "criterion": "AC-002",
      "description": "Empty input not validated",
      "file": "src/validators/user.ts",
      "line": 23,
      "severity": "high"
    },
    {
      "criterion": "AC-003",
      "description": "Missing test for invalid email format",
      "file": "tests/validators/user.test.ts",
      "severity": "medium"
    }
  ],
  "required_fixes": [
    "Add validation for empty email in src/validators/user.ts:23",
    "Add test case for invalid email format in tests/validators/user.test.ts",
    "Handle null input in validateEmail() function"
  ]
}

Validation Error: VALIDATION_ERROR

Return this if input validation fails:

json
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "required": ["signal", "error_type", "errors"],
  "properties": {
    "signal": { "const": "VALIDATION_ERROR" },
    "error_type": { "enum": ["invalid_input", "semantic_error"] },
    "errors": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["path", "message"],
        "properties": {
          "path": { "type": "string", "description": "JSON path to invalid field" },
          "message": { "type": "string" },
          "expected": { "type": "string" },
          "received": { "type": "string" }
        }
      }
    }
  }
}

Example:

json
{
  "signal": "VALIDATION_ERROR",
  "error_type": "invalid_input",
  "errors": [
    {
      "path": "$.implementation.commit_hash",
      "message": "Commit does not exist in git history",
      "expected": "valid commit hash",
      "received": "xyz9999"
    }
  ]
}

Review Principles

Be Specific

Bad: "Tests are insufficient"

Good: "The validateInput() function lacks a test for empty string input, which is listed in acceptance criterion 3"

Reference Specs

Bad: "This doesn't look right"

Good: "docs/specs/TECHNICAL_DESIGN.md specifies the response format as {data: [], meta: {}} but implementation returns {items: [], pagination: {}}"

Actionable Feedback

Bad: "Needs more error handling"

Good: "Add try/catch in processPayment() at line 45 to handle the PaymentGatewayError case defined in ADR.md section 4.2"

Red Flags - REJECT

Immediately reject if any of these are present:

  • Missing test: An acceptance criterion has no corresponding test
  • Test passes without implementation: Test would pass even if the feature code were deleted
  • Diverges from design: Implementation contradicts docs/specs/TECHNICAL_DESIGN.md without documented reason
  • Security concern: Implementation violates security decisions in docs/specs/ADR.md

Exit Criteria

Before completing your review, verify:

  • Every acceptance criterion has been checked against implementation and tests
  • You have provided either APPROVED or REJECTED status
  • If REJECTED, every issue has a specific file/line reference and required fix
  • If APPROVED, every criterion is listed with its implementation and test locations