# User Stories Generation Prompt

## Context

You are creating detailed user stories based on the PRD and target market personas.

## Input

- **Product slug:** `{slug}`
- **Read first:**
  1. `agency/products/{slug}/discovery/prd.md`
  2. `agency/products/{slug}/discovery/target-market.md`

## Instructions

1. Read the PRD to understand features and acceptance criteria
2. Read target market for persona details
3. Generate user stories for each P0 and P1 feature
4. Use the actual persona names from target-market.md
5. Include specific acceptance criteria for each story
6. Organize by epic (logical groupings)

## Story Format

Each story follows this format:

```markdown
### US-{XXX}: {Descriptive Title}

**Priority:** P0 | P1 | P2
**Epic:** {Epic Name}
**Points:** {1-13, fibonacci}

**As a** {specific persona name from target-market}
**I want to** {specific action}
**So that** {measurable benefit}

**Acceptance Criteria:**
- [ ] Given {context}, when {action}, then {result}
- [ ] Given {context}, when {action}, then {result}
- [ ] {Additional criterion}

**Notes:**
- {Technical consideration}
- {Design consideration}
- {Edge case to handle}
```

## Output Structure

Write to: `agency/products/{slug}/discovery/user-stories.md`

```markdown
# User Stories: {Product Name}

**Generated from:** PRD v1.0
**Date:** {Today}
**Total Stories:** {Count}

---

## Story Summary

| Priority | Count | Total Points |
|----------|-------|--------------|
| P0 | {X} | {Y} |
| P1 | {X} | {Y} |
| P2 | {X} | {Y} |

---

## Epic 1: {Epic Name}

{Brief description of what this epic covers}

### US-001: {Title}

**Priority:** P0
**Epic:** {Epic Name}
**Points:** 5

**As a** {Persona Name}
**I want to** {action}
**So that** {benefit}

**Acceptance Criteria:**
- [ ] Given I am on the {page}, when I {action}, then I should see {result}
- [ ] Given I have {state}, when I {action}, then {outcome}
- [ ] The system should {technical requirement}
- [ ] Error state: When {error condition}, show {error message}

**Notes:**
- Consider mobile responsiveness
- {Other technical notes}

---

### US-002: {Title}

{... continue ...}

---

## Epic 2: {Epic Name}

{Brief description}

### US-010: {Title}

{... continue ...}

---

## Epic 3: {Epic Name}

{...}

---

## Non-Functional Stories

### US-090: Performance Baseline

**Priority:** P0
**Epic:** Non-Functional

**As a** user
**I want** the app to load quickly
**So that** I don't abandon it

**Acceptance Criteria:**
- [ ] Initial page load < 3 seconds on 3G
- [ ] Time to interactive < 5 seconds
- [ ] Lighthouse performance score > 80

---

### US-091: Accessibility Baseline

**Priority:** P1
**Epic:** Non-Functional

**As a** user with disabilities
**I want** the app to be accessible
**So that** I can use it effectively

**Acceptance Criteria:**
- [ ] WCAG 2.1 Level AA compliance
- [ ] Screen reader compatible
- [ ] Keyboard navigation works

---

## Backlog Grooming Notes

### Questions for Refinement

1. {Question about a story that needs clarification}
2. {Question about scope}

### Dependencies

- US-{X} blocks US-{Y}
- US-{X} requires API from US-{Z}

### Technical Debt to Track

- {Tech debt item to address later}

---

## Appendix: Persona Quick Reference

### {Persona 1 Name}

- **Role:** {Job title}
- **Key pain:** {Main problem}
- **Tech level:** {Low/Medium/High}

### {Persona 2 Name}

- **Role:** {Job title}
- **Key pain:** {Main problem}
- **Tech level:** {Low/Medium/High}
```

## Story Writing Guidelines

### Good vs Bad Stories

**Bad:**
> As a user, I want to login so that I can use the app.

**Good:**
> As a clinic receptionist (Maria), I want to login with my email and password so that I can access today's appointments within 5 seconds of arriving at work.

### Acceptance Criteria Tips

- Use Given/When/Then format
- Include happy path AND error states
- Be specific about expected behavior
- Include performance expectations where relevant

### Pointing Guidelines

| Points | Complexity | Example |
|--------|------------|---------|
| 1 | Trivial | Copy change, config update |
| 2 | Simple | Single UI component |
| 3 | Moderate | Feature with 1-2 API calls |
| 5 | Complex | Multi-step flow |
| 8 | Very Complex | Integration, new system |
| 13 | Epic-sized | Break down further |

## Quality Checklist

Before saving, verify:
- [ ] Every P0 feature from PRD has stories
- [ ] Personas are named (not generic "user")
- [ ] Acceptance criteria are testable
- [ ] Stories are sized appropriately (nothing > 8 points)
- [ ] Edge cases and errors are considered

## After Completion

1. Update progress.md: `[timestamp] ✓ Step 5/5: User stories generated ({X} stories, {Y} points total)`
2. Update workflow.json: `progress: 100, status: "complete"`
3. Log completion: `[timestamp] 🎉 Discovery phase complete!`
