---
description: Create execution plan from research findings
agent: plan
---

# Plan: $ARGUMENTS

You are transforming research findings into a brutal, actionable execution plan.

## Phase 1: Load Research Context

**Find and read the research:**

1. **Locate research file:**

   ```bash
   find .opencode/memory/research/ -type f -name "*.md" | head -5
   ```

2. **Identify the most relevant research file for "$ARGUMENTS"**
   - Match by topic/date
   - If multiple files exist, ask user which one to use
   - If no research exists, ask: "No research found. Run `/research $ARGUMENTS` first?"

3. **Extract key findings:**
   - Question answered
   - Key findings (2-5 bullet points)
   - Decision/recommendation
   - References and sources

## Phase 2: Create Execution Plan

Use research findings to answer these planning questions:

**Complexity Assessment:**

- How many phases required? (≥3 = complex, ≤2 = simple)
- Security implications? (High/Medium/Low)
- Cross-platform considerations? (macOS, Linux, Windows?)
- Dependencies? (New packages, APIs, external services?)

**Phase Breakdown:**
For each phase, specify:

- **Phase Name & Description** (what problem does it solve?)
- **Agent Assignment** (@build, @researcher, @code-auditor, or parallel agents)
- **Inputs** (what deliverables from previous phase?)
- **Deliverables** (what does this phase produce?)
- **Validation** (how to verify phase is complete?)
- **Risks** (what can go wrong? rollback plan?)

**Example Structure:**

```
Phase 1: Setup & Discovery
- Agent: @researcher
- Deliverables: Architecture decision document
- Validation: Team alignment on approach

Phase 2: Implementation
- Agent: @build
- Deliverables: Working code + tests
- Validation: All tests passing, code review approved

Phase 3: Verification
- Agent: @code-auditor
- Deliverables: Security report, test coverage report
- Validation: No critical/high security issues
```

## Phase 3: Brutal Clarity Check

Challenge yourself on each phase:

- ❌ **Vague goals?** → Add measurable acceptance criteria
- ❌ **Too long?** → Break into smaller phases with checkpoints
- ❌ **Missing dependencies?** → Add "Requires Phase X" calls
- ❌ **No rollback plan?** → Add recovery procedures
- ❌ **Agent unclear?** → Specify exactly which agent, why them
- ❌ **Success undefined?** → Add specific validation tests

## Phase 4: Present Plan

Output the complete plan in this markdown format:

````markdown
# Execution Plan: [Topic]

**Based on Research:** [File location]  
**Complexity Level:** Simple/Medium/Complex  
**Total Duration:** [Estimated time]  
**Security Risk:** High/Medium/Low

## Phase Overview

[1-2 sentence summary of what we're building]

## Phase Breakdown

### Phase 1: [Name]

**Goal:** [One sentence outcome]  
**Agent:** @[agent-name]  
**Dependencies:** [Phase X, API keys, etc.]  
**Deliverables:**

- [ ] Deliverable 1
- [ ] Deliverable 2

**Validation:**

```bash
Test command here
```
````

**Risks & Rollback:**

- Risk: [Description]
  - Rollback: [Recovery procedure]

### Phase 2: [Name]

...

## Success Criteria

- [ ] All phases completed
- [ ] All validation tests passing
- [ ] Code review approved by @code-auditor
- [ ] Documentation updated
- [ ] Ready for deployment/release

```

## Phase 5: Approval Gate

**STOP here and present the plan to the user.**

Ask explicitly:

```

📋 Execution Plan Complete

Review the plan above. To proceed with implementation:

- "approved" → I'll implement with agents
- "revise [feedback]" → I'll update the plan
- "show research" → I'll show research findings again
- "cancel" → Stop here

```

**DO NOT PROCEED WITHOUT EXPLICIT APPROVAL.**

## Phase 6: Invoke Build (After Approval)

Once user replies "approved", invoke @plan agent:

```

session({
mode: "new",
agent: "plan",
text: "Implement this approved plan step-by-step:\n\n[Full plan text]\n\nFollow these rules:\n1. Execute phases sequentially\n2. Verify each phase before proceeding\n3. If stuck, ask for help\n4. Use @build agent for implementation\n5. Use @code-auditor for review gates"
})

```

## Execution Rules

**This Command (@plan):**
- ✅ Read and synthesize research
- ✅ Create detailed execution plan
- ✅ Challenge vague goals (brutal clarity)
- ✅ Present plan for approval
- ✅ Stop before implementation

**After Approval:**
- ✅ Invoke @plan agent to delegate to @build
- ✅ Track progress in backlog task notes
- ✅ Handle approval gates and checkpoints

## Output Checklist

Before presenting plan, verify:

- ✅ Research findings clearly summarized
- ✅ All phases have agents assigned
- ✅ Success criteria are measurable (not vague)
- ✅ Risks and rollback plans included
- ✅ Dependencies between phases clear
- ✅ Estimated timeline included
- ✅ Cross-platform considerations noted
- ✅ Approval gate is explicit

Plan hard. Present brutally clear. Get approval. Execute.
```
