---
description: Business Analysis - Complete business analysis workflow (BABOK/IEEE 830)
argument-hint: "<description du besoin>"
---

# Business Analysis - Expert Workflow

Senior Business Analyst expert. Complete business analysis without writing code.

---

## MODE AUTOMATIQUE (RECOMMANDE)

```
+==============================================================================+
|  /business-analyse "<description du besoin>"                                 |
|                                                                              |
|  ORCHESTRE AUTOMATIQUEMENT TOUT LE WORKFLOW:                                 |
|  ├── 1. Verification MCP SmartStack (alerte si absent)                       |
|  ├── 2. Analyse du contexte (Application/Module/Granularite)                 |
|  ├── 3. Definition des integrations (Workflows/Notifs/IA)                    |
|  ├── 4. Creation prd.json + progress.txt (Ralph Loop ready)                  |
|  ├── 5. Execution phases 1-7 avec Ralph Loop                                 |
|  ├── 6. Validation utilisateur (gate obligatoire)                            |
|  ├── 7. Implementation avec Ralph Loop                                       |
|  └── 8. Documentation HTML auto-generee                                      |
|                                                                              |
|  RESULTAT: Feature complete en ~30 minutes avec validation                   |
+==============================================================================+
```

**Usage:**
```bash
# Mode automatique complet (RECOMMANDE)
/business-analyse "Je veux gerer les contacts clients avec import/export"

# Mode manuel (phases individuelles)
/business-analyse:1-init
/business-analyse:2-discover ...
```

---

## Philosophy

```
+==============================================================================+
|  THE BUSINESS ANALYST NEVER CODES                                            |
|                                                                              |
|  They produce:                                                               |
|  - Clear and complete SPECIFICATIONS                                         |
|  - Actionable business DOCUMENTATION                                         |
|  - Optimized development PROMPTS                                             |
|  - HTML DOCUMENTATION (React components)                                     |
|                                                                              |
|  They let the DEVELOPER implement according to specs                         |
+==============================================================================+
```

---

## PHASE 0: BUSINESS CONTEXT RESTRICTION (CRITICAL)

```
+==============================================================================+
|  CONTEXTE BUSINESS UNIQUEMENT                                                |
+==============================================================================+
|                                                                              |
|  La Business Analyse est EXCLUSIVEMENT pour le contexte "business":          |
|                                                                              |
|  ALLOWED:                                                                    |
|  - business/{application}/{module}                                           |
|  - Applications client/metier                                                |
|  - Nouveaux modules fonctionnels                                             |
|                                                                              |
|  FORBIDDEN (reserved for SmartStack core):                                   |
|  - platform/* (administration core)                                          |
|  - personal/* (user core)                                                    |
|  - system/* (technical infrastructure)                                       |
|                                                                              |
|  VALIDATION:                                                                 |
|  Each BA command MUST validate context before proceeding.                    |
|  If non-business context detected -> BLOCK with error message.               |
|                                                                              |
+==============================================================================+
```

### Permission Path Format

```
business.{application}.{module}.{action}

Examples:
- business.crm.contacts.read
- business.inventory.products.create
- business.hr.employees.update
```

---

## 7-Phase Workflow (Updated)

```
================================================================================

   INIT       DISCOVER      ANALYSE       SPECIFY      VALIDATE      HANDOFF      DOC-HTML
  +-----+    +---------+   +---------+   +---------+   +--------+   +---------+  +---------+
  |Setup|---+|Elicit   |--+|Model    |--+|Specify  |--+|Approve |--+|Prompt   |->|React Doc|
  +-----+    +---------+   +---------+   +---------+   +--------+   +---------+  +---------+
     |            |             |             |             |             |            |
     v            v             v             v             v             v            v
 Structure   Discovery.md   BRD.md        FRD.md       Approval     Dev Prompt   FrdDocPage
 Config      (40+ Q)        Process       Use Cases     Gate        Autonomous   i18n 4 lang
 Code Scan                  Rules         Wireframes    v NOK                    Routes
                            Doc Scan                    -> ANALYSE
                                                        (revise)

             [ULTRATHINK]  [ULTRATHINK]  [ULTRATHINK]              [ULTRATHINK]  [CONTEXT7]

================================================================================
```

---

## Available Commands

| Phase | Command | Model | Description | Output |
|-------|----------|-------|-------------|--------|
| **AUTO** | **`/business-analyse`** | **opus** | **Orchestration complete automatique** | **Feature complete** |
| 0 | `/business-analyse:0-orchestrate` | opus | Orchestration manuelle avec questions | context.json, prd.json |
| 0.5 | *Validation* | - | Context business check (automatic) | Block if not business |
| 1 | `/business-analyse:1-init` | haiku | Initialize project structure + code scan | `config.json`, structure |
| 2 | `/business-analyse:2-discover` | **opus** | Requirements elicitation (ultrathink) | `1-discovery.md` |
| 3 | `/business-analyse:3-analyse` | sonnet | Business analysis BRD + doc scan (ultrathink) | `2-business-requirements.md` |
| 4 | `/business-analyse:4-specify` | sonnet | Functional specifications FRD (ultrathink) | `3-functional-specification.md` |
| 5 | `/business-analyse:5-validate` | haiku | User validation gate | `validation.json` |
| 6 | `/business-analyse:6-handoff` | **opus** | Development prompt (ultrathink) | `4-development-handoff.md` |
| -> | **`/implement FEAT-XXX`** | **opus** | **Implement from handoff (skip explore)** | Code files |
| 7 | `/business-analyse:7-doc-html` | sonnet | **React HTML documentation + Context7** | `FrdDocPage.tsx`, i18n |
| + | `/business-analyse:bug` | sonnet | Bug documentation | `tracking/bugs/BUG-XXX.md` |
| * | `/business-analyse:hotfix` | haiku | Urgent fix (lightweight template) | `tracking/hotfixes/HF-XXX.md` |
| ~ | `/business-analyse:change-request` | sonnet | Formal spec change during dev | `tracking/changes/CR-XXX.md` |

---

## Context7 Integration (MANDATORY for Code Generation)

```
+==============================================================================+
|  CONTEXT7: Documentation a jour pour generation React                        |
+==============================================================================+
|                                                                              |
|  Phase 7 (doc-html) MUST use Context7 for React generation:                  |
|                                                                              |
|  Libraries to reference:                                                     |
|  - /facebook/react - React 19 patterns, hooks                                |
|  - /i18next/react-i18next - useTranslation, Trans                            |
|  - /remix-run/react-router - Link, useParams, useNavigate                    |
|  - /lucide-icons/lucide-react - Icons coherents                              |
|                                                                              |
|  Usage pattern in prompts:                                                   |
|  "use context7 with /facebook/react and /i18next/react-i18next               |
|   to generate {component} following SmartStack documentation patterns"       |
|                                                                              |
|  WHY:                                                                        |
|  - Ensures up-to-date React 19 syntax                                        |
|  - Correct i18n hook usage                                                   |
|  - Router v7 patterns                                                        |
|  - Consistent icon imports                                                   |
|                                                                              |
+==============================================================================+
```

---

## Artifact Structure

```
.business-analyse/
|-- config.json                         # Global configuration
|-- glossary.md                         # Unified business glossary
|-- .claudeignore                       # Files ignored by Claude
|
|-- business/                           # CONTEXT: business ONLY
|   +-- {application}/                  # APPLICATION level
|       |-- context.md                  # Application context
|       |-- stakeholders.md             # Stakeholders
|       +-- modules/                    # MODULE level
|           +-- {module-name}/
|               |-- context.md          # Module context
|               +-- features/
|                   +-- {FEAT-XXX-name}/
|                       |-- 1-discovery.md
|                       |-- 2-business-requirements.md
|                       |-- 3-functional-specification.md
|                       |-- 4-development-handoff.md
|                       |-- validation.json
|                       +-- tracking/
|                           |-- changes/
|                           |   +-- CR-FEAT-XXX-001.md
|                           |-- bugs/
|                           +-- hotfixes/
|
|-- documentation/
|   |-- data-dictionary/
|   |-- process-flows/
|   +-- architecture-decisions/
|
+-- templates/
    |-- discovery.md
    |-- business-requirements.md
    |-- functional-specification.md
    |-- development-handoff.md
    +-- bug-report.md
```

---

## HTML Documentation Output (Phase 7)

```
+==============================================================================+
|  OUTPUT HTML: Documentation integree dans chaque module Business             |
+==============================================================================+
|                                                                              |
|  Phase 7 genere la documentation DANS le module (pas dans /docs):            |
|                                                                              |
|  ROUTE:                                                                      |
|  /business/{application}/{module}/documentation                              |
|                                                                              |
|  STRUCTURE:                                                                  |
|  web/smartstack-web/src/pages/business/{app}/{module}/                       |
|  |-- IndexPage.tsx            # Page principale du module                    |
|  |-- ListPage.tsx             # Liste des entites                            |
|  |-- CreatePage.tsx           # Creation                                     |
|  |-- DetailPage.tsx           # Detail                                       |
|  +-- DocumentationPage.tsx    # Documentation FRD (PHASE 7)                  |
|                                                                              |
|  I18N:                                                                       |
|  web/smartstack-web/src/i18n/locales/                                        |
|  |-- fr/{app}-{module}.json   # Cles documentation.*                         |
|  |-- en/{app}-{module}.json                                                  |
|  |-- it/{app}-{module}.json                                                  |
|  +-- de/{app}-{module}.json                                                  |
|                                                                              |
|  ACCES:                                                                      |
|  - URL: http://localhost:5173/business/{app}/{module}/documentation          |
|  - Onglet "Documentation" dans la navigation du module                       |
|                                                                              |
+==============================================================================+
```

---

## Applied Standards

| Standard | Application |
|----------|-------------|
| **BABOK v3** | 6 Knowledge Areas, elicitation techniques |
| **IEEE 830** | SRS structure, requirements traceability |
| **BRD/FRD** | Business needs / specifications separation |

## Feature ID Standards

```
+==============================================================================+
|  FEATURE ID FORMAT: FEAT-XXX (where XXX is 3-digit number)                   |
+==============================================================================+
|                                                                              |
|  Format:    FEAT-001, FEAT-002, ..., FEAT-999                                |
|  Regex:     ^FEAT-\d{3}$                                                     |
|                                                                              |
|  RELATED IDs:                                                                |
|  - Business Rules:  BR-XXX       (e.g., BR-001)                              |
|  - Functional Reqs: FR-XXX       (e.g., FR-001)                              |
|  - Use Cases:       UC-XXX       (e.g., UC-001)                              |
|  - Bugs:            BUG-XXX      (e.g., BUG-001)                             |
|  - Hotfixes:        HF-YYYYMMDD-NNN (e.g., HF-20260112-001)                  |
|  - Change Requests: CR-FEAT-XXX-N (e.g., CR-FEAT-001-001)                    |
|                                                                              |
|  VALIDATION: Each command validates ID format before proceeding.             |
|                                                                              |
+==============================================================================+
```

## Document Versioning

```
+==============================================================================+
|  SPECIFICATION VERSIONING: Track changes to documents                        |
+==============================================================================+
|                                                                              |
|  VERSION FORMAT: Major.Minor (e.g., 1.0, 1.1, 2.0)                           |
|                                                                              |
|  Major version (X.0):                                                        |
|  - Significant scope change                                                  |
|  - Major revision after validation rejection                                 |
|  - Breaking changes to previously approved specs                             |
|                                                                              |
|  Minor version (X.Y):                                                        |
|  - Clarifications, typo fixes                                                |
|  - Minor additions within scope                                              |
|  - Change request implementations                                            |
|                                                                              |
|  VERSION HISTORY: Each document maintains a changelog                        |
|  LOCKED AT HANDOFF: Version is locked when handoff is generated              |
|  POST-HANDOFF CHANGES: Require Change Request (CR) process                   |
|                                                                              |
+==============================================================================+
```

## ULTRATHINK Mode Definition

```
+==============================================================================+
|  ULTRATHINK: Deep Thinking Mode for Complex Analysis                         |
+==============================================================================+
|                                                                              |
|  ULTRATHINK is a BEHAVIORAL MODE, not a tool or skill to invoke.             |
|                                                                              |
|  WHEN TO USE:                                                                |
|  Phases marked with (ultrathink): discover, analyse, specify, handoff        |
|                                                                              |
|  HOW IT WORKS:                                                               |
|  Claude activates extended thinking to:                                      |
|  - Consider all edge cases before responding                                 |
|  - Challenge assumptions aggressively                                        |
|  - Generate comprehensive outputs                                            |
|  - Validate completeness before outputting                                   |
|                                                                              |
|  MODEL REQUIREMENT:                                                          |
|  ULTRATHINK phases require OPUS model for best results.                      |
|  Other models may produce less thorough analysis.                            |
|                                                                              |
|  NOT A SKILL INVOCATION:                                                     |
|  Do NOT call Skill("ultrathink"). It is a behavioral instruction.            |
|                                                                              |
+==============================================================================+
```

## Model Strategy

```
+==============================================================================+
|  MODEL REQUIREMENTS: Quality First, Then Cost Optimization                   |
+==============================================================================+
|                                                                              |
|  OPUS (Critical phases - deep reasoning required):                           |
|  - 2-discover: Exhaustive elicitation, challenge assumptions                 |
|  - 6-handoff: One-shot prompt generation, zero ambiguity                     |
|  - /implement: Production code generation                                    |
|                                                                              |
|  SONNET (Analysis phases - balanced reasoning):                              |
|  - 3-analyse: Business modeling, process documentation                       |
|  - 4-specify: Technical specifications, edge cases                           |
|  - 7-doc-html: React component generation with Context7                      |
|  - change-request: Impact analysis, decision matrix                          |
|  - bug: Root cause analysis                                                  |
|                                                                              |
|  HAIKU (Simple phases - template execution):                                 |
|  - 1-init: Structure setup, no decisions                                     |
|  - 5-validate: Approval gate, yes/no                                         |
|  - hotfix: Lightweight urgent fix                                            |
|                                                                              |
|  PRINCIPLE: Never sacrifice quality for cost savings.                        |
|  Each model is the MINIMUM capable of delivering quality output.             |
|                                                                              |
+==============================================================================+
```

## Permission Specifications

```
+==============================================================================+
|  PERMISSIONS IN HANDOFF: Must be EXPLICIT and IMPLEMENTABLE                  |
+==============================================================================+
|                                                                              |
|  CONTEXT RESTRICTION:                                                        |
|  All permissions MUST start with "business." prefix                          |
|  Format: business.{application}.{module}.{action}                            |
|                                                                              |
|  The 6-handoff includes a dedicated Section 7 for permissions:               |
|                                                                              |
|  7.1 [EXPLORE] - Discover existing permission patterns                       |
|  7.2 Permission Keys - Exact string codes (e.g., "business.crm.contacts.read")|
|  7.3 Role-Permission Matrix - Who can do what                                |
|  7.4 Endpoint-Permission Mapping - API protection                            |
|  7.5 UI Permission Checks - Button visibility rules                          |
|  7.6 Implementation Checklist - Step-by-step                                 |
|                                                                              |
|  MANDATORY in Gherkin scenarios:                                             |
|  - At least 1 permission denial scenario                                     |
|  - API 403 response test                                                     |
|  - UI element visibility test                                                |
|                                                                              |
|  "Admin can create" is NOT enough.                                           |
|  "POST /api/business/crm/contacts requires business.crm.contacts.create" IS. |
|                                                                              |
+==============================================================================+
```

## Golden Rules

1. **NEVER code** - BA produces specs, not code. NO C#, JS, SQL, Razor in any document.
2. **BUSINESS ONLY** - Only business context allowed. Platform/Personal/System are forbidden.
3. **ULTRATHINK mandatory** - Phases 2, 3, 4, 6 use deep thinking
4. **Model per phase** - Use correct model (opus/sonnet/haiku) per phase complexity
5. **Structure respected** - Business > Application > Module > Feature
6. **Traceability** - Each requirement has a unique ID
7. **User validation** - Phase 5 MUST be approved before handoff
8. **NOK -> Revise** - Rejected specs return to ANALYSE phase
9. **Maintained glossary** - Business terms documented
10. **Optimized prompts** - Handoff ready for one-shot implementation
11. **Tables over code** - Use attribute tables, not class definitions
12. **Explore-First** - Handoff instructs developer to explore existing patterns
13. **Explicit permissions** - business.* prefix, endpoint mapping, Gherkin tests mandatory
14. **Context7 for React** - Phase 7 MUST use Context7 for React generation
15. **4-language i18n** - FR, EN, IT, DE mandatory for HTML documentation

---

## Quick Start

```bash
# 1. Initialize project (scans code structure)
/business-analyse:1-init

# 2. New feature - Discovery (OPUS + ULTRATHINK)
/business-analyse:2-discover {application} {module} "Need description"

# 3. Analyze (scans existing docs for consistency)
/business-analyse:3-analyse FEAT-001

# 4. Specify functional requirements
/business-analyse:4-specify FEAT-001

# 5. User validates (REQUIRED before handoff)
/business-analyse:5-validate FEAT-001
#    -> If NOK: Return to /business-analyse:3-analyse with feedback

# 6. Generate dev prompt (after approval)
/business-analyse:6-handoff FEAT-001

# 7. IMPLEMENT the feature from handoff (RECOMMENDED)
/implement FEAT-001
#    -> Reads handoff, discovers patterns, generates code
#    -> Skips exploration (already done by BA)

# 8. Generate HTML documentation (Context7 + React)
/business-analyse:7-doc-html FEAT-001
#    -> Creates DocumentationPage.tsx in module folder
#    -> Adds documentation.* keys to i18n (4 languages)
#    -> Adds route: /business/{app}/{module}/documentation
#    -> Adds "Documentation" tab in module navigation
```

---

## One-Shot Feature avec Ralph-Loop (RECOMMANDE)

```
╔══════════════════════════════════════════════════════════════════════════════╗
║  RALPH-LOOP: Iteration autonome avec tracking d'état                         ║
╠══════════════════════════════════════════════════════════════════════════════╣
║                                                                              ║
║  Ralph-Loop permet a Claude d'iterer automatiquement avec MEMOIRE            ║
║  persistante via fichiers:                                                   ║
║                                                                              ║
║  FICHIERS RALPH (créés automatiquement):                                     ║
║  ├── prd.json        → Liste des tâches avec statut "passes": true/false     ║
║  └── progress.txt    → Mémoire persistante entre itérations                  ║
║                                                                              ║
║  PROCESSUS PAR ITERATION:                                                    ║
║  1. Lire prd.json → Trouver prochaine tâche "passes": false                  ║
║  2. Lire progress.txt → Comprendre le contexte                               ║
║  3. Travailler sur UNE SEULE tâche                                           ║
║  4. git commit                                                               ║
║  5. Mettre à jour prd.json → "passes": true                                  ║
║  6. Ajouter apprentissages à progress.txt                                    ║
║  7. Si TOUTES tâches "passes": true → <promise>COMPLETE</promise>            ║
║                                                                              ║
║  SIGNAL DE FIN UNIFIÉ: <promise>COMPLETE</promise>                           ║
║                                                                              ║
╚══════════════════════════════════════════════════════════════════════════════╝
```

### Usage recommande

```bash
# DISCOVERY avec ralph-loop (specs en beton)
/ralph-loop "/business-analyse:2-discover FEAT-001" \
            --completion-promise "COMPLETE" \
            --max-iterations 15

# ... phases 3-5 normales (analyse, specify, validate) ...

# HANDOFF avec ralph-loop (optionnel - garantie completude)
/ralph-loop "/business-analyse:6-handoff FEAT-001" \
            --completion-promise "COMPLETE" \
            --max-iterations 10

# IMPLEMENTATION avec ralph-loop (one-shot complet)
/ralph-loop "/implement FEAT-001" \
            --completion-promise "COMPLETE" \
            --max-iterations 25
```

### Flux simplifie

```
   DISCOVERY (Ralph)    PHASES 3-5     HANDOFF (Ralph?)   VALIDATE    IMPLEMENT (Ralph)
  +------------------+ +-----------+  +----------------+ +---------+ +------------------+
  | prd.json: 9 tasks|>| Analyse   |->| prd.json: 11   |>| HUMAIN  |>| prd.json: 18     |
  | progress.txt     | | Specify   |  | tasks          | | OK/NOK  | | tasks            |
  | UNE tâche/iter   | |           |  | progress.txt   | |         | | progress.txt     |
  +------------------+ +-----------+  +----------------+ +---------+ +------------------+
       OPUS + Ralph                     OPUS + Ralph?                     OPUS + Ralph
```

### Couts estimes

| Phase | Mode | Iterations | Cout |
|-------|------|------------|------|
| Discovery | One-shot | 1 | ~$0.30 |
| Discovery | Ralph-loop | 5-15 | ~$1.50-4.50 |
| Handoff | One-shot | 1 | ~$0.35 |
| Handoff | Ralph-loop | 3-10 | ~$1.00-2.50 |
| Implement | One-shot | 1 | ~$2.00 |
| Implement | Ralph-loop | 10-25 | ~$5.00-15.00 |

### Prerequis

Le plugin `ralph-loop` doit etre installe:
```bash
smartstack install  # Installe automatiquement ralph-loop
# ou manuellement:
claude plugin install ralph-loop@claude-plugins-official
```

### Fichiers Ralph créés par phase

| Phase | prd.json tasks | Description |
|-------|----------------|-------------|
| Discovery | 9 tâches | Catégories du 1-discovery.md |
| Handoff | 11 tâches | Sections du 4-development-handoff.md |
| Implement | 18 tâches | Backend/Frontend/Integrations/Tests |

---

## Post-Implementation Changes

```bash
# Bug discovered after implementation:
/business-analyse:bug FEAT-001
#    -> Root cause analysis (5 Whys)
#    -> Links to impacted BR/FR/UC

# Urgent fix needed in production:
/business-analyse:hotfix
#    -> Lightweight template
#    -> Quick fix prompt

# Scope change requested after handoff:
/business-analyse:change-request FEAT-001 "Add preview feature to page X"
#    -> Documents change, generates implementation prompt
#    -> For small changes: offers immediate implementation
```

---

## Skill Reference

The BA workflow also has a skill for automatic invocation:

```yaml
# Skill: /skills/business-analyse/SKILL.md
name: business-analyse
description: |
  Analyses business requirements and generates functional specifications (FRD) for SmartStack.
  Produces HTML documentation in the web project. Restricted to Business context only.
```

The skill is triggered automatically when user asks about:
- Business analysis, specifications, FRD
- User stories, business rules
- Functional requirements

---

## Next

**Mode automatique (RECOMMANDE):**
```bash
/business-analyse "Description de votre besoin"
```

**Mode manuel:**
```bash
/business-analyse:1-init
```

---

## EXECUTION AUTOMATIQUE

Si cette commande est appelee avec un argument (description du besoin):

```
ARGUMENTS = "$ARGUMENTS"

SI ARGUMENTS non vide:
  → Executer /business-analyse:0-orchestrate $ARGUMENTS
  → Le workflow complet est lance automatiquement

SINON:
  → Afficher ce fichier d'aide
  → Proposer les options
```

**Lancer le mode automatique maintenant:**

```javascript
if (ARGUMENTS && ARGUMENTS.trim().length > 0) {
  // Mode automatique - lancer l'orchestration
  execute("/business-analyse:0-orchestrate " + ARGUMENTS);
} else {
  // Mode manuel - afficher l'aide et proposer les options
  AskUserQuestion({
    questions: [{
      question: "Comment souhaitez-vous proceder?",
      header: "Mode",
      options: [
        { label: "Mode automatique (Recommande)", description: "Orchestration complete avec Ralph Loop" },
        { label: "Mode manuel", description: "Executer les phases une par une" }
      ],
      multiSelect: false
    }]
  });
}
```
