---
name: ai-workflow
description: Guides a developer through the complete AI-assisted development workflow for any task — feature, bug fix, or refactor. Walks through intent capture, requirements, PRD creation, phased planning, guardrails, TDD cycle, and PRD updates. Invokes the team's individual skills in sequence. Run this at the start of every task.
---

You are guiding me through our team's AI development workflow. Walk me through each step below **in sequence**, waiting for my input at each stage before moving to the next. Do not skip steps. Reference the relevant skill file at each step so I know where the detail lives.

---

## Step 1 — Intent & Context
*Skill: 01-intent-context.mdc*

Ask me these questions one at a time:
1. What is this task? (new feature / bug fix / refactor / investigation)
2. What is the goal in one sentence — what does "done" look like?
3. Who or what is affected? (users, systems, other teams)
4. What existing code, files, or context is most relevant?
5. Are there any hard constraints? (deadline, performance, security, compatibility)

Once I've answered, write a concise **Intent Statement** — one paragraph that captures the task, goal, affected area, and success condition. Show it to me and confirm before moving on.

---

## Step 2 — Requirements Brain Dump
*Skill: 01-intent-context.mdc*

Ask me to brain-dump everything I know. Tell me: "Don't structure it yet — just get it all out."

Prompt me with:
- What MUST this do? (required behaviours)
- What must it NOT do? (explicit non-goals)
- What edge cases worry you?
- What are the unknowns or open questions?
- What could go wrong?

Capture my answers raw and unstructured. When I'm done, confirm and move on.

---

## Step 3 — Create the PRD
*Skill: 06-documentation-prds.mdc*

Using my intent statement and brain dump, create a PRD at:
```
docs/[feature-name]/PRD_[FEATURE_NAME].md
```

Use the team template at `templates/TEMPLATE_TECHNICAL_PRD.md`. At this stage, populate:
- **Overview** — from the intent statement
- **Business Requirements** — structured from the brain dump
- **Implementation Phases** — start all phases as ⏳ PLANNED (leave tasks TBD for now)
- **Success Criteria** — from requirements and intent
- **Current Status** — PLANNED

Leave Technical Requirements (schema, API, UI) stubbed — they get filled in during implementation as decisions are made.

Tell me the PRD file path when done.

---

## Step 4 — Phased Plan
*Skill: 02-planning.mdc*

Review the PRD together. Define 2–4 phases. Each phase must:
- Have a single clear objective
- Contain 3–5 concrete, outcome-focused tasks
- Be independently testable
- Represent roughly one PR or one focused work session

Update the Implementation Phases section in the PRD with the agreed phases and tasks. All statuses remain ⏳ PLANNED.

Show me the phases and confirm before proceeding.

> **Optional:** If the plan feels uncertain or there are open design questions, run `/grill-me` now to stress-test it before locking in. See `04-grill-me.md`.

---

## Step 5 — Guardrails Check
*Skill: 03-rules-guardrails.mdc*

Before writing any code, confirm each item:

- [ ] PRD is created at `docs/[feature-name]/PRD_[FEATURE_NAME].md`
- [ ] Relevant `.mdc` rules are loaded for this project
- [ ] The coding conventions for this codebase are understood
- [ ] Test file will be created BEFORE implementation (TDD)
- [ ] Success criteria in the PRD are testable

If anything is missing, address it now. Do not proceed to Step 6 until all items are confirmed.

---

## Step 6 — TDD Cycle (repeat per task)
*Skills: 07-tdd-development-workflow.mdc, 05-unit-testing.mdc*

For each task in the current phase, follow this cycle:

1. **Write the test first** — describe the expected behaviour before any implementation
2. **Run it — confirm it FAILS** (RED). If it passes, the test is wrong.
3. **Implement minimum code** to make the test pass. No extras.
4. **Run it — confirm it PASSES** (GREEN).
5. **Refactor if needed** — clean up while tests still pass.
6. **Update the PRD** — mark task complete, add code references (`filepath:line-number`), add implementation notes.

Repeat for every task in the phase. Only move to the next phase when all tasks have passing tests and the PRD is updated.

---

## Step 7 — Phase Completion & PRD Update
*Skill: 06-documentation-prds.mdc*

After all tasks in a phase are complete:

1. Mark phase status: ✅ COMPLETED
2. Add key implementation notes to the Technical Implementation Details section
3. Add code references for significant decisions
4. Mark relevant Success Criteria checkboxes as done
5. Update Current Status: phase name, overall status, next steps

The PRD is the living record of this work. It must stay current.

---

## Step 8 — Continue or Close

- **More phases remain?** → Return to Step 6 for the next phase
- **All phases complete?** → Do a final PRD review. Confirm all Success Criteria are met. Mark the document ✅ COMPLETED.

---

## Quick Reference

| Step | Principle | Skill |
|------|-----------|-------|
| 1–2 | Clear intent; brain-dump requirements | `01-intent-context.mdc` |
| 3 | Continuous documentation — PRD first | `06-documentation-prds.mdc` |
| 4 | Outcome-focused phased planning | `02-planning.mdc` |
| 4 (optional) | Stress-test the plan before committing | `04-grill-me.md` |
| 5 | Rules and guardrails before code | `03-rules-guardrails.mdc` |
| 6 | TDD — test first, implement, update PRD | `07-tdd-development-workflow.mdc`, `05-unit-testing.mdc` |
| 7 | Living PRD — updated after every task | `06-documentation-prds.mdc` |
