---
name: review-testspec
description: Review the TEST_SPEC.md document's contents using a structured 3-tier severity checklist.
argument-hint: "Relative path of the test spec document to review (default: docs/TEST_SPEC.md)"
---

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

## Review Checklist

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

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

*   **構成要素の不足 (Missing Core Sections)**: Check if required sections are present: "すべての機能、画面ごとの機能を検証するテストケース".
*   **仕様との乖離・検証漏れ (Gaps compared to SPEC.md)**: Features, components, or screens listed in `docs/SPEC.md` that lack corresponding test scenarios or assertions.
*   **テストケースの論理的破綻 (Logic Flaws in Tests)**: Contradictory steps in verification flows or unreachable states defined as test assertions.
*   **正常系・異常系の抜け漏れ (Missing Happy/Error Paths)**: Only covering happy paths (正常系) while failing to define test cases for boundary cases, validation errors, network failures, or invalid inputs (異常系/限界値テスト).

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

*Items that require clarification or validation.*

*   **テストデータ・モックの前提条件 (Test Data Assumptions)**: Implicit dependencies on specific database seeds, external APIs, or environment variables that are not explicitly documented.
*   **テスト環境の実行要件 (Execution Prerequisites)**: Whether testing requires browser environments, specific devices, or local emulation servers.

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

*Constructive ideas to improve clarity, aesthetics, or user experience.*

*   **テストケースの表形式化 (Test Table Format)**: Suggest formatting test cases with clear fields (e.g. ID, Preconditions, Steps, Expected Result, Status) for easy checklist compilation.
*   **自動テスト対象の特定 (Automation Recommendations)**: Flagging scenarios that are well-suited for automated Unit/Integration/E2E testing versus manual verification.

---

## Execution Flow

1. **Locate Target File**:
   *   If a file path is provided as an argument, use it as the target.
   *   If no argument is provided, default to `docs/TEST_SPEC.md`.
2. **Read Content**:
   *   Read the file content.
3. **Conduct Review**:
   *   Analyze the document line-by-line or section-by-section against the checklist.
4. **Save Report to File**:
   *   Save the formatted review report to `.review/[relative-path-to-target-document]` relative to the project root (e.g., `.review/docs/TEST_SPEC.md`).
   *   Ensure the directories inside `.review/` are created automatically if they do not exist.
   *   If the report file already exists, overwrite it with the new review content.
5. **Output Report**:
   *   Present the structured review report in the chat and notify the user of the path to the saved file.

---

## Output Report Format

Output the review report using the following structure:

```markdown
# Document Review Report: [file basename]

Review of: `[relative/path/to/file]`

## Executive Summary

| Severity | Count | Key Focus |
| --- | --- | --- |
| 🔴 問題 (High) | 0 | Critical issues requiring immediate correction |
| 🟡 要確認 (Medium) | 0 | Items requiring user confirmation or alignment |
| 🟢 提案 (Low) | 0 | Suggestions for readability and quality |

---

## Detailed Findings

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

- **[Short Summary of Issue]**
  - **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
  - **Original Text**: `[original text]`
  - **Description**: [What needs confirmation and why]
  - **Recommended Action**: [Specific clarification questions or options]

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

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