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

Read and review the contents of the target 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: "機能一覧", "コンポーネント一覧", "機能ごとの入力・出力", "画面一覧", and "画面固有の仕様 (including ViewModel/Service specifications)".
*   **上位要件・設計との不整合 (Mismatch with Higher Docs)**: Functional gaps compared to `docs/REQUIREMENTS.md` or architectural mismatches with `docs/ARCHITECTURE.md` or `docs/DESIGN.md`.
*   **入出力仕様の致命的な曖昧さ (Ambiguous I/O)**: Functional details where inputs, processing logic, or outputs are not explicitly defined, preventing implementation or test case writing.
*   **画面IDルールの違反 (Screen ID Violation)**: Screens that do not have a unique screen ID (maximum 24 characters) or do not follow repository patterns.

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

*Items that require clarification or validation.*

*   **バリデーションとエラーハンドリング詳細 (Validation Details)**: Vague boundaries for form field validation, maximum/minimum characters, or custom logic in screen specifications.
*   **外部連携・API依存関係の確認 (API Dependencies)**: Unstated dependencies on third-party APIs or common business logic services (`docs/services/*.md`) in the component interactions.

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

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

*   **UI/UXモックアップ・レイアウト図 (Layout Diagrams)**: Suggest using Mermaid markdown layout maps or basic ASCII drawings to clarify screen designs.
*   **ユースケース一覧の表形式整理 (Usecase Tables)**: Formatting screen actions, event triggers, and state changes into tables.

---

## 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/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/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]
```
