---
name: step-02-analyse
description: Analysis phase - BRD formalization with business rules
model: sonnet
prev_step: steps/step-01-discover.md
next_step: steps/step-03-specify.md
---

<objective>
Transform discovery findings into a formal Business Requirements Document (BRD).
Identify and formalize all business rules with BR-XXX identifiers.
</objective>

<ultrathink>
ULTRATHINK MODE - Business Rule Formalization:
- Extract IMPLICIT rules from discovery responses
- Challenge completeness of each rule
- Verify no rule contradicts another
- Ensure rules are testable
</ultrathink>

## EXECUTION SEQUENCE

### 1. Read Current State

Read `{output_dir}/00-context.md` to restore state variables.
Read `{output_dir}/1-discovery.md` for discovery findings.

Update progress: `02-analyse` -> "In Progress"

---

### 2. Load BRD Template

```
Read: templates/frd-brd.md    # ~90 lines only (vs 477 lines full template)
```

This template contains ONLY the BRD structure, not FRD or Handoff.

---

### 3. Extract Business Objectives

From discovery section 1 (Contexte Business), formalize:

| ID | Objective | Metric | Target |
|----|----------|----------|-------|
| OBJ-001 | {objective} | {measurable KPI} | {target value} |
| OBJ-002 | ... | ... | ... |

**ULTRATHINK checkpoint:**
- Each objective is measurable?
- Target values are realistic?
- Objectives align with stakeholder needs?

---

### 4. Identify Business Rules

Scan discovery document for implicit and explicit rules:

**Sources to analyze:**
- Scope section (constraints)
- Stakeholder needs (role-specific rules)
- Data requirements (validation rules)
- Process flows (workflow rules)

**Rule categories:**
| Category | Example | BR-ID pattern |
|----------|---------|---------------|
| Validation | "Email must be unique" | BR-VAL-XXX |
| Calculation | "Total = sum of lines" | BR-CALC-XXX |
| Workflow | "Manager must approve > 1000$" | BR-WF-XXX |
| Security | "Only admin can delete" | BR-SEC-XXX |
| Data | "Created date is immutable" | BR-DATA-XXX |

---

### 5. Formalize Each Business Rule

For each identified rule, create detailed specification:

```markdown
#### BR-XXX: {Rule Name}

**Statement:** {Clear, unambiguous statement}

**Conditions:**
- IF {condition A}
- AND {condition B}
- THEN {result}
- ELSE {alternative result}

**Examples:**
| Input | Expected Output |
|-------|-----------------|
| {example input 1} | {expected output 1} |
| {example input 2} | {expected output 2} |

**Testability:** {How to verify this rule}
```

---

### 6. Model Business Process

Create process diagram for main flow:

```
┌─────────────┐     ┌─────────────┐     ┌─────────────┐
│   Step 1    │────►│   Step 2    │────►│   Step 3    │
│  {action}   │     │  {action}   │     │  {action}   │
└─────────────┘     └─────────────┘     └─────────────┘
      │                   │                   │
      ▼                   ▼                   ▼
   {actor}            {actor}            {actor}
```

Identify:
- Entry points
- Decision points (apply BR-WF rules)
- Exit points
- Alternative flows

---

### 7. Define Data Entities (Business View)

**IMPORTANT: Business attributes only - NO technical types!**

| Entity | Description | Cardinality |
|--------|-------------|-------------|
| {Entity} | {business description} | 1:N with {other} |

| Entity | Attribute | Description | Required |
|--------|-----------|-------------|----------|
| {Entity} | {attribute} | {business meaning} | Yes/No |

**ULTRATHINK checkpoint:**
- All entities from discovery captured?
- Relationships are complete?
- No orphan entities?

---

### 8. Identify Integrations

| System | Direction | Data | Frequency |
|--------|-----------|------|-----------|
| {system} | In/Out/Bi | {data} | Real-time/Batch |

For each integration, note:
- Data format expected
- Error handling strategy
- Fallback behavior

---

### 9. Compile BRD Document

Assemble using `templates/frd-brd.md` structure:

```markdown
# BRD - {feature_id} {feature_description}

> **Module:** business/{application_name}/{module_name}
> **Version:** 1.0
> **Based on:** 1-discovery.md v1.0

## 1. Executive Summary
{3-5 sentence synthesis}

## 2. Business Objectives
{OBJ table}

## 3. Business Rules
{BR summary table}

### 3.1 Critical Rules Detail
{BR-XXX detailed specs}

## 4. Business Process
{Process diagrams}

## 5. Business Data
{Entity tables - business view}

## 6. Integrations
{Integration table}

---

## Version History

| Version | Date | Author | Changes |
|---------|------|--------|---------|
| 1.0 | {date} | BA | Initial creation |
```

---

### 10. Save Output

Write to: `{output_dir}/2-business-requirements.md`

Update `00-context.md`:
- Progress: `02-analyse` -> "Complete"
- Add BR count to state

---

### 11. Display Summary and Load Next Step

**Display:**
```
ANALYSE - {feature_id}
├── Status: Complete
├── Objectives: {OBJ count}
├── Business Rules: {BR count}
├── Entities: {entity count}
├── Integrations: {integration count}
├── Output: {output_dir}/2-business-requirements.md
└── Next: step-03-specify (FRD + Use Cases)
```

**If NOT auto_mode:**
Ask: "Proceed with functional specification?"

**Load next step:**
```
Read and execute: steps/step-03-specify.md
```

---

## OUTPUT

This step produces:
- `{output_dir}/2-business-requirements.md` (created)
- `{output_dir}/00-context.md` (updated)

Template loaded: **~90 lines** (vs 477 lines full file)
