---
name: business-analyse
description: "Iterative multi-module business analysis with progressive context loading, JSON-first architecture, and interactive HTML deliverables."
model: opus
user_invocable: true
---

# /business-analyse — v2

## Architecture

**2 phases, 7 steps** — "Macro vers Specification"

### Phase 1 — Macro (Identification + Challenge)

| Step | File | Model | Role |
|------|------|-------|------|
| 00 | `step-00-init.md` | Sonnet | Detection new/update, scan existing, create index.json structure |
| 01 | `step-01-cadrage.md` | Opus | Context, stakeholders, scope, risks. ~40 core questions |
| 02 | `step-02-structure.md` | Opus | Identify App > Module > Section > Resource hierarchy, CHALLENGE each element |

### Phase 2 — Specification (Deep dive + Client enrichment)

| Step | File | Model | Role |
|------|------|-------|------|
| 03 | `step-03-specify.md` | Opus | Deep dive per module: entities, BRs, UCs, permissions, screens. Sequential internal loop |
| 04 | `step-04-consolidate.md` | Opus | Cross-module validation: data model, permission coherence, E2E flows |
| 05 | `step-05-deploy.md` | Sonnet | Deploy interactive HTML document |
| 06 | `step-06-review.md` | Opus | Apply client corrections from ba-review.json exported from HTML |

### IA + Client Loop
```
Phase 1 (steps 00-02) → Phase 2 (steps 03-05) → Client reviews HTML
                                                       ↓
                                          Client comments/enriches
                                                       ↓
                                          Export ba-review.json
                                                       ↓
                                          Step 06 → re-deploy HTML
                                                       ↓
                                          /derive-prd → /ralph-loop
```

> **PRD generation:** Handoff data and PRD files are generated by the `/derive-prd` skill, not by step-05.

## JSON Architecture — Granular files + Index

Each module is split into thematic JSON files with an `index.json` that references them:

```
docs/{app}/{module}/business-analyse/v1.0/
  index.json              ← Index with metadata + file references
  cadrage.json            ← Context, stakeholders, scope, risks (if app-level)
  entities.json           ← Entities, attributes, relations
  rules.json              ← Business rules (BRs)
  usecases.json           ← Use cases (UCs)
  permissions.json        ← Permissions, roles, access matrix
  screens.json            ← Interface specs (sections, resources, mockups)
  validation.json         ← Validation results, checks
  handoff.json            ← File mapping, APIs, handoff data
```

### File hierarchy

```
docs/
  business-analyse/v1.0/
    index.json                    ← Project index (multi-app)
    cadrage.json                  ← Project-level framing
  {app}/
    business-analyse/v1.0/
      index.json                  ← Application index
      cadrage.json                ← Application framing
    {module}/
      business-analyse/v1.0/
        index.json                ← Module index
        entities.json, rules.json, usecases.json, ...
  ba-interactive.html             ← Single unified HTML
```

### Partial loading

Each step loads only the files it needs via `index.json`:
- Step 03 (specify): loads `index.json` + `entities.json` for current module only
- Step 04 (consolidate): loads all `index.json` files for summary counts
- Step 05 (deploy): assembles all files into unified FEATURE_DATA for HTML

## Workflow Modes

| Mode | Condition | Behavior |
|------|-----------|----------|
| `new` | No existing index.json | Full analysis from step 00 |
| `update` | Existing index.json found | Delta analysis, skip completed sections |
| `review` | ba-review.json provided | Apply corrections (step 06 only) |

## Context Loading Rules

Each step loads ONLY what it needs:

| Step | Always loaded | Conditionally loaded |
|------|---------------|---------------------|
| 00 | `_shared.md` | — |
| 01 | `_shared.md`, `step-01-cadrage.md` | questionnaires |
| 02 | `_shared.md`, `step-02-structure.md` | cadrage.json from step 01 |
| 03 | `_shared.md`, `step-03-specify.md` | current module's index.json + relevant files |
| 04 | `_shared.md`, `step-04-consolidate.md` | all module index.json files |
| 05 | `_shared.md`, `step-05-deploy.md` | all JSON files for HTML assembly |
| 06 | `_shared.md`, `step-06-review.md` | ba-review.json + current feature files |

## Agents

| Agent | Role | Operations |
|-------|------|------------|
| `ba-writer` | Write granular JSON files | create, enrichSection, updateIndex, createVersion, applyReview |
| `ba-reader` | Read via index.json | findFeature, readSection, getModuleStatus, getSummaryForSkill |

## HTML Output

**Single unified HTML** document (`ba-interactive.html`) with:
- Multi-app navigation (4 levels: App > Module > Section > Resource)
- Inline editing (UC, BR, entities, sections/resources)
- HTML mockups from `screens[]` specs (SmartTable, SmartForm, SmartCard, SmartKanban, SmartDashboard)
- Wireframe fallback from EMBEDDED_ARTIFACTS
- Comment system with review panel
- Export: ba-review.json for step 06 loop

### FEATURE_DATA structure

```javascript
{
  metadata: { projectName, version, ... },
  applications: [{ code, name, icon, route, modules: [...] }],
  cadrage: { context, scope, stakeholders, risks, criteria },
  modules: [{ code, applicationCode, name, ... }],
  moduleSpecs: { [code]: { useCases, businessRules, entities, permissions, screens, sections, resources } },
  consolidation: { interactions, e2eFlows },
  comments: []
}
```

## Step Execution

```
STEP 00 (init)
  → Load: _shared.md
  → Execute: step-00-init.md
  → Output: index.json structure, workflow mode detected

STEP 01 (cadrage)
  → Load: _shared.md, step-01-cadrage.md, questionnaires
  → Execute: Interactive Q&A with client (~40 questions)
  → Output: cadrage.json (context, stakeholders, scope, risks, criteria)

STEP 02 (structure)
  → Load: _shared.md, step-02-structure.md, cadrage.json
  → Execute: Identify App > Module > Section > Resource hierarchy
  → Challenge: Question each element's necessity
  → Output: modules[], applications[], anticipatedSections per module

STEP 03 (specify) — SEQUENTIAL MODULE LOOP
  → For each module (in dependency order):
    → Load: _shared.md, step-03-specify.md, module index.json
    → Execute: entities, BRs, UCs, permissions, screens
    → Output: entities.json, rules.json, usecases.json, permissions.json, screens.json
  → No team mode — sequential ensures 100% context per module

STEP 04 (consolidate)
  → Load: _shared.md, step-04-consolidate.md, all index.json
  → Execute: Data model validation, permission coherence, E2E flows
  → Output: validation.json, consolidated data

STEP 05 (deploy)
  → Load: _shared.md, step-05-deploy.md, all JSON files
  → Execute: Assemble FEATURE_DATA, generate HTML
  → Output: ba-interactive.html (single file)

STEP 06 (review) — CLIENT LOOP ENTRY
  → Load: _shared.md, step-06-review.md, ba-review.json
  → Execute: Apply corrections, create new version
  → Output: Updated JSON files, regenerated HTML
```

## References

| File | Content |
|------|---------|
| `references/html-data-mapping.md` | FEATURE_DATA mapping for HTML generation |
| `references/naming-conventions.md` | SmartStack naming rules |
| `references/wireframe-svg-style-guide.md` | SVG wireframe rendering guide |
| `references/validation-checklist.md` | Validation criteria checklist |
| `references/deploy-modes.md` | Deployment configuration |
| `references/acceptance-criteria.md` | Acceptance criteria patterns |

> **Cross-reference:** Handoff data, PRD generation, file templates, and BR-to-code mappings are in the `/derive-prd` skill.

## Questionnaires

| File | Questions | Focus |
|------|-----------|-------|
| `questionnaire/01-context.md` | 3 | Business process, friction points, vision |
| `questionnaire/02-stakeholders-scope.md` | 10 | User profiles, access levels, scope boundaries |
| `questionnaire/03-data-ui.md` | ~15 | Data entities, UI expectations, dashboards |
| `questionnaire/04-risks-metrics.md` | — | NOT USED (risks/metrics out of BA scope) |
| `questionnaire/05-cross-module.md` | ~8 | Cross-module dependencies, integration impact |

## Entry Point

**FIRST ACTION:** Load `steps/step-00-init.md`
