---
name: improve-document
description: Automatically improve a document by resolving high-severity issues (問題) in an iterative review-fix loop.
argument-hint: "Relative path of the document to improve"
---

Iteratively review and improve a target document by identifying and fixing high-severity issues (**問題**) using the `review-document` skill.

## 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, prompt the user to specify the file path.

2.  **Locate or Run Initial Review**:

    -   Look for an existing review report at `.review/[relative-path-to-target-document]` relative to the project root (e.g., if target is `docs/AGENTS.md`, look for `.review/docs/AGENTS.md`).
    -   If the file exists, read its contents.
    -   If it does not exist (or is empty), invoke the [review-document](../review-document/SKILL.md) skill to generate a new report.

3.  **Parse and Resolve Loop (Maximum 3 Iterations)**:

    -   For up to 3 times, perform the following:
        -   Read the latest review report file and parse findings under the **🔴 問題 (High Severity)** section.
        -   If there are **no findings** listed under **🔴 問題** (or the count is `0`):
        -   Break the loop. All high-severity issues have been successfully resolved.
        -   If **🔴 問題** findings are present:
        -   For each issue, analyze the location, original text, and recommended action.
        -   Apply surgical, precise edits to the target document to correct the issue. Avoid modifying unrelated sections.
        -   Save the updated target document.
        -   Run the [review-document](../review-document/SKILL.md) skill on the target document to overwrite the review report file with an updated analysis.
        -   Reload and parse the updated review report.

4.  **Final Summary**:

    -   If the loop exits:
        -   Summarize which high-severity issues were resolved in each iteration.
        -   Note if any issues remain unresolved after 3 iterations.
        -   Provide the path/link to the updated document and the updated review report.
