---
name: forge:add-phase
description: Add phase to end of current milestone in roadmap
argument-hint: <description>
allowed-tools:
  - Read
  - Write
  - Bash
---

<objective>
Add a new integer phase to the end of the current milestone in the roadmap.

Routes to the add-phase workflow which handles:
- Phase number calculation (next sequential integer)
- Directory creation with slug generation
- Roadmap structure updates
- State evolution tracking
</objective>

<execution_context>
@state/STATE.json
@ROADMAP.md
@CLAUDE.md
</execution_context>

<context>
**Phase Description:** $ARGUMENTS

**Phase Assignment:**
1. Read ROADMAP.md to find current milestone
2. Calculate next integer phase (ignoring decimals)
3. Generate slug from description
4. Create phase directory structure
5. Add to ROADMAP.md
</context>

<process>
**Execute add-phase workflow:**

1. **Load State**
   - Read state/STATE.json
   - Read ROADMAP.md
   - Identify current milestone

2. **Calculate Phase Number**
   - Find highest integer phase in current milestone
   - Next phase = highest + 1
   - Example: If phases are 70, 71, 71.1, 72 → next is 73

3. **Generate Slug**
   - Create URL-safe slug from description
   - Format: `<phase-number>-<slug>`
   - Example: "Implement auth" → "73-implement-auth"

4. **Create Directory Structure**
   ```bash
   mkdir -p .planning/phases/<phase-slug>/
   touch .planning/phases/<phase-slug>/CONTEXT.md
   touch .planning/phases/<phase-slug>/PLAN.md
   ```

5. **Update ROADMAP.md**
   - Add new phase entry to current milestone
   - Use standard phase format
   - Maintain proper heading hierarchy

6. **Submit Event**
   - Event type: PHASE_ADDED
   - Include: phaseId, milestoneId, description
   - Write to state/events/

7. **Confirm**
   - Show new phase info
   - Suggest next: `/forge:discuss <phase-number>` or `/forge:plan <phase-number>`
</process>

<deliverables>
- .planning/phases/<phase-slug>/CONTEXT.md (empty template)
- .planning/phases/<phase-slug>/PLAN.md (empty template)
- ROADMAP.md updated with new phase
- Event: PHASE_ADDED in state/events/
- STATE.json updated
</deliverables>

<next_steps>
- Run `/forge:discuss <phase-number>` to capture phase context
- Run `/forge:plan <phase-number>` to generate task breakdown
- Tip: Use `/clear` to start from a fresh context
</next_steps>
