---
name: review-checklist
description: Review the UNIT_CHECKLIST or INTEGRATION_CHECKLIST document's contents and generate a test coverage report against TEST_SPEC.md.
argument-hint: "Relative path of the checklist document to review (default: test/checklists/UNIT_CHECKLIST-XXXX.md)"
---

Read and review the contents of the target checklist document in the workspace using a structured checklist with three severity levels (問題, 要確認, 提案), and generate a test coverage report compared to TEST_SPEC.md.

## Review Checklist

### 1. 問題 (Issue/Problem - High Severity)

*Critical errors, logic flaws, or gaps that must be corrected.*

*   **テスト仕様書との不整合 (Inconsistency with TEST_SPEC)**: Check if test cases in `TEST_SPEC.md` are missing from the checklist, or if test cases exist in the checklist that are not defined in `TEST_SPEC.md`.
*   **フォーマットの違反 (Formatting Errors)**: Ensure the checklist table structure matches: `| ID1 | ID2 | ID3 | 大項目 | 中項目 | 小項目 | 確認日 | 版 | 確認者 | 結果 | 備考 |`.
*   **無効なステータス (Invalid Test Results)**: Ensure "結果" values are strictly limited to `TODO`, `OK`, `NG`, or `SKIP`.

### 2. 要確認 (Needs Confirmation/Clarification - Medium Severity)

*Items that require clarification or validation.*

*   **テスト実施メタデータの不足 (Missing Execution Metadata)**: Check if completed tests (`OK` or `NG`) are missing "確認日" or "確認者".
*   **NG原因・詳細の不足 (Missing Details for Failed Tests)**: Ensure all `NG` results have explanations or links to issues in the "備考" column.

### 3. 提案 (Suggestion/Recommendation - Low Severity)

*Constructive ideas to improve clarity, coverage, or test execution.*

*   **SKIP項目の見直し (Review of SKIP Items)**: Suggest documenting explicit reasons for any `SKIP` status or propose moving them to automated tests.

---

## Execution Flow

1. **Locate Target Files**:
   *   Identify the target checklist file from arguments (default to the latest file in `test/checklists/`).
   *   Locate the corresponding test specification document (`docs/TEST_SPEC.md` or `docs/<Application>/TEST_SPEC.md`).
2. **Analyze Coverage and Run Verification**:
   *   Compare the checklist entries with the defined test cases in `TEST_SPEC.md`.
   *   Calculate the following metrics:
       *   **Total Test Cases** (defined in `TEST_SPEC.md`)
       *   **Mapped Cases** (present in the checklist)
       *   **Executed Cases** (status is `OK`, `NG`, or `SKIP`)
       *   **Test Coverage Rate**: `(Mapped Cases / Total Test Cases) * 100` (%)
       *   **Test Execution Rate**: `(Executed Cases / Mapped Cases) * 100` (%)
       *   **Pass Rate**: `(OK Cases / (Executed Cases - SKIP Cases)) * 100` (%)
3. **Conduct Review**:
   *   Inspect metadata, format, and remarks according to the checklist rules.
4. **Save Report to File**:
   *   Save the formatted review report to `.review/[relative-path-to-target-document]` (e.g., `.review/test/checklists/UNIT_CHECKLIST-XXXX.md`).
5. **Output Report**:
   *   Present the structured report in the chat and notify the user of the path.

---

## Output Report Format

Output the review report using the following structure:

```markdown
# Document Review & Test Coverage Report: [file basename]

Review of: `[relative/path/to/checklist]`
Against: `[relative/path/to/TEST_SPEC.md]`

## Executive Summary

| Severity | Count | Key Focus |
| --- | --- | --- |
| 🔴 問題 (High) | 0 | Inconsistencies with TEST_SPEC or formatting errors |
| 🟡 要確認 (Medium) | 0 | Incomplete execution metadata or lack of fail details |
| 🟢 提案 (Low) | 0 | Structural or test execution efficiency improvements |

## Test Coverage Metrics

| Metric | Value | Description |
| --- | --- | --- |
| Total Test Cases (仕様書総ケース数) | X | TEST_SPEC.md に定義されている総テストケース数 |
| Mapped Cases (マッピング数) | Y | チェックリストにインポートされているケース数 |
| Test Coverage Rate (カバレッジ率) | XX.X% | テスト仕様書に対するチェックリストのカバー率 |
| Test Execution Rate (実行率) | YY.Y% | マッピング数に対するテスト実施済み割合 |
| Pass Rate (合格率) | ZZ.Z% | テスト実施（SKIP除く）に対する OK 割合 |

### Execution Details
*   **TODO (未実施)**: A
*   **OK (合格)**: B
*   **NG (不合格)**: C
*   **SKIP (スキップ)**: D

---

## Detailed Findings

### 🔴 問題 (High Severity)
*List critical issues.*

- **[Short Summary]**
  - **Location**: Line X-Y / Section name
  - **Original Text**: `[original text]`
  - **Description**: [Why it is a problem]
  - **Recommended Action**: [Specific, actionable fix]

### 🟡 要確認 (Medium Severity)
*List items needing confirmation.*

- **[Short Summary]**
  - **Location**: Line X-Y / Section name
  - **Description**: [What needs confirmation and why]
  - **Recommended Action**: [Specific questions or options]

### 🟢 提案 (Low Severity)
*List suggestions.*

- **[Short Summary]**
  - **Location**: Line X-Y / Section name
  - **Description**: [How it could be improved]
  - **Recommended Action**: [Concrete suggested text or structure]
```
