---
name: business-analyse-html
description: "Generate the interactive HTML document from business analysis JSON data"
model: opus
user_invocable: true
---

# /business-analyse-html

Generate the interactive HTML document of the business analysis from the JSON analysis files.

## Triggers

- Explicit invocation: `/business-analyse-html <feature-id>`
- After `/business-analyse` step-04 (consolidation complete)
- Delegation from `/business-analyse-review` (after review corrections applied)

## Parameters

| Parameter | Required | Description |
|-----------|----------|-------------|
| `<feature-id>` | Yes | Feature identifier (e.g., FEAT-001) |
| `--force` | No | Regenerate even if HTML already exists |

## Prerequisites

- JSON analysis files must exist (at minimum `index.json` + `cadrage.json`)
- Feature status must be `consolidated`

## Project Detection (ba-006)

When launched, detect and select the target project:

```
1. Glob: docs/*/v*/index.json
2. If 0 projects → BLOCKING ERROR "No project found. Run /business-analyse first."
3. If 1 project → auto-select
4. If N projects → AskUserQuestion "Which project?"
5. Store projectSlug, docs_dir in session
```

**Legacy fallback:** Also check `docs/business-analyse/v*/index.json` and `docs/*/business-analyse/v*/index.json`.

## Workflow

4 progressive steps:

| Step | File | Role |
|------|------|------|
| 01 | `steps/step-01-collect.md` | Read JSON sources (index, cadrage, modules, consolidation) |
| 02 | `steps/step-02-build-data.md` | Build FEATURE_DATA + EMBEDDED_ARTIFACTS objects |
| 03 | `steps/step-03-render.md` | Inject into ba-interactive.html template, write final file |
| 04 | `steps/step-04-verify.md` | POST-CHECK (size, sections, coherence) |

## Absolute Rules

- **NEVER** deploy an empty template — FEATURE_DATA must be injected
- **moduleSpecs** MUST have ONE entry per module (empty = BROKEN)
- **moduleSpecs[].screens[]** MUST have populated resources when source screens.json has data (empty resources = NO HTML mockups)
- **Scope keys** MUST be converted: `inScope` → `inscope`, `outOfScope` → `outofscope`
- **Wireframe fields** MUST be renamed: `mockupFormat` → `format`, `mockup` → `content`
- **Input normalization** MUST handle both JSON schemas: Format A (`screens[]`, `useCases`, `mainScenario`) and Format B (`sections[]`, `usecases`, `steps[]` as objects)
- **NEVER** call `.join()` on arrays without checking element types — object elements produce `[object Object]`
- **Final file** MUST be > 100KB
- **Final file** MUST NOT contain the string `[object Object]`
- **NEVER** reuse a build script (`_build-html.js`, `generate-html.js`) from a previous session — always re-execute steps 01→02→03→04 from scratch. Build scripts are throwaway artifacts that bypass the skill's normalization logic.
- **With `--force`:** delete any existing build script before proceeding

## References

| File | Content |
|------|---------|
| `references/data-mapping.md` | JSON → FEATURE_DATA field mapping |
| `references/data-build.md` | FEATURE_DATA & EMBEDDED_ARTIFACTS construction |
| `references/output-modes.md` | Standard, micro, delta, multi-app modes |

## Entry Point

**FIRST ACTION:** Load `steps/step-01-collect.md`
