---
description: "Implementation workflow — scouts, plans, waits for approval, then implements"
---

# Task: $@

Use the subagent tool to implement the task.

## Step 1: Scout and Plan

Run this chain:

```
{ chain: [
  { agent: "scout", task: "Thoroughly investigate the codebase for: $@\n\nFind all relevant files, types, functions, dependencies, and tests. Report file paths with line ranges. Trace how the pieces connect. Flag anything surprising or risky that an implementer needs to know." },
  { agent: "planner", task: "Create a detailed implementation plan for: $@\n\nScout context:\n\n{previous}\n\nBe precise: every step must name exact files, functions, and line ranges. Address edge cases and error handling. Specify which steps can run in parallel." },
  { 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. Ask for approval before continuing.**

When presenting, highlight: what will change, which files, risks, and the plan-reviewer verdict.

If the user requests changes to the plan, revise and present again before implementing.

## Step 3: Implement

Once approved:
- Execute the plan steps using the "coder" agent
- When running coder, always wrap the plan step(s) in the task: "Implement the following plan step(s). Do NOT deviate.\n\n<plan>\n{the approved plan steps}\n</plan>"
- Run the "reviewer" agent on all changes
- If NEEDS_FIXES, run the "fixer" agent with the review output

## Step 4: Summary

After the final step, summarize: what was done, what files changed, what was reviewed, and any remaining concerns.

## Important

- **NEVER skip the approval gate**. Always present the plan and wait.
- Always pass scout context forward using {previous} in chain mode — this is how the planner and plan-reviewer receive the scout's findings.
- When running the coder, always include the approved plan verbatim in the task so the coder has full context.

## Agent Failure and Fallback

When a subagent returns empty output or an error (rate limit, credit exhaustion, connection failure):

1. **Retry once** with the same agent and model — transient failures are common.
2. **If still failing, retry with the cross-family fallback model** using the `model` override parameter. See the fallback table in the `subagent-implement` SKILL.md for the current primary/fallback mapping.
3. **If the fallback also fails**, do the work yourself (read the relevant files directly and produce the scout/plan/review output inline). Inform the user which agent failed, what error was returned, and what you did instead.

Do NOT silently absorb failures. Always surface them to the user even when working around them.
