# Tasks: analysis-revision

- [x] 1.1. Write MCP tool tests (Red phase)
  - File: tests/test_server.py
  - Purpose: TDD Red phase — write failing tests for `get_review_comments` before implementation
  - Leverage: existing `initialized_review_server` fixture, `_create_in_review_design()` helper, `save_review_batch` tool
  - Requirements: AC-1.1, AC-1.2, AC-1.3, AC-1.4
  - Prompt: Implement the task for spec analysis-revision, first run spec-workflow-guide to get the workflow guide then implement the task: Role: Python test engineer specializing in pytest and MCP server testing | Task: Write 9 tests (Unit-01 through Unit-08 + Integ-01) in tests/test_server.py for the new `get_review_comments` MCP tool, following test-design.md scenarios. Use existing `initialized_review_server` fixture and `_create_in_review_design()` helper. Tests should import `server_module.get_review_comments` and call via `asyncio.run()`. All tests must FAIL (Red) since the tool is not yet implemented. Include: Unit-01 happy path, Unit-02 no reviews, Unit-03 invalid design_id, Unit-04 corrupted YAML, Unit-05 sorted descending, Unit-06 target fields, Unit-07 valid format but nonexistent design_id returns empty (Codex review), Unit-08 service exception returns error dict (Codex review, use unittest.mock.patch on ReviewService.list_review_batches to raise RuntimeError), Integ-01 write-then-read roundtrip. | Restrictions: Do not implement the MCP tool yet. Only write tests. Follow existing test patterns in test_server.py. Place tests after the existing review-related tests. | Success: All 9 tests exist and fail with AttributeError (get_review_comments not found) or similar. No existing tests broken. Mark task as [-] in tasks.md when starting, log with log-implementation when done, mark [x] when complete.

- [x] 1.2. Implement `get_review_comments` MCP tool (Green phase)
  - File: src/insight_blueprint/server.py
  - Purpose: TDD Green phase — implement the MCP tool to make tests pass
  - Leverage: `ReviewService.list_review_batches()`, `_validate_design_id()`, `get_review_service()`, existing `save_review_batch` tool pattern
  - Requirements: FR-1.1, FR-1.2, FR-1.3, FR-1.4, FR-1.5
  - Dependencies: 1.1
  - Prompt: Implement the task for spec analysis-revision, first run spec-workflow-guide to get the workflow guide then implement the task: Role: Python developer specializing in FastMCP server development | Task: Add `get_review_comments(design_id: str) -> dict` MCP tool to server.py. Place it after `save_review_batch` (around line 436). Use existing `_validate_design_id()` for input validation, `get_review_service()` for service access, and `svc.list_review_batches(design_id)` for data retrieval. Return `{design_id, batches: [b.model_dump(mode="json") for b in batches], count: len(batches)}`. Follow the exact pattern of existing tools like `save_review_batch`, including try/except for ValueError and Exception (Codex review: service exception handling). | Restrictions: Do not modify any existing code. Only add the new tool function (~20 lines). Do not add new imports (all needed imports already exist). | Success: All 9 tests from task 1.1 pass. No existing tests broken. `uv run pytest tests/test_server.py -v` all green. Mark task as [-] in tasks.md when starting, log with log-implementation when done, mark [x] when complete.

- [x] 2.1. Create `analysis-revision` skill
  - File: src/insight_blueprint/_skills/analysis-revision/SKILL.md
  - Purpose: Create the revision workflow skill that guides Claude through fixing review comments
  - Leverage: existing skill patterns from `analysis-reflection/SKILL.md`, MCP tools (`get_analysis_design`, `get_review_comments`, `update_analysis_design`, `transition_design_status`)
  - Requirements: FR-2.1, FR-2.2, FR-2.3, FR-2.4, FR-2.5, FR-2.6, FR-2.7, FR-3.1, FR-3.2, FR-3.3, FR-3.4, FR-3.5, FR-3.6, FR-3.7, FR-3.8
  - Dependencies: 1.2
  - Prompt: Implement the task for spec analysis-revision, first run spec-workflow-guide to get the workflow guide then implement the task: Role: Prompt engineer specializing in Claude Code skill design | Task: Create SKILL.md for `analysis-revision` skill at `src/insight_blueprint/_skills/analysis-revision/SKILL.md`. Follow the structure and frontmatter format of `analysis-reflection/SKILL.md`. The skill must: (1) Use `get_analysis_design` to check status == revision_requested, (2) Use `get_review_comments` to get the latest batch where status_after == revision_requested, (3) Read/create tracking file at `.insight/designs/{id}_revision.yaml` with schema from design.md (including fingerprint field), (4) Loop through unaddressed comments showing target_section content alongside each comment, (5) Update tracking file as comments are addressed, (6) Propose `transition_design_status` to in_review when all done. Include MCP Tool Reference table, Chaining table, trigger words (Japanese + English), and Language Rules section. | Restrictions: SKILL.md only, no Python code. Follow existing skill conventions exactly (frontmatter with name, version, description, disable-model-invocation, argument-hint). Tracking file writes must use atomic pattern (Write tool). | Success: SKILL.md follows conventions, covers all REQ-2 and REQ-3 functional requirements, integrates into skill chain. Mark task as [-] in tasks.md when starting, log with log-implementation when done, mark [x] when complete.
