---
description: "Maximum quality pipeline — deep scout, thorough planning, plan review, approval gate, coding, code review"
---

Use the subagent tool to implement with maximum quality. This is for high-risk or architecturally significant changes.

## Step 1: Deep scout + Plan + Plan review
```
{ chain: [
  { agent: "deep-scout", task: "Deep architectural investigation for: $@\n\nTrace all dependency chains, read tests, check types, understand WHY things are structured the way they are. Map subsystems and their boundaries. Your output enables a complex high-risk change." },
  { agent: "planner", task: "Create a detailed implementation plan for: $@\n\nDeep scout context:\n\n{previous}\n\nBe precise: every step must name exact files, functions, and line ranges. Address edge cases and error handling explicitly. Specify which steps can run in parallel. This is a high-risk change — be thorough." },
  { agent: "plan-reviewer", task: "Review this plan critically. Verify all file paths, line numbers, and assumptions against the codebase. Check for missing steps, edge cases, and risks.\n\n{previous}" }
]}
```

## Step 2: APPROVAL GATE

**STOP. Present the plan and the plan-reviewer verdict to the user.**

Show clearly:
- The implementation plan (steps, files, risks)
- Plan-reviewer's verdict (APPROVED / NEEDS_REVISION / REJECTED) and any issues found
- Ask: "Approve this plan, or want changes?"

Do NOT proceed until the user explicitly approves.
If the user requests changes, revise the plan (re-run planner with the feedback) and present again.

## Step 3: Implement (only after approval)
- Use "coder-claude" for the implementation steps
- For each coder run, include the approved plan verbatim: "Implement the following plan step(s). Do NOT deviate.\n\n<plan>\n{the approved plan steps}\n</plan>"
- For multiple independent steps, run them in parallel using separate coder-claude tasks, each assigned to specific files/plan steps to avoid conflicts

## Step 4: Code review
Run the "reviewer" agent on all changes with this task: "Review all changes made for: $@\n\nCheck for correctness, edge cases, error handling, type safety, and consistency with the approved plan."

## Step 5: Fix
If the reviewer says NEEDS_FIXES, run the "fixer" agent with the review output.

## Step 6: Report
Summarize everything: what was planned, what was implemented, what was reviewed, what was fixed, and any remaining concerns.

## Failure handling

- **If any subagent fails, retry it once.** If it fails again, stop and inform the user which agent failed, what the error was, and what had been completed so far. Do NOT continue with remaining steps after a second failure.
