---
description: Plan with task creation then implement with validation
agent: plan
---

# Plan and Build: $ARGUMENTS

## Step 1: Create Task Structure

Create three mandatory files in new @backlog/tasks/[task-id]/:

**prd.md** - Fill in:

- Goal: What are we building?
- Scope (In/Out): What's included/excluded?
- Success Criteria: [x] Measurable checkboxes
- Assumptions: What are we assuming?

**spec.md** - Fill in:

- Architecture: High-level design
- Constraints: Rules to follow
- Edge Cases: Corner cases to handle
- Testing: How to verify success criteria

**review.md** - Template for later (filled after work)

## Step 2: Complexity Assessment

Analyze the task and answer these questions:

**Scope Questions:**

- How many files will be modified? (Count)
- How many languages/frameworks involved? (Count)
- Are there breaking changes? (Yes/No)

**Risk Questions:**

- Security implications? (High/Medium/Low)
- New external dependencies? (Yes/No)
- Database schema changes? (Yes/No)
- Will it affect other systems? (Yes/No)

**Complexity Questions:**

- How many phases needed? (1-2 = simple, 3 = moderate, 4+ = complex)
- Can one person do it? (Yes/No)
- What's the rollback procedure? (Describe)

## Step 3: Create Detailed Plan

Based on assessment, fill PRD and spec with:

**PRD Sections:**

- Goal: 1-2 sentences (measurable, not vague)
- Scope: Explicit "In-Scope" and "Out-of-Scope" lists
- Success Criteria: Checkboxes like:
  - [ ] Feature X works with Y
  - [ ] No performance regression > 5%
  - [ ] Tests pass with 80%+ coverage

**Spec Sections:**

- Architecture: Phase breakdown (if ≥2 phases)
- Constraints: Explicit rules (naming, patterns, libraries allowed)
- Edge Cases: Numbered list of corner cases
- Testing: Specific test cases per success criterion
- Notes: Any non-obvious implementation details

## Step 4: Present Plan for Approval

Display the filled task files and present:

```
PLAN READY FOR REVIEW

Task: [task-id]
Goal: [PRD goal]
Files Modified: [Count from plan]
Risk Level: [High/Medium/Low]
Complexity: [Phases needed]

PRD Success Criteria:
- [List checkboxes from prd.md]

Next Step Options:
1. "approved" → Proceed with implementation
2. "revise [feedback]" → Update plan/templates
3. "cancel" → Stop here
```

**WAIT FOR USER RESPONSE - DO NOT PROCEED WITHOUT EXPLICIT APPROVAL**

## Step 5: Implement After Approval

Once user says "approved", invoke build agent with:

```
Implement task [task-id] using approved plan

MANDATORY:
1. Read [task-id]/prd.md and spec.md first
2. Execute implementation by phases (if multi-phase)
3. Continuously validate against spec constraints
4. Stop and report any constraint violation
5. Complete review.md after all work done
6. Mark all completed success criteria [x]
7. Run /complete-task to validate
```

## Step 6: Quality Checkpoint

After build completes, verify:

**Review.md Complete?**

- [ ] "What Changed" section filled with file list
- [ ] "What Skipped" section filled (even if just "none")
- [ ] "Inconsistencies" section filled (even if just "none")
- [ ] "Validation" section shows success criteria checked

**Success Criteria Met?**

- [ ] All applicable PRD criteria are [x] marked

**No Outstanding Changes?**

- [ ] All code changes committed OR staged with explanation

---

**ANTI-HALLUCINATION: Planning requires full task structure. Implementation requires approval. Completion requires full review.**
