# Feature Development Workflow

> See the full workflow at [AIFLOW.md](../../AIFLOW.md)
> **Gates must pass in order: 1 → 2 → 3 → 4 → 5**

---

## Step 1: Load ticket & AI analyzes (Gate 1)

```bash
aiflow use PROJ-33                    # from Backlog/Jira
claude                                # AI auto-starts Gate 1
```

AI will **automatically**:
1. Load ticket info from Backlog/Jira
2. Read source code — understand architecture, related files, patterns
3. Ask clarifying questions if anything is unclear (one at a time)
4. Output `AK-Docs/04.Coding/01.Requirements/[functionId]/[ticketId].md` containing:
   - Requirements summary (AI's understanding)
   - Source code analysis (related files, data flow)
   - **Proposed solution** with options and recommendation
   - **Impact analysis** — affected areas, risks
   - **Effort estimate** (S/M/L/XL)
   - Testing plan

**PM needs to prepare on the ticket:**
```markdown
## Description
Clear business requirement. Who uses it, and for what purpose.

## Acceptance Criteria
- [ ] [Condition for completion 1]
- [ ] [Condition for completion 2]

## Mockup / Wireframe
[Link or UI description]

## Context
Constraints, business rules specially requiring attention.
```

**If ticket content is unclear:** AI will ask questions based on source code analysis — not just checking format.

**When satisfied with the requirement document, type:**
```
APPROVED
```

---

## Step 2: Review Implementation Plan (Gate 2)

AI generates a detailed implementation plan:
- TDD task breakdown (test first → implement → verify)
- Commit strategy (small, focused commits)
- Test commands

**When agreed, type:**
```
APPROVED
```

**CODE WILL NOT BE GENERATED BEFORE RECEIVING "APPROVED".**

---

## Step 3: AI Generate Code (Gate 3)

AI performs automatically:
1. Complex feature (3+ files): `superpowers:subagent-driven-development`
2. Write tests FIRST → run → confirm FAIL
3. Implement → tests PASS
4. Commit each small step

Developer doesn't need to do anything at this step — just monitor.

---

## Step 4: Review Summary (Gate 4)

AI runs:
1. `superpowers:verification-before-completion` — all tests PASS
2. `impact-analysis` — no breaking changes outside of scope
3. Review checklist — all items ticked
4. Create `AK-Docs/04.Coding/04.Reviews/[functionId]/[ticketId].md`

AI displays summary and waits for developer review.

**If OK, type:**
```
APPROVED
```

**If there are bugs, type:**
```
BUG: [specific description]
```
- Coding bug → AI fixes → repeat Gate 4
- Requirement bug → AI returns to Gate 1, update requirement doc

---

## Step 5: Peer Review & PR (Gate 5)

AI invokes `superpowers:requesting-code-review` and guides PR creation.

```bash
git push origin feature/PROJ-33-feature-name
# Create PR with full description following the template in AIFLOW.md
```

Peer reviewer uses the `superpowers:receiving-code-review` skill during review.

---

## Completion Checklist

- [ ] Gate 1 APPROVED — requirement doc with solution, impact, estimate
- [ ] Gate 2 APPROVED — implementation plan confirmed by developer
- [ ] Gate 3 done — code + tests are green
- [ ] Gate 4 APPROVED — summary + checklist complete
- [ ] Gate 5 done — PR is peer-reviewed and merged
